跳到正文

告警和发现结果 API ​

以下 API 可用于与告警和发现结果相关的任务。


获取告警 ​

提供检索与特定检测器类型或检测器 ID 相关的告警的选项。

参数 ​

请求告警时可以指定以下参数。

参数描述
detector_id用于获取告警的检测器 ID。在指定 detectorType 时可选。否则必填。
detectorType用于获取告警的检测器类型。在指定 detector_Id 时可选。否则必填。
severityLevel用于按告警严重性级别筛选。可选。
alertState用于按告警状态筛选。可能的值为 ACTIVE、ACKNOWLEDGED、COMPLETED、ERROR 或 DELETED。可选。
sortString此字段指定安全分析用于对告警进行排序的字符串。可选。
sortOrder用于对发现结果列表进行排序的顺序。可能的值为 asc 或 desc。可选。
missing没有找到别名映射的字段列表。可选。
size响应中返回的最大结果数的可选限制。可选。
startIndex分页指示器。可选。
searchString你希望在搜索中返回的告警属性。可选。

示例请求 ​

json
GET /_plugins/_security_analytics/alerts?detectorType=windows

示例响应 ​

json
{
    "alerts": [{
        "detector_id": "detector_12345",
        "id": "alert_id_1",
        "version": -3,
        "schema_version": 0,
        "trigger_id": "trigger_id_1",
        "trigger_name": "my_trigger",
        "finding_ids": ["finding_id_1"],
        "related_doc_ids": ["docId1"],
        "state": "ACTIVE",
        "error_message": null,
        "alert_history": [],
        "severity": null,
        "action_execution_results": [{
            "action_id": "action_id_1",
            "last_execution_time": 1665693544996,
            "throttled_count": 0
        }],
        "start_time": "2022-10-13T20:39:04.995023Z",
        "last_notification_time": "2022-10-13T20:39:04.995028Z",
        "end_time": "2022-10-13T20:39:04.995027Z",
        "acknowledged_time": "2022-10-13T20:39:04.995028Z"
    }],
    "total_alerts": 1,
    "detectorType": "windows"
}

响应字段 ​

告警会一直存在,直到你解决根本原因,并具有以下状态:

状态描述
ACTIVE告警正在进行中且未被确认。告警将保持此状态,直到你确认它们、删除与告警关联的触发器或完全删除监视器。
ACKNOWLEDGED有人已确认告警但尚未修复根本原因。
COMPLETED告警不再进行中。告警在相应触发器评估为 false 后进入此状态。
ERROR执行触发器时发生错误。此错误通常是由于错误的触发器或目标造成的。
DELETED有人在告警进行期间删除了与此告警关联的检测器或触发器。

确认告警 ​

在触发告警时发送确认。

示例请求 ​

json
POST /_plugins/_security_analytics/<detector_id>/_acknowledge/alerts

{"alerts":["4dc7f5a9-2c82-4786-81ca-433a209d5205"]}

示例响应 ​

json
{
  "acknowledged": [
    {
      "detector_id": "8YT5fYQBZ8IUM4axics6",
      "id": "4dc7f5a9-2c82-4786-81ca-433a209d5205",
      "version": 1,
      "schema_version": 4,
      "trigger_id": "1TP5fYQBMkkIGY6Pg-q8",
      "trigger_name": "test-trigger",
      "finding_ids": [
        "2e167f4b-8063-40ef-80f8-2afd9bf095b8"
      ],
      "related_doc_ids": [
        "1|windows"
      ],
      "state": "ACTIVE",
      "error_message": null,
      "alert_history": [],
      "severity": "1",
      "action_execution_results": [
        {
          "action_id": "BopdoIJKXd",
          "last_execution_time": 1668560817925,
          "throttled_count": 0
        }
      ],
      "start_time": "2022-11-16T01:06:57.748Z",
      "last_notification_time": "2022-11-16T01:06:57.748Z",
      "end_time": null,
      "acknowledged_time": null
    }
  ],
  "failed": [],
  "missing": []
}

获取发现结果 ​

获取发现结果 API 根据检测器属性返回发现结果。

参数 ​

获取发现结果时可以指定以下参数。

参数描述
detector_id用于获取告警的检测器 ID。在指定 detectorType 时可选。否则必填。
detectorType用于获取告警的检测器类型。在指定 detector_id 时可选。否则必填。
sortOrder用于对发现结果列表进行排序的顺序。可能的值为 asc 或 desc。可选。
size响应中返回的最大结果数的可选限制。可选。

示例请求 ​

json
GET /_plugins/_security_analytics/findings/_search?*detectorType*=
{
    "total_findings":2,
    "findings":[
       {
            "detectorId":"12345",
            "id":"2b9663f4-ae77-4df8-b84f-688a0195723b",
            "related_doc_ids":[
                "5"
            ],
            "index":"sbwhrzgdlg",
            "queries":[
                {
                    "id":"f1bff160-587b-4500-b60c-ab22c7abc652",
                    "name":"3",
                    "query":"test_field:\"us-west-2\"",
                    "tags":[
                        
                    ]
                }
            ],
            "timestamp":1664401088804,
            "document_list":[
                {
                    "index":"sbwhrzgdlg",
                    "id":"5",
                    "found":true,
                    "document":"{\n            \"message\" : \"This is an error from IAD region\",\n            \"test_strict_date_time\" : \"2022-09-28T21:38:02.888Z\",\n            \"test_field\" : \"us-west-2\"\n        }"
                }
            ]
        },
        {
            "detectorId":"12345",
            "id":"f43a2701-0ef5-4931-8254-bdf510f73952",
            "related_doc_ids":[
                "1"
            ],
            "index":"sbwhrzgdlg",
            "queries":[
                {
                    "id":"f1bff160-587b-4500-b60c-ab22c7abc652",
                    "name":"3",
                    "query":"test_field:\"us-west-2\"",
                    "tags":[
                        
                    ]
                }
            ],
            "timestamp":1664401088746,
            "document_list":[
                {
                    "index":"sbwhrzgdlg",
                    "id":"1",
                    "found":true,
                    "document":"{\n            \"message\" : \"This is an error from IAD region\",\n            \"test_strict_date_time\" : \"2022-09-28T21:38:02.888Z\",\n            \"test_field\" : \"us-west-2\"\n        }"
                }
            ]
        }
    ]
}