Find and/or aggregate detection alerts

POST /api/detection_engine/signals/search

Spaces method and path for this operation:

post /s/{space_id}/api/detection_engine/signals/search

Refer to Spaces for more information.

Find and/or aggregate detection alerts that match the given query.

application/json

Body Required

Search and/or aggregation query

Responses

  • 200 application/json

    Successful response

    Elasticsearch search response

    Additional properties are allowed.

  • 400 application/json

    Invalid input data response

    One of:
  • 401 application/json

    Unsuccessful authentication response

    Hide response attributes Show response attributes object
    • error string Required
    • message string Required
    • statusCode integer Required
  • 500 application/json

    Internal server error response

    Hide response attributes Show response attributes object
    • message string Required
    • status_code integer Required
POST /api/detection_engine/signals/search
curl \
 --request POST 'https://localhost:5601/api/detection_engine/signals/search' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '"{\n  \"aggs\": {\n    \"alertsByGrouping\": {\n      \"terms\": {\n        \"field\": \"host.name\",\n        \"size\": 10\n      }\n    },\n    \"missingFields\": {\n      \"missing\": {\n        \"field\": \"host.name\"\n      }\n    }\n  },\n  \"query\": {\n    \"bool\": {\n      \"filter\": [\n        {\n          \"bool\": {\n            \"filter\": [\n              {\n                \"match_phrase\": {\n                  \"kibana.alert.workflow_status\": \"open\"\n                }\n              }\n            ],\n            \"must\": [],\n            \"must_not\": [\n              {\n                \"exists\": {\n                  \"field\": \"kibana.alert.building_block_type\"\n                }\n              }\n            ],\n            \"should\": []\n          }\n        },\n        {\n          \"range\": {\n            \"@timestamp\": {\n              \"gte\": \"2025-01-17T08:00:00.000Z\",\n              \"lte\": \"2025-01-18T07:59:59.999Z\"\n            }\n          }\n        }\n      ]\n    }\n  },\n  \"runtime_mappings\": {},\n  \"size\": 0\n}"'
Request example
{
  "aggs": {
    "alertsByGrouping": {
      "terms": {
        "field": "host.name",
        "size": 10
      }
    },
    "missingFields": {
      "missing": {
        "field": "host.name"
      }
    }
  },
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "filter": [
              {
                "match_phrase": {
                  "kibana.alert.workflow_status": "open"
                }
              }
            ],
            "must": [],
            "must_not": [
              {
                "exists": {
                  "field": "kibana.alert.building_block_type"
                }
              }
            ],
            "should": []
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": "2025-01-17T08:00:00.000Z",
              "lte": "2025-01-18T07:59:59.999Z"
            }
          }
        }
      ]
    }
  },
  "runtime_mappings": {},
  "size": 0
}
Response examples (200)
{
  "_shards": {
    "failed": 0,
    "skipped": 0,
    "successful": 1,
    "total": 1
  },
  "aggregations": {
    "alertsByGrouping": {
      "buckets": [
        {
          "doc_count": 5,
          "key": "Host-f43kkddfyc"
        }
      ],
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0
    },
    "missingFields": {
      "doc_count": 0
    }
  },
  "hits": {
    "hits": [],
    "max_score": null,
    "total": {
      "relation": "eq",
      "value": 5
    }
  },
  "timed_out": false,
  "took": 0
}