add gen tools

pull/17608/head
fuwx 1 year ago
parent efdb480557
commit c6892c2c9d
No known key found for this signature in database
GPG Key ID: C8FA8C18DFB4702B

2
.gitignore vendored

@ -201,3 +201,5 @@ api/.vscode
# plugin migrate
plugins.jsonl
api/tools_generator/metrics_conf.json

@ -0,0 +1,48 @@
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 ContainerNetworkBandwidthReceiveTool(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': '基础设施情况 - 容器网络 - 网络带宽使用 - 接收',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络接收带宽(按命名空间和Pod统计)
author: APO
label:
en_US: Container network receive bandwidth (aggregated by namespace and Pod)
zh_Hans: 容器网络接收带宽(按命名空间和Pod统计)
description:
human:
en_US: Container network receive bandwidth (aggregated by namespace and Pod)
zh_Hans: 容器网络接收带宽(按命名空间和Pod统计)
llm: Container network receive bandwidth (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 网络带宽使用 - 接收
unit: "bytes"
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(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

@ -0,0 +1,48 @@
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 ContainerNetworkBandwidthTransmitTool(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': '基础设施情况 - 容器网络 - 网络带宽使用 - 发送',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络发送带宽(按命名空间和Pod统计)
author: APO
label:
en_US: Container network transmit bandwidth (aggregated by namespace and Pod)
zh_Hans: 容器网络发送带宽(按命名空间和Pod统计)
description:
human:
en_US: Container network transmit bandwidth (aggregated by namespace and Pod)
zh_Hans: 容器网络发送带宽(按命名空间和Pod统计)
llm: Container network transmit bandwidth (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 网络带宽使用 - 发送
unit: "bytes"
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(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

@ -0,0 +1,48 @@
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 ContainerNetworkErrorPacketsReceiveTool(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': '基础设施情况 - 容器网络 - 网络错误包数 - 接收',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络接收错误包数(按命名空间和Pod统计)
author: APO
label:
en_US: Container network received error packets (aggregated by namespace and Pod)
zh_Hans: 容器网络接收错误包数(按命名空间和Pod统计)
description:
human:
en_US: Container network received error packets (aggregated by namespace and Pod)
zh_Hans: 容器网络接收错误包数(按命名空间和Pod统计)
llm: Container network received error packets (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 网络错误包数 - 接收
unit: "pps"
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(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

@ -0,0 +1,48 @@
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 ContainerNetworkErrorPacketsTransmitTool(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': '基础设施情况 - 容器网络 - 网络错误包数 - 发送',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络发送错误包数(按命名空间和Pod统计)
author: APO
label:
en_US: Container network transmitted error packets (aggregated by namespace and Pod)
zh_Hans: 容器网络发送错误包数(按命名空间和Pod统计)
description:
human:
en_US: Container network transmitted error packets (aggregated by namespace and Pod)
zh_Hans: 容器网络发送错误包数(按命名空间和Pod统计)
llm: Container network transmitted error packets (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 网络错误包数 - 发送
unit: "pps"
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(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

@ -0,0 +1,48 @@
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 ContainerNetworkPacketLossReceiveTool(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': '基础设施情况 - 容器网络 - 丢包数 - Received',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络接收丢包数(按命名空间和Pod统计)
author: APO
label:
en_US: Container network received packet loss (aggregated by namespace and Pod)
zh_Hans: 容器网络接收丢包数(按命名空间和Pod统计)
description:
human:
en_US: Container network received packet loss (aggregated by namespace and Pod)
zh_Hans: 容器网络接收丢包数(按命名空间和Pod统计)
llm: Container network received packet loss (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 丢包数 - Received
unit: "pps"
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(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

@ -0,0 +1,48 @@
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 ContainerNetworkPacketLossTransmitTool(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': '基础设施情况 - 容器网络 - 丢包数 - Transmitted',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络发送丢包数(按命名空间和Pod统计)
author: APO
label:
en_US: Container network transmitted packet loss (aggregated by namespace and Pod)
zh_Hans: 容器网络发送丢包数(按命名空间和Pod统计)
description:
human:
en_US: Container network transmitted packet loss (aggregated by namespace and Pod)
zh_Hans: 容器网络发送丢包数(按命名空间和Pod统计)
llm: Container network transmitted packet loss (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 丢包数 - Transmitted
unit: "pps"
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(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

@ -0,0 +1,48 @@
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 ContainerNetworkPacketReceiveRateTool(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': '基础设施情况 - 容器网络 - 包传输速率 - 接收',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络接收包速率(按命名空间和Pod统计)
author: APO
label:
en_US: Container network packet receive rate (aggregated by namespace and Pod)
zh_Hans: 容器网络接收包速率(按命名空间和Pod统计)
description:
human:
en_US: Container network packet receive rate (aggregated by namespace and Pod)
zh_Hans: 容器网络接收包速率(按命名空间和Pod统计)
llm: Container network packet receive rate (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 包传输速率 - 接收
unit: "pps"
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(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

@ -0,0 +1,48 @@
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 ContainerNetworkPacketTransmitRateTool(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': '基础设施情况 - 容器网络 - 包传输速率 - 发送',
'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)

@ -0,0 +1,75 @@
identity:
name: 容器网络发送包速率(按命名空间和Pod统计)
author: APO
label:
en_US: Container network packet transmit rate (aggregated by namespace and Pod)
zh_Hans: 容器网络发送包速率(按命名空间和Pod统计)
description:
human:
en_US: Container network packet transmit rate (aggregated by namespace and Pod)
zh_Hans: 容器网络发送包速率(按命名空间和Pod统计)
llm: Container network packet transmit rate (aggregated by namespace and Pod)
display:
type: metric
title: 基础设施情况 - 容器网络 - 包传输速率 - 发送
unit: "pps"
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(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

@ -1,3 +0,0 @@
#!/bin/bash
docker run -d --name dify-api --network host --pid host -v /root/workspace/dify/api/.env:/app/api/.env -v /root/workspace/dify/docker/volumes/app/storage:/app/api/storage -e MIGRATION_ENABLED="true" -e DEBUG="true" -e MODE="api" registry.cn-hangzhou.aliyuncs.com/kindlingx/dify-api:apo-1.0.0-9d88021

@ -1,3 +0,0 @@
#!/bin/bash
docker run -d --name dify-worker --network host --pid host -v /root/workspace/dify/api/.env:/app/api/.env -v /root/workspace/dify/docker/volumes/app/storage:/app/api/storage -e MODE="worker" registry.cn-hangzhou.aliyuncs.com/kindlingx/dify-api:apo-1.0.0-9d88021

@ -1,7 +1,5 @@
from generator import ToolGenerator
import os
def main():
generator = ToolGenerator('./metrics_conf.json')
generator.generate_all("../core/tools/builtin_tool/providers/apo_select/tools")

Loading…
Cancel
Save