Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Creating a conditional webhook

alerts
notifications
webhook

#1

My goal is to create a alert that sends a certain message when the incident opens and a slightly different one when the incident closes. I was looking at using a webhook however I was having trouble changing the webhook payload on open/close of the incident. Is there a way to achieve my desired outcome?

I tried the following in the payload for the webhook

{
“text”: $EVENT_STATE == “OPEN” ? “incident open” : “incident closed”
}

Any suggestions welcome. Even if I have to create 2 webhooks one for open and one for close.

Thanks


#2

Hi, @matthew.golding: The only solution I know of is to create your own endpoint to receive the POST from New Relic, modify the payload as desired, and forward the data to its final destination.


#3

You can include current_state in the payload which will have OPEN/CLOSED/ACKNOWLEDGED and parse for that.

https://docs.newrelic.com/docs/alerts/new-relic-alerts/managing-notification-channels/customize-your-webhook-payload


#4

Thanks @parrott I dont think that will work as slack has an api with values it requires in the payload.

I think @philweber suggestion is a way that will work out with an intermediatary. Then that intermediatary can inspect the newrelic props and then send another request to slack with the text.


#5

Slack is pretty particular about payloads, for sure :slight_smile: when you’re creating this intermediary, I would suggest including the current_state for ease in determining how to modify the payload. We also have a first class integration for Slack! You get different notification styles based on whether the notification is for incident OPEN/CLOSE/ACKNOWLEDGE

https://docs.newrelic.com/docs/alerts/new-relic-alerts/managing-notification-channels/notification-channels-control-where-send-alerts#slack


#6

Thanks @parrott I started with the first class integration but didn’t like (apologies to your designers) the way it looked. Also we are already receiving alerts from another platform which we send alerts back from and wanted to have a uniformed look.

Looks like we might look at going down a path of using a lambda to receive all the props from the event and do some decisions based on that to customise the message.


#7

Lambda sounds like an ideal solution here - with a function triggered by a webhook hitting it, this could be perfect for your needs.

Let us know how you get on with that @matthew.golding