Integrating Atlassian Opsgenie with Zabbix

Atlassian Opsgenie is so much more than just another integration service for receiving notifications. Opsgenie offers us a call system, an SMS system, iOS and android apps, two-way acknowledgements, and even an on-call schedule.3

I think Opsgenie is the best tool for replacing old-school call and SMS systems and fully integrating them with Zabbix. So, let’s get started with Opsgenie and see how we can get this amazing tool set up.

Getting ready

Ensure that your Zabbix server is ready. I’ll be using the lar-book-centos server, but any Zabbix Server ready to send problems should work.

You are also going to need an Atlassian Opsgenie account with Opsgenie ready to go. I won’t show you how to create accounts, but we’ll start this recipe with Opsgenie ready to go.

How to do it…

Follow these steps to complete this recipe:

  1. Let’s start by logging into our Atlassian Opsgenie setup and going to Settings on the home page. From the left sidebar, click on Notifications.
  2. Make sure that you add you email and phone number here by using the +Add email and +Add phone number buttons. We need these in order to receive notifications:
    Figure 8.59 – Opsgenie profile – Contact methods

    Figure 8.59 – Opsgenie profile – Contact methods

  3. Your settings will be automatically saved once you’ve added them, which means we can navigate away from Settings to Teams using the top bar.
  4. From the Teams tab, click on the blue Add team button in the top-right corner. Then, add the following information:
    Figure 8.60 – Opsgenie – Add team window

    Figure 8.60 – Opsgenie – Add team window

  5. I’ve set up our Consultancy team with two users that are part of this team. Click on the blue Add button at the bottom of the window to add the new team.
  6. This will take you to the new Consultancy team page. Click on Integrations and click on the blue Add integration button in the top-right corner.
  7. When we use the search field to search for the Zabbix integration, we can see it immediately, as shown in the following screenshot:
    Figure 8.61 – Opsgenie – Add integration page

    Figure 8.61 – Opsgenie – Add integration page

  8. Hover over the Zabbix integration and click the blue Add button. This will take you to the next page, where a Name and API Key will be generated:
    Figure 8.62 – Opsgenie – Add Zabbix integration page

    Figure 8.62 – Opsgenie – Add Zabbix integration page

  9. Copy the API Key information and scroll to the bottom of the page. Here, click on the blue Save integration button.
  10. Now, navigate to your Zabbix Server CLI and execute the following code:

    For Red Hat-based systems:

    wget https://og-release-cicd-public-oregon.s3-us-west-2.amazonaws.com/purpose=public/project=oec-scripts/env=prod/branch=master/module=oec-scripts/version=1.1.0/opsgenie-zabbix-1.1.0-rpm-x86-64.rpm

    For Debian-based systems:

    wget https://og-release-cicd-public-oregon.s3-us-west-2.amazonaws.com/purpose=public/project=oec-scripts/env=prod/branch=master/module=oec-scripts/version=1.1.0/opsgenie-zabbix-1.1.0-deb-amd64.deb
  11. We can now install the downloaded Zabbix Opsgenie plugin by issuing the following command(s):

    For Red Hat-based systems:

    rpm -i opsgenie-zabbix-1.1.0-rpm-x86-64.rpm 

    For Debian-based systems:

    dpkg -i opsgenie-zabbix-1.1.0-rpm-x86-64.rpm 
  12. Once you’ve installed the plugin, go to the Zabbix frontend. If you haven’t followed any of the previous recipes, create a new user group for our media types by navigating to Administration | User groups and clicking the Create user group button in the top-right corner. Add the following user group:
    Figure 8.63 – Zabbix – Create user group page, the External Services group for use with Opsgenie

    Figure 8.63 – Zabbix – Create user group page, the External Services group for use with Opsgenie

  13. Click on the Permissions tab and click on Select. Make sure that you select all the groups and subgroups with Read permissions, as follows:
    Figure 8.64 – Zabbix – Create user group permissions page, the External Services group for use with Opsgenie

    Figure 8.64 – Zabbix – Create user group permissions page, the External Services group for use with Opsgenie

  14. Now, click on the blue Add button and finish creating this user group.
  15. Next, navigate to Administration | Actions. On the Trigger actions page, click on the blue Create action button in the top-right corner.
  16. In the Name field, type Opsgenie action and add the following items to Conditions:
    Figure 8.65 – Zabbix – Create new action page, Opsgenie action

    Figure 8.65 – Zabbix – Create new action page, Opsgenie action

  17. Now, click on the Operations tab.
  18. Click the underlined Add text option next to Operations to add your first operation. Set Operation type to Remote command and paste in the contents of the /home/opsgenie/oec/opsgenie-zabbix/actionCommand.txt file, as shown in the following screenshot:
    Figure 8.66 – Zabbix – Create action operations window, Opsgenie action

    Figure 8.66 – Zabbix – Create action operations window, Opsgenie action

  19. Repeat step 17 for Recovery operation and Update operation. It should look like this:
    Figure 8.67 – Zabbix – Create action operations page, Opsgenie action

    Figure 8.67 – Zabbix – Create action operations page, Opsgenie action

  20. Click on the blue Add button at the bottom of the page to finish setting up the action.
  21. Now, you must configure the Opsgenie-to-Zabbix integration. Edit the config file with the following command:
    vim /home/opsgenie/oec/conf/config.json
  22. Make sure that you edit the apiKey, command_url, user, and password lines, as shown in the following screenshot:
    Figure 8.68 – Opsgenie config.json file

    Figure 8.68 – Opsgenie config.json file

    Important note

    You will need to edit baseUrl if you are not located in the United States. I am in Europe, so I changed it to https://api.eu.opsgenie.com.

  23. That’s it! You can now see your alerts coming in and acknowledge them from Opsgenie:
Figure 8.69 – Opsgenie alert from Zabbix

Figure 8.69 – Opsgenie alert from Zabbix

How it works…

When an alert is created in Zabbix, it is sent to Opsgenie via the Zabbix integration. This integration utilizes the Opsgenie API to catch our Zabbix information and send back a reply if required. This way, we have two-way communication between the two applications:

Figure 8.70 – Opsgenie setup diagram

Figure 8.70 – Opsgenie setup diagram

Opsgenie is an amazing tool that can take several tasks away from your Zabbix Server. I’ve used it in the past to migrate away from another monitoring tool to Zabbix. Opsgenie makes it easy to receive alerts from our products and centralize notifications:

Figure 8.71 – Opsgenie setup example, inspired by Wadie

Figure 8.71 – Opsgenie setup example, inspired by Wadie

Another great feature from Atlassian Opsgenie is the integration it offers with other Atlassian products. We can build a setup like the one shown in the preceding diagram to integrate all the products used in our company.

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

7 − 5 =