Alerts & Webhooks
Alert Webhooks
4min
an alert can be configured to be sent via webhook call in this case, an http post request will be made to the specified endpoint, containing a json payload, whenever the threshold condition is met if the response has a 200 status code, it is considered successful, otherwise, the alert system will keep trying to send the alert context variables the following context variables can be used to set a webhook request header and payload sample webhook for slack create the alert using the alerts ui https //ui amberflo io/alerts/create or using the create a notification docid\ f6y3dmmq5u0ffdwbcxkjq curl location request post 'https //app amberflo io/notification' \\ \ header 'content type application/json' \\ \ header 'x api key xyz' \\ \ data raw '{ "name" "usage alert", "meterid" "4d1ca680 4974 11ec ad9b e1ce3f8b2ad3", "cron" "0 0 0", "webhookurl" "https //hooks slack com/services/t01hzb7a0m6/b01n83nqv6h/lma2syqdunv3a7clbbd9234", "webhookpayload" "{\\"text\\" \\"amberflo notification {{notification name}} \\",\\"blocks\\" \[{\\"type\\" \\"section\\",\\"text\\" {\\"type\\" \\"mrkdwn\\",\\"text\\" \\"amberflo notification {{notification name}}\\"}},{\\"type\\" \\"section\\",\\"block id\\" \\"section567\\",\\"text\\" {\\"type\\" \\"mrkdwn\\",\\"text\\" \\"your meter value has exceeded the allowed threshold limit \\"}},{\\"type\\" \\"section\\",\\"block id\\" \\"section789\\",\\"fields\\" \[{\\"type\\" \\"mrkdwn\\",\\"text\\" \\" customer \\\n {{customer name}}\\"},{\\"type\\" \\"mrkdwn\\",\\"text\\" \\" meter \\\n {{meter name}}\\"},{\\"type\\" \\"mrkdwn\\",\\"text\\" \\" threshold condition \\\n {{threshold condition}}\\"},{\\"type\\" \\"mrkdwn\\",\\"text\\" \\" threshold limit \\\n {{threshold value}}\\"},{\\"type\\" \\"mrkdwn\\",\\"text\\" \\" current value \\\n {{current value}}\\"}]},{\\"type\\" \\"section\\",\\"block id\\" \\"section790\\",\\"text\\" {\\"type\\" \\"mrkdwn\\",\\"text\\" \\"<{{ui hyperlink}}|click here to view usage details>\\"}}]}", "thresholdcondition" "greater than", "thresholdvalue" "1000", "range" "day", "customerfiltermode" "per customer", "enabled" true }' sample webhook payload for slack webhook payload { "text" "amberflo notification {{notification name}} ", "blocks" \[ { "type" "section", "text" { "type" "mrkdwn", "text" "amberflo notification {{notification name}}" } }, { "type" "section", "block id" "section567", "text" { "type" "mrkdwn", "text" "your meter value has exceeded the allowed threshold limit " } }, { "type" "section", "block id" "section789", "fields" \[ { "type" "mrkdwn", "text" " customer \n {{customer name}}" }, { "type" "mrkdwn", "text" " meter \n {{meter name}}" }, { "type" "mrkdwn", "text" " threshold condition \n {{threshold condition}}" }, { "type" "mrkdwn", "text" " threshold limit \n {{threshold value}}" }, { "type" "mrkdwn", "text" " current value \n {{current value}}" } ] }, { "type" "section", "block id" "section790", "text" { "type" "mrkdwn", "text" "<{{ui hyperlink}}|click here to view usage details>" } } ] } alerts will send the following http request to the webhook endpoint curl location request post 'https //hooks slack com/services/t01hzb7a0m6/b01p3j0le0h/obrott8tmrj2zbv3bqaqhxtf' \\ \ header 'content type application/json' \\ \ data raw '{ "text" "amberflo notification alert for prepaid ", "blocks" \[ { "type" "section", "text" { "type" "mrkdwn", "text" "amberflo notification alert for prepaid" } }, { "type" "section", "block id" "section567", "text" { "type" "mrkdwn", "text" "your meter value has exceeded the allowed threshold limit " } }, { "type" "section", "block id" "section789", "fields" \[ { "type" "mrkdwn", "text" " customer \n oceanic airlines" }, { "type" "mrkdwn", "text" " threshold condition \n less than" }, { "type" "mrkdwn", "text" " threshold limit \n 1000000000" }, { "type" "mrkdwn", "text" " current value \n 40384" } ] }, { "type" "section", "block id" "section790", "text" { "type" "mrkdwn", "text" "\<https //ui amberflo io/customers/54a43bba 915d 4512 a0bd 9d9debesase|click here to view usage details>" } } ] }' and the rendered slack message will look like this