OpenNMS - OpsGenie heartbeat monitor

OpsGenie has a {heartbeat API](Heartbeat API) that needs a simple POST request with an authorization token from your monitoring system to tell OpsGenie it is still alive.
If this constant communication gets interrupted, an alarm will be created and inform your on-call team.

An example call using curl to OpsGenies heartbeat API looks like:

curl -X POST 'https://api.opsgenie.com/v2/heartbeats/HEARTBEATNAME/ping'
    --header 'Authorization: GenieKey b14e732b-7010-469b-b4e9-0d78b875e69b' 

The response looks like this:

{
    "result": "PONG - Heartbeat received",
    "took": 0,
    "requestId": "111be080-6632-4897-a6e9-b8dc72f943c7"
}

OpenNMS provides a lot of monitors that are very configurable for specific needs.
In this case, we can use the HttpPostMonitor or PageSequenceMonitor since both are able to inject headers.

Here is an example for the PageSequenceMonitor and the OpsGenie heartbeat API.

<service name="OpsGenie-Heartbeat" interval="300000" user-defined="true" status="on">
    <parameter key="retry" value="3"/>
    <parameter key="timeout" value="5000"/>
    <parameter key="rrd-repository" value="/opt/opennms/share/rrd/response"/>
    <parameter key="ds-name" value="OpsGenie-Heartbeat"/>
    <parameter key="page-sequence">
        <page-sequence>
            <page path="/v2/heartbeats/HEARTBEATNAME/ping"
                    method="POST"
                    scheme="https"
                    port="443"
                    host="api.opsgenie.com"
                    virtual-host="api.opsgenie.com"
                    requireIPv4="false"
                    requireIPv6="false"
                    disable-ssl-verification="false"
                    successMatch=".*PONG.*"
                    response-range="200-399">
            <header name="Authorization" value="GenieKey b14e732b-7010-469b-b4e9-0d78b875e69b"/>
            </page>
        </page-sequence>
    </parameter>
</service>
<monitor service="OpsGenie-Heartbeat" class-name="org.opennms.netmgt.poller.monitors.PageSequenceMonitor"/>

:woman_facepalming: You can fix me, Iā€™m a wiki post.

1 Like