Skip to main content
Version: 23.10

Opsgenie Events

The Opsgenie Events stream connector allows you to send data from Centreon to Opsgenie using their HTTP REST API.

Before starting

  • In most cases, you will want to send data from the central server. It is also possible to send it from a remote server or a poller (e.g. if you want to avoid the central server being a SPOF, or if you are an MSP and you install the stream connector on a poller or a remote server within your customer's infrastructure).
  • By default, the Opsgenie Events stream connector sends events from host_status and service_status. Broker events. The event format is shown here.
  • These events are sent each time a host or a service is checked. Various parameters let you filter out events.

Compatibility

Warning: this documentation was written in February 2021. It is possible that some elements described below have become obsolete due to changes to Opsgenie. You can let us know by using the documentation feedback tools at the bottom right of this page.

Installation

Perform the installation on the server that will send data to Opsgenie (central server, remote server, poller).

  1. Login as root on the Centreon central server using your favorite SSH client.

  2. Run the following command:

dnf install centreon-stream-connector-opsgenie

Configuring Opsgenie

You will need to configure your Opsgenie instance to receive data from Centreon. Opsgenie integration requires two different API keys. The first one is an integration API key coming from the Rest API HTTPS over JSON integration. This integration must have the Create and Update Access right. The second key is an API key coming from the APP Settings. This key must have the Create and Update access right.

Opsgenie integration: alerts

  1. In the Settings menu, select Integration list.
  2. In the integration list, add an API integration (Rest API HTTPS over JSON).
  3. Go to Configured integrations and edit your API integration to enable it (if it is not enabled already). You also must give it a Create and Update Access right. Save your configuration and the API Key that is mandatory to send alerts from Centreon to Opsgenie. This API key is referred to as integration_api_token in the Centreon configuration.

Opsgenie integration: incidents

  1. Before starting, be aware that this integration will only work if you are using the Centreon BAM module.
  2. In the Settings menu, select API key management in the APP SETTINGS subcategory.
  3. In the API key management menu, add a new API key with Create and Update access.
  4. Save your configuration and your Api key that is mandatory to send incidents from Centreon to Opsgenie. This API key is referred to as app_api_token in the Centreon configuration.

Configuring the stream connector in Centreon

  1. On your central server, go to Configuration > Pollers > Broker configuration.
  2. Click on central-broker-master (or the appropriate broker configuration if it is a poller or a remote server that will send events).
  3. On the Output tab, select Generic - Stream connector from the list and then click Add. A new output appears in the list.
  4. Fill in the fields as follows:
FieldValue
NameOpsgenie events
Path/usr/share/centreon-broker/lua/opsgenie-events-apiv2.lua
Filter categoryNeb
  1. To enable Centreon to connect to your Opsgenie device, fill in the following mandatory parameters. The fields for the first entry are already present. Click on the +Add a new entry link located below the Filter category table to add another one.
TypeNameDescriptionExample of value
stringapp_api_tokenAPI Authentication key for alertsan_authkey
stringintegration_api_tokenAPI Authentication key for incidents (require Centreon BAM module)an_authkey
  1. Fill in any optional parameters you want (using the +Add a new entry link):
TypeNameDescriptionDefault value
stringlogfileFile in which logs are written/var/log/centreon-broker/opsgenie-events-apiv2.log
numberlog_levelLogging level from 1 (errors) to 3 (debug)1
  1. Use the stream connector's optional parameters to filter or adapt the data you want Centreon to send to Opsgenie.

  2. Deploy the configuration.

  3. Restart centengine on all pollers:

    systemctl restart centengine

    Opsgenie should now receive data from Centreon.

Filtering or adapting the data you want to send to Opsgenie

All stream connectors have a set of optional parameters , that allow you to filter the data you will send to your Opsgenie device, to reformat the data, to define a proxy...

Each optional parameter has a default value, that is indicated in the corresponding documentation.

  • To override the default value of a parameter, click on the +Add a new entry link located below the Filter category table to add a custom parameter. For example, if you want to only send to Opsgenie the events linked to a hostgroup called "Europe", enter:

    type = string
    name = accepted_hostgroup
    value = Europe
  • For the Opsgenie Events stream connector, the following values always override the default values, you do not need to define them in the interface except if you want to change their values (for example to remove the downtimes in the accepted_elements variable).

TypeNameValue explanationDefault value for the stream connectorPossible values
stringaccepted_categoriesEach event is linked to a broker category, which can be used to filter eventsnebneb ou bam
stringaccepted_elementsCentreon item managed by this connector (to add more, you need to look at the custom event format section, see below), the list of items must be separated by commas without spaceshost_status,service_statushost_status or service_status or ba_status
stringapi_urlOpsgenie API address, use https://api.eu.opsgenie.com if your instance is in Europehttps://api.opsgenie.com-
stringalerts_api_endpointOpsgenie API address for alerts/v2/alerts-
stringincident_api_endpointOpsgenie API address for incidents/v1/incidents/create-
stringba_incident_tagsList of tags for an incident. Must use a comma as a separator. BV names will be automatically added to the tagscentreon,application-
numberenable_incident_tagsAdds tags for incidents if set to 111 ou 0
numberget_bvAdds BV name to tags if enable_incident_tags is set to 111 ou 0
stringenable_severityIf set to 1, tries to link a Centreon severity to an Opsgenie priority01 ou 0
stringdefault_priorityDefault priority used for Opsgenie tickets
stringpriority_mappingAllows to match Opsgenie priorities with a priority order in the stream connectorP1=1,P2=2,P3=3,P4=4,P5=5-
stringopsgenie_prioritiesList of Opsgenie priorities with comma separatorP1,P2,P3,P4,P5-
stringtimestamp_conversion_formatIndicates timestamp display format%Y-%m-%d %H:%M:%S-

Event bulking

This stream connector is compatible with event bulking. Meaning that it is able to send more that one event in each call to the Opsgenie REST API.

To use this feature you must add the following parameter in the configuration of your stream connector.

TypeNameValue
numbermax_buffer_size1 ou plus

Event format

This stream connector will send events with the following format.

Output example for service_status events

{
"alias": "Host-Name_Service-Name_WARNING",
"description": "Output returned from plugin",
"message": "2024-10-21 11:29:41 Host-Name // Service-Name is WARNING"
}

Output example for host_status events

{
"alias": "Host-Name_DOWN",
"description": "Output returned from host check",
"message": "2024-10-21 11:32:42 Host-Name is DOWN"
}

Custom event format

This stream connector allows you to change the format of the event to suit your needs. It allows you to handle event types that are not handled by default such as downtimes events.

In order to use this feature you need to configure a json event format file and add a new stream connector parameter.

TypeNameValue
stringformat_file/etc/centreon-broker/opsgenie-events-format.json

The event format configuration file must be readable by the centreon-broker user.

To learn more about custom event formats and templating files, read this documentation.

Curl commands: testing the stream connector

Sending events

If you want to test that events are sent to Opsgenie correctly:

  1. Log in to the server that you configured to send events to Opsgenie (your central server, a remote server or a poller).
  2. Run the following command:
curl -X POST -H 'content-type: application/json' -H 'Authorization: GenieKey <app_api_token>' 'https://api.opsgenie.com/v2/alerts' -d '{"description":"Output returned from plugin","message":"2024-10-21 11:46:37 Host-Name // Service-Name is WARNING","alias":"Host-Name_Service-Name_WARNING"}'

Replace all the ** <xxxx>** inside the above command with the appropriate value.

  1. Check that the data has been received by Opsgenie.