# Incorrect HTTP method trying to create Alerting destination via API

**URL:** <https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780>\
**Category:** Alerting\
**Tags:** troubleshoot\
**Created:** [May 31, 2022, 7:21pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780 "2022-05-31T19:21:09Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [May 31, 2022, 7:21pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/1 "2022-05-31T19:21:09Z")

</div>

The following worked for me with v1.3.2 but isn’t working in v2.0.0:

```auto
$ cat /opt/alerting/destinations/malcolm_api_loopback_destination.json
{
  "type": "custom_webhook",
  "name": "Malcolm API Loopback Webhook",
  "custom_webhook": {
    "path": "alert",
    "header_params": {
      "Content-Type": "application/json"
    },
    "scheme": "HTTP",
    "method": "POST",
    "port": 5000,
    "host": "api"
  }
}

$ curl -L --show-error -XPOST "http://opensearch:9200/_opendistro/_alerting/destinations" -H 'osd-xsrf:true' -H 'Content-type:application/json' '-d@/opt/alerting/destinations/malcolm_api_loopback_destination.json' ; echo
{"error":"Incorrect HTTP method for uri [/_opendistro/_alerting/destinations] and method [POST], allowed: [GET]","status":405}

```

From what I can see in the documentation for the [create destination API](https://opendistro.github.io/for-elasticsearch-docs/docs/alerting/api/#create-destination), POST seems to be the correct method I should be using.

When I try a GET:

```auto
$ curl -L --show-error -XGET "http://opensearch:9200/_opendistro/_alerting/destinations" -H 'osd-xsrf:true' -H 'Content-type:application/json' ; echo
{"error":{"root_cause":[{"type":"alerting_exception","reason":"Configured indices are not found: [.opendistro-alerting-config]"}],"type":"alerting_exception","reason":"Configured indices are not found: [.opendistro-alerting-config]","caused_by":{"type":"exception","reason":"org.opensearch.index.IndexNotFoundException: no such index [.opendistro-alerting-config]"}},"status":404}

```

Which is what I would expect, actually, as the indices for `.opendistro-alerting-config` _haven’t_ been created yet, as my attempt to create a destination fails. Or is there some other API I need to call first now to initialize alerting before I can create a destination?

---

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [June 2, 2022, 1:11pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/2 "2022-06-02T13:11:28Z")

</div>

I’ll try logging an issue on GitHub.

---

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [June 2, 2022, 9:10pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/3 "2022-06-02T21:10:08Z")

</div>

Actually realizing I might be looking at old documentation (pre opendistro → opensearch) so maybe I’ve just got the API URLs wrong, I’ll test that first.

---

<div class="post-metadata">

**Author:** ![nateynate](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/nateynate/32/4913_2.png) [@nateynate](https://forum.opensearch.org/u/nateynate)\
**Post date:** [June 2, 2022, 9:52pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/4 "2022-06-02T21:52:23Z")

</div>

Thanks for sharing your issue @tlacuache - if the newer documentation doesn’t solve your issue make sure to drop another comment in here and we’ll work through it.

Nate

---

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [June 6, 2022, 1:33pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/5 "2022-06-06T13:33:15Z")

</div>

Thanks. I [updated](https://github.com/mmguero-dev/Malcolm/blob/development/dashboards/scripts/create-arkime-sessions-index.sh#L192-L221) to make sure I was using the right APIs (`/_plugins/_alerting/...` instead of `/_opendistro/_alerting/...`) but I am still getting the same errors as described in my first comment.

---

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [June 6, 2022, 1:41pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/6 "2022-06-06T13:41:01Z")

</div>

Could this have anything to do with “destinations” showing up as “deprecated” in the alerting plugin UI now? Maybe I shouldn’t even be using this API?

---

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [June 6, 2022, 1:51pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/7 "2022-06-06T13:51:02Z")

</div>

So I tried out creating a [notification channel](https://opensearch.org/docs/latest/notifications-plugin/api/#create-channel-configuration) instead of a destination and I apparently did so successfully. Still, I would think if the destinations feature were deprecated it should still work until it’s removed.

The other thing I’m not quite sure about: I don’t see in the documentation for channels how to specify things like the HTTP Method (seems to default to `POST`, which is okay for what I need, but where’s the config option?) or to specify custom Webhook headers or Query parameters. These are options that show up in the UI, but I don’t see them covered anywhere [here](https://opensearch.org/docs/latest/notifications-plugin/api/#create-channel-configuration).

---

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [June 6, 2022, 3:03pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/8 "2022-06-06T15:03:26Z")

</div>

After some more playing around and looking at the source code/test suite of the [notifications repo](https://github.com/opensearch-project/notifications) I was able to get things created the way I wanted to and figure out the options for the configuration of the webhook notification channel (to replace alerting destinations).

If there were anything I would suggest for the opensearch team it would be:

- flesh out the [API documentation](https://opensearch.org/docs/latest/notifications-plugin/api/) more (in my case, all of the options for the webhook config type were not documented)
- if you’re still supporting the deprecated alerting destinations for now, I was not able to get one created via the API, FWIW

---

<div class="post-metadata">

**Author:** ![nateynate](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/nateynate/32/4913_2.png) [@nateynate](https://forum.opensearch.org/u/nateynate)\
**Post date:** [June 7, 2022, 10:27pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/9 "2022-06-07T22:27:18Z")

</div>

@tlacuache - Thanks so much for the suggestion. Net time I get a chance I’ll be happy to file a documentation request on your behalf. If you’re feeling so inclined, you’re also more than welcome to fill out an issue in our documentation-website repo.

Thanks!

Nate

---

<div class="post-metadata">

**Author:** ![jdbright](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/jdbright/32/4979_2.png) [@jdbright](https://forum.opensearch.org/u/jdbright)\
**Post date:** [June 10, 2022, 6:03pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/10 "2022-06-10T18:03:11Z")

</div>

Hi again @tlacuache.

The team did announce the [breaking change](https://github.com/opensearch-project/alerting/issues/105#issuecomment-1071264000) in alerting on the [roadmap](https://github.com/orgs/opensearch-project/projects/1) which talked to the breaking changes in 2.0. I want to make sure I understand the gap though. It sounds like the API documentation could have been clearer. Anything else we could have done?

---

<div class="post-metadata">

**Author:** ![tlacuache](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/tlacuache/32/879_2.png) [@tlacuache](https://forum.opensearch.org/u/tlacuache)\
**Post date:** [June 10, 2022, 6:29pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/11 "2022-06-10T18:29:19Z")

</div>

Thanks! I should have picked up on it there, not sure how I missed it in the breaking changes. I guess that the thing that got me confused about it being removed vs. just deprecated was the fact that the Dashboards Alerting UI plugin still had the destinations controls in them (albeit with a “deprecated” warning at the top).

Besides that, the only speedbump I ran into was trying to figure out what all of the supported parameters were for the webook configuration type. The examples show the URL but I had to go digging in the source code to find the others.

---

<div class="post-metadata">

**Author:** ![jdbright](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/jdbright/32/4979_2.png) [@jdbright](https://forum.opensearch.org/u/jdbright)\
**Post date:** [June 10, 2022, 6:36pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/12 "2022-06-10T18:36:46Z")

</div>

I appreciate the quick feedback and will get the documentation added up if you haven’t already opened a ticket.

---

<div class="post-metadata">

**Author:** ![qreshi](https://avatars.discourse-cdn.com/v4/letter/q/aca169/32.png) [@qreshi](https://forum.opensearch.org/u/qreshi)\
**Post date:** [June 20, 2022, 6:09pm UTC](https://forum.opensearch.org/t/incorrect-http-method-trying-to-create-alerting-destination-via-api/9780/13 "2022-06-20T18:09:15Z")

</div>

Hi @tlacuache,

I also want to make sure we don’t cause confusion between the “deprecated” and “removal” labels for Alerting.

The reason the Destination page in the Alerting UI says deprecated is because the Destinations are still present in a read-only state as fallbacks but upon upgrading to 2.0 (along with Notifications plugin installed) the Destinations will automatically be migrated to Notification Channels.

From the Alerting API perspective, the Destination write APIs have been removed and the read APIs are deprecated with a plan to remove them as well in 3.0. There should be references to this in the breaking changes as @jdbright mentioned and we do have some [FAQ sections in the documentation that sheds some more light on this migration](https://opensearch.org/docs/latest/monitoring-plugins/alerting/monitors/#questions-about-destinations).

Feel free to create an issue or update an existing one you might have if you feel there is anything missing here.
