add log error level count
parent
f8431313d3
commit
1a699a2481
@ -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 LogErrorLevelCountTool(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_name = tool_parameters.get('pod_name', '.*')
|
||||
namespace = tool_parameters.get('namespace', '.*')
|
||||
pid = tool_parameters.get('pid', '.*')
|
||||
start_time = tool_parameters.get("startTime")
|
||||
end_time = tool_parameters.get("endTime")
|
||||
params = {
|
||||
'metricName': '宿主机监控指标 - 日志解析错误计数总览 - log error level count',
|
||||
'params': {
|
||||
'pod_name': pod_name,
|
||||
'namespace': namespace,
|
||||
'pid': pid
|
||||
},
|
||||
'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: 记录了日志解析系统中按错误级别统计的总次数
|
||||
author: APO
|
||||
label:
|
||||
en_US: Records the total count of log parsing system errors categorized by error level
|
||||
zh_Hans: 记录了日志解析系统中按错误级别统计的总次数
|
||||
description:
|
||||
human:
|
||||
en_US: Records the total count of log parsing system errors categorized by error level
|
||||
zh_Hans: 记录了日志解析系统中按错误级别统计的总次数
|
||||
llm: Records the total count of log parsing system errors categorized by error level
|
||||
display:
|
||||
type: metric
|
||||
title: 宿主机监控指标 - 日志解析错误计数总览 - log error level count
|
||||
unit: "short"
|
||||
parameters:
|
||||
- name: pod_name
|
||||
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: namespace
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: Namespace
|
||||
zh_Hans: 命名空间
|
||||
human_description:
|
||||
en_US: Namespace
|
||||
zh_Hans: 命名空间
|
||||
llm_description: Namespace
|
||||
form: llm
|
||||
- name: pid
|
||||
type: string
|
||||
required: False
|
||||
label:
|
||||
en_US: Process ID
|
||||
zh_Hans: 进程ID
|
||||
human_description:
|
||||
en_US: Process ID
|
||||
zh_Hans: 进程ID
|
||||
llm_description: Process ID
|
||||
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…
Reference in New Issue