About this integration:

Integrate Zabbix with Freshservice to triage the alerts sent from your diverse IT components, including networks, servers, virtual machines and cloud services to act upon them in a timely manner and prevent outages.


Configuration in Freshservice:


Step 1:

Head to the Admin panel, scroll down to IT Operations Management, and select Monitoring Tools

If your account has more than one workspace, navigate to Admin > {Worskpace Name} > IT Operations Management> Monitoring Tools.



Step 2:

You are now on the Monitoring Tools list page. Select Add monitoring tool to add a new integration.




Step 3

You will see a list of pre-configured integrations, the gateway to custom integration using webhooks, and the option to use email as a channel for alerts. Select Zabbix.


Step 4

Get the Endpoint URL and the Auth key for Zabbix by following the integration setup.



Configuration in Zabbix:


Step 1: Create a Media Type in Zabbix


In Zabbix to set up an alerting mechanism for important events, create a Media Type.


Media Type:

Medias are the delivery channels used for sending notifications and alerts from Zabbix. For Zabbix to integrate with Freshservice AMS, we should create a webhook integration media type. 

To configure a webhook as the media type

  • Go to Administration → Media types

  • Click on Create media type. The Media type tab contains various attributes specific for this media type:

  • Enter the name of the Media Type.

  • Select the type of media as a webhook.

  • Add the following parameters and replace the url and auth_key param values with the values copied from Freshservice 

    • event_name  - {EVENT.NAME}

    • event_opdata -  {EVENT.OPDATA}

    • event_status - {EVENT.STATUS}

    • hostname - {HOST.NAME}

    • host_ip - {HOST.IP}

    • item_key - {ITEM.KEY}

    • item_name - {ITEM.NAME}

    • message - {ALERT.MESSAGE}

    • severity - {EVENT.SEVERITY}

    • subject - {ALERT.SUBJECT}

    • action_id - {ACTION.ID}

    • action_name - {ACTION.NAME}

    • event_date - {EVENT.DATE}

    • event_time - {EVENT.TIME}

    • tags - {EVENT.TAGS}

    • url - <copy url from Freshservice integrations page>

    • auth_key - <copy auth_key from Freshservice integration page>


  • Copy the following script if you are using Zabbix version 4.4 and 5.4 and paste it into the Script field

try {

    Zabbix.Log(4, 'webhook script value=' + value);

    var result = {

        'tags': {

            'endpoint': 'FS_AMS'

        }

    };



    params = JSON.parse(value);

    var tags_array = [];

    if (params.tags != "" && params.tags != "{EVENT.TAGS}") {

       tags = params.tags.split(",");

       for(i = 0; i < tags.length; i++) {

         tags_array.push(tags[i].trim());

       }

    }

    req = new CurlHttpRequest();

    fields = {

        "message": params.message,

        "subject": params.subject,

        "item_key": params.item_key,

        "host_ip": params.host_ip,

        "event_name": params.event_name,

        "hostname": params.hostname,

        "event_opdata": params.event_opdata,

        "severity": params.severity,

        "item_name": params.item_name,

        "event_status": params.event_status,

        "action_id": params.action_id,

        "action_name": params.action_name,

        "event_date": params.event_date,

        "event_time": params.event_time,

        "event_age": params.event_age,

        "tags": tags_array

    };

    if(params.event_status == "RESOLVED") {

        fields.severity = "ok";

    }

        

    resp = '';



    req.AddHeader('Content-Type: application/json');

    req.AddHeader('Authorization: ' + params.auth_key);





    resp = req.Post(params.url, JSON.stringify(fields));



    if (req.Status() != 202) {

        throw 'Response code: ' + req.Status();

    }

    else {

        results = JSON.stringify({"response_body": resp });

        Zabbix.Log(4, results);

    }

    return results;

}

catch(error) {

    Zabbix.Log(4, 'FS AMS Notification failed: ' + JSON.stringify({ "fields": fields }));

    Zabbix.Log(4, 'FS AMS alert creation failed : ' + error);

    results = JSON.stringify({"error": error});

    return results;

}


  • Copy the following script if you are using Zabbix version 6.4 and above. Paste it into the Script field
try {
   Zabbix.Log(4, 'webhook script value=' + value);
   var result = {
       'tags': {
           'endpoint': 'FS_AMS'
       }
   };
   params = JSON.parse(value);
   var tags_array = [];
   if (params.tags != "" && params.tags != "{EVENT.TAGS}") {
       tags = params.tags.split(",");
       for (i = 0; i < tags.length; i++) {
           tags_array.push(tags[i].trim());
       }
   }
   req = new HttpRequest();
   fields = {
       "message": params.message,
       "subject": params.subject,
       "item_key": params.item_key,
       "host_ip": params.host_ip,
       "event_name": params.event_name,
       "hostname": params.hostname,
       "event_opdata": params.event_opdata,
       "severity": params.severity,
       "item_name": params.item_name,
       "event_status": params.event_status,
       "action_id": params.action_id,
       "action_name": params.action_name,
       "event_date": params.event_date,
       "event_time": params.event_time,
       "event_age": params.event_age,
       "tags": tags_array
   };
   if (params.event_status == "RESOLVED") {
       fields.severity = "ok";
   }
   resp = '';
   req.addHeader('Content-Type: application/json');
   req.addHeader('Authorization: ' + params.auth_key);
   resp = req.post(params.url, JSON.stringify(fields));
   if (req.getStatus() != 202) {
       throw 'Response code: ' + req.Status();
   } else {
       results = JSON.stringify({
           "response_body": resp
       });
       Zabbix.Log(4, results);
   }
   return results;
} catch (error) {
   Zabbix.Log(4, 'FS AMS Notification failed: ' + JSON.stringify({
       "fields": fields
   }));
   Zabbix.Log(4, 'FS AMS alert creation failed : ' + error);
   results = JSON.stringify({
       "error": error
   });
   return results;
}
  • It is not required to check the option to “Include event menu entry
  • Check the enable field and save the settings.

  • On the media type list, click on "Test" against the media type you created for Freshservice. If everything is configured correctly, this will send a test alert to Freshservice which you can view on the alert list page.



A media type must be linked to users by defining specific delivery addresses.To do that, 

  • Go to Administration → Users

  • Click the user to which you want to link  the media type

  • Go to media tab and pick the newly created media type from the type dropdown list

  • Set the ‘Sent to’ option

  • Set the ‘When activate’ option. For eg: To get notified 24/7, set the value as 1-7,00:00-24:00

  • Set the ‘Use if severity’ option

  • Check enable.

Click Add and Update User Media information.



Step 2: Create Action

  1. From the Zabbix homepage, navigate to Configurations -> Actions -> Create Action.
  2. Under Actions, enter properties such as name and add the condition for which you want the action to be triggered.
  3. Click the  Operations tab, select the Operations you want to do.
  4. Click Add under Send to Users, choose Admin and Guest and click Add.
  5. Check the default subject and message under Recovery Operations and Update Operations and click Add to have the action added.
  6. This will send alerts from the configured trigger to Freshservice