A little background.
One of our longtime customers uses Zendesk as his help desk product. It’s a great product, in fact we actually use it ourselves.
The problem our customer has is that every time Sentinel sends an alert to his Zendesk email address, Zendesk creates a ticket. So .. When he gets told that a service is having problems a ticket gets created .. and then, when we alert him that the service comes right, another ticket gets created.
He has asked us for a while for a way to disabled the ‘Recovered’ and the ‘OK’ alerts because of the duplicate ticket thing, and we thought long and hard about this. We don’t want to cause him any more headaches but at the same time, we want to make sure that we’re building a system that can be really flexible without having to add a bunch of additional UI stuff that many people may not ever use.
So Tim came up with the idea of posting alerts to a custom URL and that would then give you the flexibility to strip out types of alerts that you didn’t want to get. It would also mean that you could then build other process around the alerts from Sentinel. Eg; maybe you want to run a script to restart a process if you get alerted that it’s down.
So with that, stage 1 of our API was born.
Example code for talking to Zendesk
Here is some example php code that you can use to create tickets directly inside of Zendesk based on the alert type.
<?php /* The following example shows how to create a Zendesk ticket for any non OK or RECOVERY alerts from Sentinel Monitoring with a high priority. The elements you will need to adjust in this example are: Zendesk subdomain: The subdomain name you requested when you setup your Zendesk account Zendesk user ID: The ID of the person you wish to create the Zendesk ticket on behalf of Zendesk username: The username you use to log into Zendesk Zendesk password: The password you use to log into Zendesk For further information on Zendesk's ticket XML API visit the following URL: http://www.zendesk.com/api/tickets */ if (!in_array($_POST["state"], array("OK", "RECOVERED"))) { // generate the XML required to create a Zendesk ticket $xml = '<ticket><description>Problem with ' . $_POST["server_service_name"] . ' on ' . $_POST["server_name"] . '</description><requester-id>[Zendesk user ID]</requester-id><priority-id>4</priority-id></ticket>'; // create the cURL object $c = curl_init(); // set the required cURL options curl_setopt($c, CURLOPT_URL, "http://[Zendesk subdomain].zendesk.com/tickets.xml"); curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-Type: text/xml; charset=utf-8")); curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($c, CURLOPT_USERPWD, "[Zendesk username]:[Zendesk password]"); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $xml); // execute the cURL request curl_exec($c); // tidy up curl_close($c); } ?>
Now for this to work, you just have to host it on your server and then tell Sentinel the URL to the code. To do this just open the Sentinel Dashboard, click ‘All People‘, choose a person to edit, and then paste in the URL to the ‘API URL‘ field
That’s all there is to it. ![]()
Tell us how you would use the Sentinel Website & Server Monitoring API and we’ll feature it on our blog here.
{ 1 comment… read it below or add one }
Hi,
Awesome to see that you have created an integration for Zendesk! We always love to see the different uses that people come up with for our product. I wanted to take the time to reach out and see if there is someone that I can talk to about getting your company listed on our page of integration partners at http://www.zendesk.com/integrations. Let me know if there is someone that I can speak to with regards to the process of getting listed on our site as an integration partner. There are only a few steps (most of which you have completed already) and we can have you listed and also mention you in our newsletter as a new integration partner. Looking forward to hearing from you!
Regards,
Eric Shen