We are aware of a potentially service impacting issue. Learn more

Knowledgebase

Sample Web Hook Print

  • 0

As part of our API alerts feature, you can add custom web hooks which will be called in the event of an alert or recovery. This allows you to setup a script on an alternate web server from the one you are checking that will parse a json post containing the details of the alert. A WebHook API alert will send a request to a URL on your server containing one post variable called webhook_data. The webhook_data field contains a json string with the following data:

results: will be true if this is a recovery alert and will be false if this is a down alert.
key: The key you enter below used to authenticate the hook request.
alert_date_time: The time the alert was sent.
downtime: The total downtime of this alert.
check_name: The name of the check.
hostname: The hostname/url of the check.
check_type: The type of check being performed.
check_notes: User entered check notes.
failure_message: User entered custom failure message, this is only sent on a failure.
recover_message: User entered custom recovery message, this is only sent on recovery.
first_down_time: When the first down alert was sent.
location: The location of the check failure, this is only sent on failure not on recovery. 
error_message: The error message from the check, this is only sent on failure. 
dns_hostname: The dns hostname being checked, only sent for the alert type of DNS.
dns_record_type: The record type of the DNS check, only sent for the alert type of DNS.
dns_server: The dns server being used to perform the check, only sent for the alert type of DNS.

 

The following is a simple web hook that checks the key that was passed and prints the downtime. This wouldn't actually do anything, this is just an example to get you started.

 

 

 

<?php

$results = json_decode($_POST['webhook_data']);

if ($results->key == "mysecretkey") {

echo $results->downtime;

}

?>

 

Was this answer helpful?

« Back

Powered by WHMCompleteSolution