diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_epoll_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_epoll_time.py new file mode 100644 index 0000000000..2f7d73d18a --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_epoll_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisEpollTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Epoll', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_epoll_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_epoll_time.yaml new file mode 100644 index 0000000000..3d5b298930 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_epoll_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在Epoll操作上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread Epoll operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在Epoll操作上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread Epoll operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在Epoll操作上的耗时折线图(按Pod统计) + llm: Thread Epoll operation time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Epoll + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_file_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_file_time.py new file mode 100644 index 0000000000..c9c764356b --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_file_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisFileTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - File', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_file_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_file_time.yaml new file mode 100644 index 0000000000..3fb8ea29d7 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_file_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在文件操作上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread file operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在文件操作上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread file operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在文件操作上的耗时折线图(按Pod统计) + llm: Thread file operation time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - File + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_futex_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_futex_time.py new file mode 100644 index 0000000000..d0ada87de5 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_futex_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisFutexTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Futex', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_futex_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_futex_time.yaml new file mode 100644 index 0000000000..d4aebcd527 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_futex_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在Futex操作上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread Futex operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在Futex操作上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread Futex operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在Futex操作上的耗时折线图(按Pod统计) + llm: Thread Futex operation time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Futex + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_idle_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_idle_time.py new file mode 100644 index 0000000000..18848a002f --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_idle_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisIdleTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Idle', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_idle_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_idle_time.yaml new file mode 100644 index 0000000000..a7c66d3ea6 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_idle_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在空闲状态上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread idle state time consumption line chart (aggregated by Pod) + zh_Hans: 线程在空闲状态上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread idle state time consumption line chart (aggregated by Pod) + zh_Hans: 线程在空闲状态上的耗时折线图(按Pod统计) + llm: Thread idle state time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Idle + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_net_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_net_time.py new file mode 100644 index 0000000000..a296bddfd0 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_net_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisNetTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Net', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_net_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_net_time.yaml new file mode 100644 index 0000000000..e076612a4c --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_net_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在网络操作上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread network operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在网络操作上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread network operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在网络操作上的耗时折线图(按Pod统计) + llm: Thread network operation time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Net + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_oncpu_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_oncpu_time.py new file mode 100644 index 0000000000..0c155473a9 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_oncpu_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisOncpuTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - OnCPU', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_oncpu_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_oncpu_time.yaml new file mode 100644 index 0000000000..725eae11fe --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_oncpu_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在CPU上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread CPU time consumption line chart (aggregated by Pod) + zh_Hans: 线程在CPU上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread CPU time consumption line chart (aggregated by Pod) + zh_Hans: 线程在CPU上的耗时折线图(按Pod统计) + llm: Thread CPU time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - OnCPU + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_other_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_other_time.py new file mode 100644 index 0000000000..76aa856b51 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_other_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisOtherTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Other', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_other_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_other_time.yaml new file mode 100644 index 0000000000..ef7481b82c --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_other_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在其他操作上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread other operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在其他操作上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread other operation time consumption line chart (aggregated by Pod) + zh_Hans: 线程在其他操作上的耗时折线图(按Pod统计) + llm: Thread other operation time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Other + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_runqueue_time.py b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_runqueue_time.py new file mode 100644 index 0000000000..fe7431cc18 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_runqueue_time.py @@ -0,0 +1,44 @@ +import json +from collections.abc import Generator +from typing import Any, Optional + +import requests + +from configs import dify_config +from core.tools.builtin_tool.tool import BuiltinTool +from core.tools.entities.tool_entities import ToolInvokeMessage +from libs.apo_utils import APOUtils + + +class ThreadPolarisRunqueueTimeTool(BuiltinTool): + def _invoke( + self, + user_id: str, + tool_parameters: dict[str, Any], + conversation_id: Optional[str] = None, + app_id: Optional[str] = None, + message_id: Optional[str] = None, + ) -> Generator[ToolInvokeMessage, None, None]: + pod = tool_parameters.get('pod', '.*') + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Runqueue', + 'params': { + 'pod': pod + }, + 'startTime': start_time, + 'endTime': end_time, + 'step': APOUtils.get_step(start_time, end_time), + } + resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params) + list = resp.json()['result'] + list = json.dumps({ + 'type': 'metric', + 'display': True, + 'unit': list['unit'], + 'data': { + 'timeseries': list['timeseries'] + } + }) + yield self.create_text_message(list) \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_runqueue_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_runqueue_time.yaml new file mode 100644 index 0000000000..c5334d4ff9 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/thread_polaris_runqueue_time.yaml @@ -0,0 +1,53 @@ +identity: + name: 线程在运行队列上的耗时折线图(按Pod统计) + author: APO + label: + en_US: Thread runqueue time consumption line chart (aggregated by Pod) + zh_Hans: 线程在运行队列上的耗时折线图(按Pod统计) +description: + human: + en_US: Thread runqueue time consumption line chart (aggregated by Pod) + zh_Hans: 线程在运行队列上的耗时折线图(按Pod统计) + llm: Thread runqueue time consumption line chart (aggregated by Pod) +display: + type: metric + title: Thread Polaris Metrics - 北极星指标(线程) - 各类型耗时折线图 - Runqueue + unit: "ns" +parameters: + - name: pod + type: string + required: False + label: + en_US: Pod name + zh_Hans: Pod名称 + human_description: + en_US: Pod name + zh_Hans: Pod名称 + llm_description: Pod name + form: llm + - name: startTime + type: number + required: true + label: + en_US: startTime + zh_Hans: startTime + pt_BR: startTime + human_description: + en_US: Data query start time(Microsecond) + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time(Microsecond) + form: llm + - name: endTime + type: number + required: true + label: + en_US: endTime + zh_Hans: endTime + pt_BR: endTime + human_description: + en_US: Data query end time(Microsecond) + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time(Microsecond) + llm_description: Data query end time(Microsecond) + form: llm