getting all monitors for a specific index in elasticsearch

351 Views Asked by At

I am using elasticsearch opendistro 7.2. and I have monitors with triggers created. I want to be able to delete all monitors that are relevant to a specific index (let's say "events_index").

This does not seem to work, any ideas how I should approach this?

GET _opendistro/_alerting/monitors/_search
{"query": {"bool": {"should": [
  {"term": {"monitor.inputs.search.indices": "events_index"}}
  ]}}}
1

There are 1 best solutions below

0
On

This should work:

GET _opendistro/_alerting/monitors/_search
{
  "query": {
   "nested": {
     "path": "monitor.inputs",
     "query": {
       "match": {
         "monitor.inputs.search.indices": "events_index"
       }
     }
   }
  }
}

Alternatively, using the query you mentioned:

GET _opendistro/_alerting/monitors/_search
{
  "query": {
    "nested": {
      "path": "monitor.inputs",
      "query": {
        "bool": {
          "should": [
            {
              "term": {
                "monitor.inputs.search.indices": {
                  "value": "events_index"
                }
              }
            }
          ]
        }
      }
    }
  }
}