add query thread polaris tools

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

@ -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)

@ -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

@ -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)

@ -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

@ -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)

@ -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

@ -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)

@ -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

@ -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)

@ -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

@ -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)

@ -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

@ -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)

@ -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

@ -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)

@ -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
Loading…
Cancel
Save