A module for sending heartbeats to OpsGenie
A Node.js module for sending heartbeats to OpsGenie.
When operating a Node.js app, you need to be notified of downtime. Services like Pingdom allow you to monitor the availability of your app by pinging it periodically and alerting you if it cannot be reached. But this requires your app to be available online.
If your app is running behind a firewall (intranet) or it's a background job not inteded to be publically available, Pingdom and similar services have no way of pinging it. The solution of cause is to reverse the roles and let your app ping the monitoring service. OpsGenie provide such an API.
npm install opsgenie
You can either configure OpsGenie using environment variables, or configure it using the
OpsGenie environment variables:
OPSGENIE_API_KEY- Your personal OpsGenie API key
OPSGENIE_NAME- The hostname that the OpsGenie heartbeat agent should register as (optional)
If no name is provided, either by
OPSGENIE_NAME or by setting it via the
.heartbeat() function, the hostname of the server will be used.
Example 1 - Using OpsGenie with environment variables:
Example 2 - Configure OpsGenie using the
require'opsgenie'heartbeatapiKey: 'eb243592-faa2-4ba2-a551q-1afdf565c889'name: 'host-name';
The OpsGenie module can emit the following events:
- error - If something goes wrong while communicating with OpsGenie, an error event is emitted (note: if no listener is added, OpsGenie will not emit this event)
- heartbeat - For every heartbeat sent to OpsGenie, the response JSON object is emitted
var opsgenie = require'opsgenie';opsgenieon'error'console.log'Something went wrong while communicating with OpsGenie: ' + errmessage;;opsgenieon'heartbeat'console.log'OpsGenie heartbeat result:' res;;