Custom webhook params documentation for `Create Destination` api

For custom webhooks, you must specify more information: parameters, authentication, and headers.

Currently the create destination api docs only provide examples for slack.

What are the params we need to pass in to the api call to create custom webhooks?

Thanks in advance!

Hi Shah,

For custom webhook, there are 2 options.

Option1:- You can embed everything into the Url (host, port, params)
Option2 :- You can input respective fields.

Example Api call with custom webhook with option 1

curl -X POST localhost:9200/_opendistro/_alerting/destinations -H ‘Content-Type: application/json’ -d ’
{
“name”: “custom with everythign in url”,
“type”: “custom_webhook”,
“custom_webhook”: {
“url”: “https://hooks.chime.aws/incomingwebhooks/383c0e2b-d028-44f4-8d38-XXXXXX?token=R2x1UlN4ZHF8MXxxVFJpelJNVDgzdGNwMnVRenJwRFBHUkR0NlhROWhXOVVTZXXXXXXXXX
}
}’

Example Api call with custom webhook with option 2

curl -X POST localhost:9200/_opendistro/_alerting/destinations -H 'Content-Type: application/json' -d '
{
 "type" : "custom_webhook",
 "name" : "custom chime",
 "custom_webhook" : {
   "path" : "incomingwebhooks/383c0e2b-d028-44f4-8d38-696754bXXXXXX",
   "header_params" : {
     "Content-Type" : "application/json"
   },
   "scheme" : "HTTPS",
   "port" : 443,
   "query_params" : {
     "token" : "R2x1UlN4ZHF8MXxxVFJpelJNVDgzdGNwMnVRenJwRFBHUkR0NlhROWhXOVVTZXpXXXXX"
   },
   "host" : "hooks.chime.aws"
 }
 }'

Thanks Vamshin,

That worked!

Hi - could you provide some clarification on above. I am trying to set up a custom webhook for Pager Duty from Kibana UI - note this is an elasticsearch domain running in AWS for which the Alerting feature was available recently, and AWS direct us to Opendistro for further info.

In Alerting - Destinations - ‘Edit Destination’, I can either;

  • define endpoint by URL
  • Define endpoint by custom attributes URL

How would I compose the webhook URL needed in the ‘define endpoint by url’ field? I can send a test event using;

curl -H “Content-type: application/json” -X POST https://events.pagerduty.com/generic/2010-04-15/create_event.json -d ‘{ “service_key”: “”, “event_type”: “trigger”, “description”: “pd-test” }’

However what is the structure of the Webhook URL?

Thank you!

Swapna

Hi Swapna,

In url portion, you should provide

https://events.pagerduty.com/generic/2010-04-15/create_event.json

and in message body of action, you should provide

{ “service_key”: “”, “event_type”: “trigger”, “description”: “pd-test” }

Hi @vamshin,

Thank you for responding - I have done as you have said;

URL portion of webhook;

For the ‘in message body of action’ part - can you tell me where to enter this in the Kibana UI? The only place I can see ‘actions’ are within the trigger of the monitor, where you can edit the ‘message’ - is this correct?

I have removed the default ctx templates and replaced with ‘{ “service_key”: “”, “event_type”: “trigger”, “description”: “pd-test” }’. I have then run the ‘Send test message’, observing the results using developer tools - network in chrome. When I run this using AWS SNS (which is an integrated destination) it works, however using ^this method I get;

“output”:{},“throttled”:false,“error”:"java.io.IOException: Failed: HttpResponseProxy{HTTP/1.1 400 Bad Request

Please can you advise where I need to enter the parameters in the Kibana UI?

Hi @Swaps,

I responded to your question on the other thread: