add apo user api
parent
9735940185
commit
96657b65ee
@ -1,48 +0,0 @@
|
||||
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 ContainerCpuThrottleContainerdSecondsTool(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]:
|
||||
cadvisor_job_name = tool_parameters.get('cadvisor_job_name', '.*')
|
||||
namespace = tool_parameters.get('namespace', '.*')
|
||||
pod = tool_parameters.get('pod', '.*')
|
||||
start_time = tool_parameters.get("startTime")
|
||||
end_time = tool_parameters.get("endTime")
|
||||
params = {
|
||||
'metricName': '基础设施情况 - 容器CPU - 容器CPU节流时间 - Containerd',
|
||||
'params': {
|
||||
'cadvisor_job_name': cadvisor_job_name,
|
||||
'namespace': namespace,
|
||||
'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)
|
||||
@ -1,75 +0,0 @@
|
||||
identity:
|
||||
name: 容器CPU节流时长(使用Containerd容器运行时,按容器和Pod统计)
|
||||
author: APO
|
||||
label:
|
||||
en_US: Container CPU throttling time (Containerd runtime, aggregated by container and Pod)
|
||||
zh_Hans: 容器CPU节流时长(使用Containerd容器运行时,按容器和Pod统计)
|
||||
description:
|
||||
human:
|
||||
en_US: Container CPU throttling time (Containerd runtime, aggregated by container and Pod)
|
||||
zh_Hans: 容器CPU节流时长(使用Containerd容器运行时,按容器和Pod统计)
|
||||
llm: Container CPU throttling time (Containerd runtime, aggregated by container and Pod)
|
||||
display:
|
||||
type: metric
|
||||
title: 基础设施情况 - 容器CPU - 容器CPU节流时间 - Containerd
|
||||
unit: "s"
|
||||
parameters:
|
||||
- name: cadvisor_job_name
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: cAdvisor job name
|
||||
zh_Hans: cAdvisor任务名称
|
||||
human_description:
|
||||
en_US: cAdvisor job name
|
||||
zh_Hans: cAdvisor任务名称
|
||||
llm_description: cAdvisor job name
|
||||
form: llm
|
||||
- name: namespace
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: Namespace
|
||||
zh_Hans: 命名空间
|
||||
human_description:
|
||||
en_US: Namespace
|
||||
zh_Hans: 命名空间
|
||||
llm_description: Namespace
|
||||
form: llm
|
||||
- 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
|
||||
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
|
||||
@ -1,44 +0,0 @@
|
||||
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 LinuxNetworkDroppedPacketsReceiveTool(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]:
|
||||
cluster = tool_parameters.get('cluster', '.*')
|
||||
start_time = tool_parameters.get("startTime")
|
||||
end_time = tool_parameters.get("endTime")
|
||||
params = {
|
||||
'metricName': '集群总览 - 总览 - 网络饱和 - 丢包数 - Linux Packets dropped (receive)',
|
||||
'params': {
|
||||
'cluster': cluster
|
||||
},
|
||||
'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)
|
||||
@ -1,53 +0,0 @@
|
||||
identity:
|
||||
name: Linux集群网络接收丢包数
|
||||
author: APO
|
||||
label:
|
||||
en_US: Linux cluster network receive packet drops
|
||||
zh_Hans: Linux集群网络接收丢包数
|
||||
description:
|
||||
human:
|
||||
en_US: Linux cluster network receive packet drops
|
||||
zh_Hans: Linux集群网络接收丢包数
|
||||
llm: Linux cluster network receive packet drops
|
||||
display:
|
||||
type: metric
|
||||
title: 集群总览 - 总览 - 网络饱和 - 丢包数 - Linux Packets dropped (receive)
|
||||
unit: "short"
|
||||
parameters:
|
||||
- name: cluster
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
human_description:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
llm_description: Cluster 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
|
||||
@ -1,44 +0,0 @@
|
||||
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 LinuxNetworkDroppedPacketsTransmitTool(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]:
|
||||
cluster = tool_parameters.get('cluster', '.*')
|
||||
start_time = tool_parameters.get("startTime")
|
||||
end_time = tool_parameters.get("endTime")
|
||||
params = {
|
||||
'metricName': '集群总览 - 总览 - 网络饱和 - 丢包数 - Linux Packets dropped (transmit)',
|
||||
'params': {
|
||||
'cluster': cluster
|
||||
},
|
||||
'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)
|
||||
@ -1,53 +0,0 @@
|
||||
identity:
|
||||
name: Linux集群网络发送丢包数
|
||||
author: APO
|
||||
label:
|
||||
en_US: Linux cluster network transmit packet drops
|
||||
zh_Hans: Linux集群网络发送丢包数
|
||||
description:
|
||||
human:
|
||||
en_US: Linux cluster network transmit packet drops
|
||||
zh_Hans: Linux集群网络发送丢包数
|
||||
llm: Linux cluster network transmit packet drops
|
||||
display:
|
||||
type: metric
|
||||
title: 集群总览 - 总览 - 网络饱和 - 丢包数 - Linux Packets dropped (transmit)
|
||||
unit: "short"
|
||||
parameters:
|
||||
- name: cluster
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
human_description:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
llm_description: Cluster 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
|
||||
@ -1,44 +0,0 @@
|
||||
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 NodeCpuUtilizationLinuxTool(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]:
|
||||
cluster = tool_parameters.get('cluster', '.*')
|
||||
start_time = tool_parameters.get("startTime")
|
||||
end_time = tool_parameters.get("endTime")
|
||||
params = {
|
||||
'metricName': '集群总览 - 节点资源使用 - 节点CPU使用率 - Linux',
|
||||
'params': {
|
||||
'cluster': cluster
|
||||
},
|
||||
'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)
|
||||
@ -1,53 +0,0 @@
|
||||
identity:
|
||||
name: Linux节点CPU使用率
|
||||
author: APO
|
||||
label:
|
||||
en_US: Linux node CPU utilization rate
|
||||
zh_Hans: Linux节点CPU使用率
|
||||
description:
|
||||
human:
|
||||
en_US: Linux node CPU utilization rate
|
||||
zh_Hans: Linux节点CPU使用率
|
||||
llm: Linux node CPU utilization rate
|
||||
display:
|
||||
type: metric
|
||||
title: 集群总览 - 节点资源使用 - 节点CPU使用率 - Linux
|
||||
unit: "percentunit"
|
||||
parameters:
|
||||
- name: cluster
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
human_description:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
llm_description: Cluster 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
|
||||
@ -1,44 +0,0 @@
|
||||
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 NodeMemoryUsageLinuxTool(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]:
|
||||
cluster = tool_parameters.get('cluster', '.*')
|
||||
start_time = tool_parameters.get("startTime")
|
||||
end_time = tool_parameters.get("endTime")
|
||||
params = {
|
||||
'metricName': '集群总览 - 节点资源使用 - 节点内存使用量 - Linux',
|
||||
'params': {
|
||||
'cluster': cluster
|
||||
},
|
||||
'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)
|
||||
@ -1,53 +0,0 @@
|
||||
identity:
|
||||
name: Linux节点内存使用字节数
|
||||
author: APO
|
||||
label:
|
||||
en_US: Linux node memory usage in bytes
|
||||
zh_Hans: Linux节点内存使用字节数
|
||||
description:
|
||||
human:
|
||||
en_US: Linux node memory usage in bytes
|
||||
zh_Hans: Linux节点内存使用字节数
|
||||
llm: Linux node memory usage in bytes
|
||||
display:
|
||||
type: metric
|
||||
title: 集群总览 - 节点资源使用 - 节点内存使用量 - Linux
|
||||
unit: "bytes"
|
||||
parameters:
|
||||
- name: cluster
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
human_description:
|
||||
en_US: Cluster name
|
||||
zh_Hans: 集群名称
|
||||
llm_description: Cluster 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
|
||||
Loading…
Reference in New Issue