Link Search Menu Expand Document Documentation Menu

搜索警报工具

2.13 版本引入

SearchAlertsTool 工具检索有关生成的告警信息。有关告警的更多信息,请参阅告警

步骤 1:注册将运行 SearchAlertsTool 的流代理

流代理按顺序运行一系列工具,并返回最后一个工具的输出。要创建流代理,请发送以下注册代理请求:

POST /_plugins/_ml/agents/_register
{
  "name": "Test_Agent_For_Search_Alerts_Tool",
  "type": "flow",
  "description": "this is a test agent for the SearchAlertsTool",
  "memory": {
    "type": "demo"
  },
  "tools": [
      {
      "type": "SearchAlertsTool",
      "name": "DemoSearchAlertsTool",
      "parameters": {}
    }
  ]
}

有关参数描述,请参阅注册参数

OpenSearch 返回一个代理 ID

{
  "agent_id": "EuJYYo0B9RaBCvhuy1q8"
}

步骤 2:运行代理

通过发送以下请求来运行代理

POST /_plugins/_ml/agents/EuJYYo0B9RaBCvhuy1q8/_execute
{
  "parameters": {
    "question": "Do I have any alerts?"
  }
}

OpenSearch 返回生成的告警列表和告警总数

{
  "inference_results": [
    {
      "output": [
        {
          "name": "response",
          "result": "Alerts=[Alert(id=rv9nYo0Bk4MTqirc_DkW, version=394, schemaVersion=5, monitorId=ZuJnYo0B9RaBCvhuEVux, workflowId=, workflowName=, monitorName=test-monitor-2, monitorVersion=1, monitorUser=User[name=admin, backend_roles=[admin], roles=[own_index, all_access], custom_attribute_names=[], user_requested_tenant=null], triggerId=ZeJnYo0B9RaBCvhuEVul, triggerName=t-1, findingIds=[], relatedDocIds=[], state=ACTIVE, startTime=2024-02-01T02:03:18.420Z, endTime=null, lastNotificationTime=2024-02-01T08:36:18.409Z, acknowledgedTime=null, errorMessage=null, errorHistory=[], severity=1, actionExecutionResults=[], aggregationResultBucket=null, executionId=ZuJnYo0B9RaBCvhuEVux_2024-02-01T02:03:18.404853331_51c18f2c-5923-47c3-b476-0f5a66c6319b, associatedAlertIds=[])]TotalAlerts=1"
        }
      ]
    }
  ]
}

如果未找到告警,OpenSearch 会在结果中返回一个空数组

{
  "inference_results": [
    {
      "output": [
        {
          "name": "response",
          "result": "Alerts=[]TotalAlerts=0"
        }
      ]
    }
  ]
}

注册参数

下表列出了注册代理时可用的所有工具参数。所有参数都是可选的。

参数 类型 描述
alertIds 数组 要搜索的告警 ID。
monitorId 字符串 用于过滤告警的监控器名称。
workflowIds 数组 用于过滤告警的工作流 ID 列表。
alertState 字符串 用于过滤告警的告警状态。有效值为 ALLACTIVEERRORCOMPLETEDACKNOWLEDGED。默认为 ALL
severityLevel 字符串 用于过滤告警的严重性级别。有效值为 ALL123。默认为 ALL
searchString 字符串 用于搜索特定告警的搜索字符串。
sortOrder 字符串 结果的排序顺序。有效值为 asc(升序)和 desc(降序)。默认为 asc
sortString 字符串 指定用于排序结果的监控器字段。默认为 monitor_name.keyword
size 整数 要返回的结果数量。默认值为 20
startIndex 整数 要开始的分页告警索引。默认为 0

执行参数

下表列出了运行代理时可用的所有工具参数。

参数 类型 必需/可选 描述
问题 字符串 必需 要发送到 LLM 的自然语言问题。
剩余 350 字符

有问题?

想要贡献?