AlertOps and Jenkins
AlertOps’ alert management system can be integrated with Jenkins to receive and respond to all (predefined status mappings) job/build alerts through email, SMS, push notification or phone alerts. AlertOps would ensure that the alert/job status would reach the appropriate team by using proper workflows, escalation policies and schedules. Based on your ruleset, incidents can be automatically opened and closed, depending on whether Jenkins sends a job/build success or failure (any status update throughout the entire flow for that matter).
The above scenario and scope for integration is due to the fact that AlertOps has a very flexible and simple API/Webhook configuration feature that can be leveraged with Jenkins’ notification plugin.
AlertOps - Inbound Integrations
We can now define some rulesets in AlertOps so that Jenkins can send out event notifications to the AlertOps platform. AlertOps would ensure based on these notifications received, that it would always reach out and assign to the correct person/team by utilizing its escalation policies, schedules, and workflow features.
AlertOps provides Inbound Integrations to integrate with numerous monitoring, chat and ITSM tools. You can configure an inbound integration for Jenkins incidents.
At a high level this is how the flow looks like, you define an API integration in the AlertOps platform by defining settings like Integration Name, Escalation rules, recipient users/groups. Once an integration is defined, a unique API URL is generated. This acts as webhook or the gateway through which notifications from Jenkins reach AlertOps and thus an incident/alert is created correspondingly. The API can be defined with various settings like URL mappings, filters, escalations etc. as required.
To configure an Inbound Integration in AlertOps to receive alerts from Jenkins,
Under 'Integrations' select 'Inbound Integrations', select the category 'API' and then select add 'Add API Integration'
There are numerous integration options available in AlertOps, select Jenkins
Once you select the integration, you can then specify basic settings like the integration name, escalation policy, names of the recipients/groups for which the alerts must be assigned to.
Once you click save, the API Integration will be created, and you will be given a unique URL which acts as the access point and needs to be configured at the source (in this case Jenkins), to send alerts. You can find the integration you just created, and you can give advanced settings and define various configurations for the alerts to be received and processed. For example, you can define when to open and close alerts based on the payload obtained from the API call, filters etc
Make a note of the API URL, which will be used in Jenkins, so it calls a HTTP POST request to this URL with the body in JSON format containing the alert specific information. AlertOps automatically creates an alert when the status variable (build^status) does not contain ‘SUCCESS’. We give this definition because, ideally, we would want any event from Jenkins to be alerted to a team to take specific action until it is fully succeeded. The events that come in, come with phase variables finalized, completed, started, queued. The incident will also be closed automatically when the status ‘SUCCESS’ is received.
You can similarly define URL mappings as you want, owing to the flexibility provided by AlertOps’ OpenAPI integrations. You can provide other filters and match with regex expressions as well. You can also test the generated URL.
Configuration of Jenkins for AlertOps Integration
Jenkins comes with loads of plugins as part of its ecosystem to integrate with various systems. We will use the Notifications plugin, to send event notifications to AlertOps.
To add a Notification Plugin to your Jenkins environment,
In the left navigation pane, select ‘Manage Jenkins’ > Under ‘System Configuration’, select ‘Manage Plugins’
Under the Available tab, search for Notification plugin. Select and install it. Once you install it, it should be available in the Installed tab.
To configure your project to send out notification events to AlertOps,
In the dashboard, select your project, and select Configure in the left navigation pane.
There should be a tab called ‘Job Notifications’. Under that tab, do the configuration as per the screenshot below. Make sure that you paste the API URL obtained in the previous section here. The other options can be configured however you want. Click Save/Apply.
That’s it! You have added the Notification plugin and configured it for your project, that would send out notifications to AlertOps when the alert condition is triggered (in this case any event).
Alerts in AlertOps can be seen in the ‘Inbound Log’ or the ‘Alerts’ section.
Alert Triggering Information:
AlertOps will automatically create an incident when a new alert is received from Jenkins when the build^status field contains any other value other than ‘SUCCESS’. (Note: We give this definition because, ideally, we would want any event from Jenkins to be alerted to a team, to take specific action until it is fully succeeded. The events that come in, come with phase variable values finalized, completed, started, queued)
If an alert matches an existing Open Alert (based on the source ID), AlertOps will recognize the new alert as part of the existing alert and ignore the alert (you can configure this). The alert will be recorded in the Inbound Messages table as “Mapped Appended.”
AlertOps will automatically close the same incident when an alert with build^status contains “SUCCESS”