diff --git a/api/core/tools/builtin_tool/providers/apo_rule/apo_rule.yaml b/api/core/tools/builtin_tool/providers/apo_rule/apo_rule.yaml index 55ba8108bc..3659e96ddf 100644 --- a/api/core/tools/builtin_tool/providers/apo_rule/apo_rule.yaml +++ b/api/core/tools/builtin_tool/providers/apo_rule/apo_rule.yaml @@ -3,7 +3,7 @@ identity: name: apo_rule label: en_US: APORule - zh_Hans: APO规则执行 + zh_Hans: APO数据分析规则 pt_BR: APORule description: en_US: The user inputs the rules described in natural language for large model reasoning diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu.yaml index ba45f44e20..ba92fa1232 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu.yaml @@ -3,7 +3,7 @@ identity: author: APO label: en_US: Query the CPU utilization of the container - zh_Hans: 查询容器CPU利用率 + zh_Hans: 容器CPU使用率(使用Containerd容器运行时,按容器和Pod统计) pt_BR: Query the CPU utilization of the container display: type: metric @@ -12,7 +12,7 @@ display: description: human: en_US: Query the CPU utilization of the container - zh_Hans: 查询容器CPU利用率 + zh_Hans: 容器CPU使用率(使用Containerd容器运行时,按容器和Pod统计) pt_BR: Query the CPU utilization of the container llm: Query the CPU utilization of the container parameters: diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu_cfs.py b/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu_cfs.py new file mode 100644 index 0000000000..e915c37cec --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu_cfs.py @@ -0,0 +1,45 @@ +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 SelectContainerCPUTool(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") + namespace = tool_parameters.get("namespace") + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': '基础设施情况 - 容器CPU - 容器CPU节流时间 - Containerd', + 'params': { + "pod": pod, + "namespace": namespace + }, + '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/container_cpu_cfs.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu_cfs.yaml new file mode 100644 index 0000000000..d68cc5d825 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/container_cpu_cfs.yaml @@ -0,0 +1,70 @@ +identity: + name: 容器CPU节流时长(使用Containerd容器运行时,按容器和Pod统计) + author: APO + label: + en_US: Query the CPU utilization of the container + zh_Hans: 容器CPU节流时长(使用Containerd容器运行时,按容器和Pod统计) + pt_BR: Query the CPU utilization of the container +display: + type: metric + title: 基础设施情况 - 容器CPU - 容器CPU节流时间 - Containerd + unit: s 秒 +description: + human: + en_US: Query the CPU utilization of the container + zh_Hans: 容器CPU节流时长(使用Containerd容器运行时,按容器和Pod统计) + pt_BR: Query the CPU utilization of the container + llm: Query the CPU utilization of the container +parameters: + - name: pod + type: string + required: true + label: + en_US: pod + zh_Hans: pod + pt_BR: pod + human_description: + en_US: Specified pod name + zh_Hans: 指定的容器POD名称 + pt_BR: Specified pod name + llm_description: Specified pod name + form: llm + - name: namespace + type: string + required: true + label: + en_US: namespace + zh_Hans: namespace + pt_BR: namespace + human_description: + en_US: Specified namespace + zh_Hans: 指定的容器所在Namespace + pt_BR: Specified namespace + llm_description: Specified namespace + 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 + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time + 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 + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time + llm_description: Data query start time + form: llm \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/container_disk_time.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/container_disk_time.yaml index a6935bf95a..a385aa51ff 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/container_disk_time.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/container_disk_time.yaml @@ -3,7 +3,7 @@ identity: author: APO label: en_US: Query the CPU utilization of the container - zh_Hans: 基础设施情况 - 容器磁盘 - 读写花费时间 /s - Read + zh_Hans: 容器磁盘读取耗时每秒(使用Containerd,按Pod和容器统计) pt_BR: Query the CPU utilization of the container display: type: metric @@ -12,9 +12,9 @@ display: description: human: en_US: Query the CPU utilization of the container - zh_Hans: 基础设施情况 - 容器磁盘 - 读写花费时间 /s - Read + zh_Hans: 容器磁盘读取耗时每秒(使用Containerd,按Pod和容器统计) pt_BR: Query the CPU utilization of the container - llm: 基础设施情况 - 容器磁盘 - 读写花费时间 /s - Read + llm: 容器磁盘读取耗时每秒(使用Containerd,按Pod和容器统计) parameters: - name: pod type: string diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/container_rss.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/container_rss.yaml index 7ba975df5b..3a67d4d66e 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/container_rss.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/container_rss.yaml @@ -3,14 +3,14 @@ identity: author: APO label: en_US: Query container resident memory usage - zh_Hans: 查询容器内存使用量 + zh_Hans: 容器内存使用字节数(使用Containerd容器运行时,按容器和Pod统计) pt_BR: Query container resident memory usage description: human: en_US: Query container resident memory usage - zh_Hans: 查询容器内存使用量 + zh_Hans: 容器内存使用字节数(使用Containerd容器运行时,按容器和Pod统计) pt_BR: Query container resident memory usage - llm: Query container resident memory usage + llm: 容器内存使用字节数(使用Containerd容器运行时,按容器和Pod统计) display: type: metric title: 基础设施情况 - 容器内存 - 容器内存使用率 - Containerd diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/container_rtt.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/container_rtt.yaml index 013c331a59..ac6adefbe7 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/container_rtt.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/container_rtt.yaml @@ -3,14 +3,14 @@ identity: author: APO label: en_US: Query container rtt - zh_Hans: 查询容器网络与下游RTT + zh_Hans: 容器与下游服务的网络往返时间(RTT,按命名空间和Pod统计) pt_BR: Query container rtt description: human: en_US: Query container rtt - zh_Hans: 查询容器网络与下游RTT + zh_Hans: 容器与下游服务的网络往返时间(RTT,按命名空间和Pod统计) pt_BR: Query container rtt - llm: Query container rtt + llm: 容器与下游服务的网络往返时间(RTT,按命名空间和Pod统计) display: type: metric title: 基础设施情况 - 容器网络 - 与下游服务RTT diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/host_cpu_iowait.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/host_cpu_iowait.yaml index 890de8e40b..d247cee292 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/host_cpu_iowait.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_cpu_iowait.yaml @@ -3,14 +3,14 @@ identity: author: APO label: en_US: Query the CPU utilization of the host - zh_Hans: 宿主机监控指标 - Basic CPU / Mem / Net / Disk - CPU Basic - Busy Iowait + zh_Hans: 宿主机IO等待CPU繁忙率 pt_BR: Query the CPU utilization of the host description: human: en_US: Query the CPU utilization of the host - zh_Hans: 宿主机监控指标 - Basic CPU / Mem / Net / Disk - CPU Basic - Busy Iowait + zh_Hans: 宿主机IO等待CPU繁忙率 pt_BR: Query the CPU utilization of the host - llm: 宿主机监控指标 - Basic CPU / Mem / Net / Disk - CPU Basic - Busy Iowait + llm: 宿主机IO等待CPU繁忙率 display: type: metric title: 宿主机监控指标 - Basic CPU / Mem / Net / Disk - CPU Basic - Busy Iowait diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_io.py b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_io.py new file mode 100644 index 0000000000..9c116b97e3 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_io.py @@ -0,0 +1,43 @@ +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 HostDiskIOTool(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]: + node = tool_parameters.get("node") + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': '宿主机监控指标 - Storage Disk - Time Spent Doing I/Os - IO', + 'params': { + "node": node + }, + '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/host_disk_io.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_io.yaml new file mode 100644 index 0000000000..6be11e7671 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_io.yaml @@ -0,0 +1,57 @@ +identity: + name: 宿主机磁盘IO耗时速率 + author: APO + label: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘IO耗时速率 + pt_BR: Query the CPU utilization of the host +description: + human: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘IO耗时速率 + pt_BR: Query the CPU utilization of the host + llm: 宿主机磁盘IO耗时速率 +display: + type: metric + title: 宿主机监控指标 - Storage Disk - Time Spent Doing I/Os - IO + unit: percent(0-100)百分比 +parameters: + - name: node + type: string + required: true + label: + en_US: node + zh_Hans: node + pt_BR: node + human_description: + en_US: Specified host name + zh_Hans: 指定的主机名 + pt_BR: Specified host name + llm_description: Specified host 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 + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time + 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 + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time + llm_description: Data query start time + form: llm \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_read_bytes.py b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_read_bytes.py new file mode 100644 index 0000000000..ec5d12c674 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_read_bytes.py @@ -0,0 +1,43 @@ +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 HostDiskReadBytesTool(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]: + node = tool_parameters.get("node") + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': '宿主机监控指标 - Storage Disk - Disk R/W Data - Read bytes', + 'params': { + "node": node + }, + '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/host_disk_read_bytes.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_read_bytes.yaml new file mode 100644 index 0000000000..183e041499 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_read_bytes.yaml @@ -0,0 +1,57 @@ +identity: + name: 宿主机磁盘读取数据速率(字节/秒) + author: APO + label: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘读取数据速率(字节/秒) + pt_BR: Query the CPU utilization of the host +description: + human: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘读取数据速率(字节/秒) + pt_BR: Query the CPU utilization of the host + llm: 宿主机磁盘读取数据速率(字节/秒) +display: + type: metric + title: 宿主机监控指标 - Storage Disk - Disk R/W Data - Read bytes + unit: Bps 字节每秒 +parameters: + - name: node + type: string + required: true + label: + en_US: node + zh_Hans: node + pt_BR: node + human_description: + en_US: Specified host name + zh_Hans: 指定的主机名 + pt_BR: Specified host name + llm_description: Specified host 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 + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time + 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 + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time + llm_description: Data query start time + form: llm \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_used.py b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_used.py new file mode 100644 index 0000000000..3db6746ad4 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_used.py @@ -0,0 +1,43 @@ +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 HostDiskUsedTool(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]: + node = tool_parameters.get("node") + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': '宿主机监控指标 - Basic CPU / Mem / Net / Disk - Disk Space Used Basic', + 'params': { + "node": node + }, + '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/host_disk_used.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_used.yaml new file mode 100644 index 0000000000..8d2d253eea --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_used.yaml @@ -0,0 +1,57 @@ +identity: + name: 宿主机磁盘使用率(百分比,不含rootfs) + author: APO + label: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘使用率(百分比,不含rootfs) + pt_BR: Query the CPU utilization of the host +description: + human: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘使用率(百分比,不含rootfs) + pt_BR: Query the CPU utilization of the host + llm: 宿主机磁盘使用率(百分比,不含rootfs) +display: + type: metric + title: 宿主机监控指标 - Basic CPU / Mem / Net / Disk - Disk Space Used Basic + unit: percent(0-100)百分比 +parameters: + - name: node + type: string + required: true + label: + en_US: node + zh_Hans: node + pt_BR: node + human_description: + en_US: Specified host name + zh_Hans: 指定的主机名 + pt_BR: Specified host name + llm_description: Specified host 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 + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time + 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 + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time + llm_description: Data query start time + form: llm \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_write_bytes.py b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_write_bytes.py new file mode 100644 index 0000000000..0211ad315a --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_write_bytes.py @@ -0,0 +1,43 @@ +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 HostDiskWriteBytesTool(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]: + node = tool_parameters.get("node") + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': '宿主机监控指标 - Storage Disk - Disk R/W Data - Written bytes', + 'params': { + "node": node + }, + '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/host_disk_write_bytes.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_write_bytes.yaml new file mode 100644 index 0000000000..08b2705cad --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_disk_write_bytes.yaml @@ -0,0 +1,57 @@ +identity: + name: 宿主机磁盘写入数据速率(字节/秒) + author: APO + label: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘写入数据速率(字节/秒) + pt_BR: Query the CPU utilization of the host +description: + human: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机磁盘写入数据速率(字节/秒) + pt_BR: Query the CPU utilization of the host + llm: 宿主机磁盘写入数据速率(字节/秒) +display: + type: metric + title: 宿主机监控指标 - Storage Disk - Disk R/W Data - Written bytes + unit: Bps 字节每秒 +parameters: + - name: node + type: string + required: true + label: + en_US: node + zh_Hans: node + pt_BR: node + human_description: + en_US: Specified host name + zh_Hans: 指定的主机名 + pt_BR: Specified host name + llm_description: Specified host 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 + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time + 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 + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time + llm_description: Data query start time + form: llm \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/host_fd_open.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/host_fd_open.yaml index b3d65545bd..17c566f28c 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/host_fd_open.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_fd_open.yaml @@ -1,16 +1,16 @@ identity: - name: host_cpu_iowait + name: host_cpu_fd_open author: APO label: en_US: Query the CPU utilization of the host - zh_Hans: 宿主机监控指标 - System Misc - File Descriptors - Open file descriptors + zh_Hans: 宿主机当前打开文件描述符数 pt_BR: Query the CPU utilization of the host description: human: en_US: Query the CPU utilization of the host zh_Hans: 宿主机当前打开文件描述符数 pt_BR: Query the CPU utilization of the host - llm: 宿主机监控指标 - System Misc - File Descriptors - Open file descriptors + llm: 宿主机当前打开文件描述符数 display: type: metric title: 宿主机监控指标 - System Misc - File Descriptors - Open file descriptors diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/host_net_recv.py b/api/core/tools/builtin_tool/providers/apo_select/tools/host_net_recv.py new file mode 100644 index 0000000000..dc991b8225 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_net_recv.py @@ -0,0 +1,43 @@ +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 HostCPUIoWaitRespTool(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]: + node = tool_parameters.get("node") + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': '宿主机监控指标 - Basic CPU / Mem / Net / Disk - Network Traffic Basic - recv', + 'params': { + "node": node + }, + '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/host_net_recv.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/host_net_recv.yaml new file mode 100644 index 0000000000..6eac135d46 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/host_net_recv.yaml @@ -0,0 +1,57 @@ +identity: + name: 宿主机网络接收速率(比特/秒) + author: APO + label: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机网络接收速率(比特/秒) + pt_BR: Query the CPU utilization of the host +description: + human: + en_US: Query the CPU utilization of the host + zh_Hans: 宿主机网络接收速率(比特/秒) + pt_BR: Query the CPU utilization of the host + llm: 宿主机网络接收速率(比特/秒) +display: + type: metric + title: 宿主机监控指标 - Basic CPU / Mem / Net / Disk - Network Traffic Basic - recv + unit: percent(0-100)百分比 +parameters: + - name: node + type: string + required: true + label: + en_US: node + zh_Hans: node + pt_BR: node + human_description: + en_US: Specified host name + zh_Hans: 指定的主机名 + pt_BR: Specified host name + llm_description: Specified host 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 + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time + 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 + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time + llm_description: Data query start time + form: llm \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_avg_resp.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_avg_resp.yaml index 7ff65f28f7..6923f662a7 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_avg_resp.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_avg_resp.yaml @@ -3,7 +3,7 @@ identity: author: APO label: en_US: Query the CPU utilization of the host - zh_Hans: Originx 北极星指标 (服务层级) - RED指标 - 平均响应时间 + zh_Hans: 服务平均响应时间(毫秒,按服务名和内容键统计,指定时间段内) pt_BR: Query the CPU utilization of the host description: human: diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_resp_ok.py b/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_resp_ok.py new file mode 100644 index 0000000000..94f009ec5e --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_resp_ok.py @@ -0,0 +1,45 @@ +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 OriginxServiceRedRespOkTool(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]: + service_name = tool_parameters.get("service_name") + content_key = tool_parameters.get("content_key") + start_time = tool_parameters.get("startTime") + end_time = tool_parameters.get("endTime") + params = { + 'metricName': 'Originx 北极星指标 (服务层级) - RED指标 - 请求成功率', + 'params': { + "service_name": service_name, + "content_key": content_key + }, + '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/originx_service_red_resp_ok.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_resp_ok.yaml new file mode 100644 index 0000000000..3d69720a88 --- /dev/null +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/originx_service_red_resp_ok.yaml @@ -0,0 +1,70 @@ +identity: + name: Originx 北极星指标 (服务层级) - RED指标 - 请求成功率 + author: APO + label: + en_US: Query the CPU utilization of the host + zh_Hans: 服务请求成功率(按服务名和内容键统计,指定时间段内) + pt_BR: Query the CPU utilization of the host +description: + human: + en_US: Query the CPU utilization of the host + zh_Hans: 服务请求成功率(按服务名和内容键统计,指定时间段内) + pt_BR: Query the CPU utilization of the host + llm: 服务请求成功率(按服务名和内容键统计,指定时间段内) +display: + type: metric + title: Originx 北极星指标 (服务层级) - RED指标 - 请求成功率 + unit: ms +parameters: + - name: service_name + type: string + required: true + label: + en_US: service_name + zh_Hans: service_name + pt_BR: service_name + human_description: + en_US: Specified service name + zh_Hans: 指定的服务名 + pt_BR: Specified service name + llm_description: 指定的服务名 + form: llm + - name: content_key + type: string + required: true + label: + en_US: content_key + zh_Hans: content_key + pt_BR: content_key + human_description: + en_US: Specified endpoint name + zh_Hans: 指定的服务端点名 + pt_BR: Specified endpoint name + llm_description: 指定的服务端点名 + 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 + zh_Hans: 开始时间 (微秒) + pt_BR: Data query start time + llm_description: Data query start time + 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 + zh_Hans: 结束时间 (微秒) + pt_BR: Data query end time + llm_description: Data query start time + form: llm \ No newline at end of file diff --git a/api/core/tools/builtin_tool/providers/apo_select/tools/select_cpu.yaml b/api/core/tools/builtin_tool/providers/apo_select/tools/select_cpu.yaml index 9f9a43d557..3490c4075a 100644 --- a/api/core/tools/builtin_tool/providers/apo_select/tools/select_cpu.yaml +++ b/api/core/tools/builtin_tool/providers/apo_select/tools/select_cpu.yaml @@ -3,14 +3,14 @@ identity: author: APO label: en_US: Query the CPU utilization of the host - zh_Hans: 查询主机CPU利用率 + zh_Hans: 宿主机CPU繁忙率(百分比) pt_BR: Query the CPU utilization of the host description: human: en_US: Query the CPU utilization of the host - zh_Hans: 查询主机CPU利用率 + zh_Hans: 宿主机CPU繁忙率(百分比) pt_BR: Query the CPU utilization of the host - llm: Query the CPU utilization of the host + llm: 宿主机CPU繁忙率(百分比) display: type: metric title: 宿主机监控指标 - Quick CPU / Mem / Disk - CPU Busy diff --git a/api/services/tools/builtin_tools_manage_service.py b/api/services/tools/builtin_tools_manage_service.py index 69aa447eec..210daa3966 100644 --- a/api/services/tools/builtin_tools_manage_service.py +++ b/api/services/tools/builtin_tools_manage_service.py @@ -351,7 +351,7 @@ class BuiltinToolManageService: match_tools = process.extract( query, [tool.entity.identity.label.zh_Hans for tool in tools], - limit=10, + limit=50, ) for match_name, score, index in match_tools or []: tool = tools[index]