API - Get Destinations

Hello guys,

I would like to proceed a fully automated monitor / alerts creation and management.

I read this page : https://opendistro.github.io/for-elasticsearch-docs/docs/alerting/api/

But i don’t see how to GET all destinations configured on opendistro through api

hope finding somehting like :

GET _opendistro/_alerting/destinations/_search
{
    "query": {
    "match" : {
      "destination.name": "*IFTTT*"
    }
  }
}

But it doesn’t work.

The idea is to retrieve destination id in order to provide it in a create monitor request API.

How do you proceed ?

Thanks

Hi @pjo,

You’re correct that there isn’t an easy way to do this through the Alerting API at the moment. This was recently captured in an issue on the Alerting repo in Gitub. The search and GET APIs are missing for destinations and need to be added. You can use that issue to track the progress of this change.

As a temporary workaround, you can try to query the .opendistro-alerting-config index directly using an exists query to filter out destinations.

Something like:

GET /.opendistro-alerting-config/_search
{
  "query": {
    "exists": {
      "field": "destination"
    }
  }
}

Hope this helps.

Hi @qreshi,

Thanks for your answer.

I’ll try this workaround :slight_smile:

Feel free to +1