Select Supported Platforms

Select Supported Architectures

Select Tier

Github Name

Asset Definition
Release Notes
Release Assets

Sensu Go OpsGenie Handler

Go Test
Sensu Bonsai Asset

The Sensu Go OpsGenie Handler is a Sensu Event Handler which manages
OpsGenie incidents, for alerting operators. With this handler,
Sensu can trigger OpsGenie incidents.

This handler was inspired by pagerduty plugin.

After version 1.0.0 we changed opsgenie sdk to sdk-v2.


Download the latest version of the sensu-opsgenie-handler from releases,
or create an executable script from this source.

From the local path of the sensu-opsgenie-handler repository:

go build -o /usr/local/bin/sensu-opsgenie-handler main.go


Example Sensu Go handler definition:

type: Handler
api_version: core/v2
  name: opsgenie
  namespace: default
  type: pipe
  command: sensu-opsgenie-handler
  timeout: 10
  - betorvs/sensu-opsgenie-handler
  - is_incident
    secret: opgsgenie_authtoken

Security Note: Care should be taken to not expose the auth token for this handler by specifying it
on the command line or by directly setting the environment variable in the handler definition. It is
suggested to make use of secrets management to surface it as an environment variable. The
handler definition above references it as a secret. Below is an example secrets definition that make
use of the built-in env secrets provider.

type: Secret
api_version: secrets/v1
  name: opsgenie_authtoken
  provider: env

Example Sensu Go check definition:

type: CheckConfig
api_version: core/v2
  name: dummy-app-healthz
  namespace: default
  annotations: P2
  command: check-http -u http://localhost:8080/healthz
  - dummy
  - opsgenie
  interval: 60
  publish: true

Usage Examples


The Sensu Go OpsGenie handler for incident management

  sensu-opsgenie-handler [flags]
  sensu-opsgenie-handler [command]

Available Commands:
  help        Help about any command
  version     Print the version number of this plugin

      --addHooksToDetails            Include the checks.hooks in details to send to OpsGenie
  -a, --auth string                  The OpsGenie API authentication token, use default from OPSGENIE_AUTHTOKEN env var
  -L, --descriptionLimit int         The maximum length of the description field (default 15000)
  -d, --descriptionTemplate string   The template for the description to be sent (default "{{.Check.Output}}")
      --escalation-team string       The OpsGenie Escalation Responders Team, use default from OPSGENIE_ESCALATION_TEAM env var
  -F, --fullDetails                  Include the more details to send to OpsGenie like proxy_entity_name, occurrences and agent details arch and os
  -h, --help                         help for sensu-opsgenie-handler
  -i, --includeEventInNote           Include the event JSON in the payload sent to OpsGenie
  -l, --messageLimit int             The maximum length of the message field (default 130)
  -m, --messageTemplate string       The template for the message to be sent (default "{{.Entity.Name}}/{{.Check.Name}}")
  -p, --priority string              The OpsGenie Alert Priority, use default from OPSGENIE_PRIORITY env var (default "P3")
  -r, --region string                The OpsGenie API Region (us or eu), use default from OPSGENIE_REGION env var (default "us")
      --schedule-team string         The OpsGenie Schedule Responders Team, use default from OPSGENIE_SCHEDULE_TEAM env var
  -s, --sensuDashboard string        The OpsGenie Handler will use it to create a source Sensu Dashboard URL. Use OPSGENIE_SENSU_DASHBOARD. Example: http://sensu-dashboard.example.local/c/~/n (default "disabled")
  -t, --team string                  The OpsGenie Team, use default from OPSGENIE_TEAM env var
  -T, --titlePrettify                Remove all -, /, \ and apply strings.Title in message title
  -w, --withAnnotations              Include the event.metadata.Annotations in details to send to OpsGenie
  -W, --withLabels                   Include the event.metadata.Labels in details to send to OpsGenie

Use "sensu-opsgenie-handler [command] --help" for more information about a command.

Note: Make sure to set the OPSGENIE_AUTHTOKEN environment variable for sensitive credentials in production to prevent leaking into system process table. Please remember command arguments can be viewed by unprivileged users using commands such as ps or top. The --auth argument is provided as an override primarily for testing purposes.

To configure OpsGenie Sensu Integration follow these first part in OpsGenie Docs.

To use Opsgenie Priority from Entity or Check

Please add this annotations inside sensu-agent:

# /etc/sensu/agent.yml example
annotations: "P1"

Or inside check:

type: CheckConfig
api_version: core/v2
  name: interval_check
  namespace: default
  annotations: P2
  command: -w 75 -c 90
  - system
  - opsgenie
  interval: 60
  publish: true

Argument Annotations

All arguments for this handler are tunable on a per entity or check basis based on annotations. The
annotations keyspace for this handler is It allows you to replace all flags, if it is a string type, like: auth, priority, team, region.


To change the team argument for a particular check, for that checks's metadata add the following:

type: CheckConfig
api_version: core/v2
  annotations: DevOps

Asset creation

The easiest way to get this handler added to your Sensu environment, is to add it as an asset from Bonsai:

sensuctl asset add betorvs/sensu-opsgenie-handler --rename sensu-opsgenie-handler

See sensuctl asset --help for details on how to specify version.



Are you sure you want to report this asset?

Please describe the reason for reporting this asset. Our moderators will be notified and will disable the asset if it is found to be inappropriate.


You must be signed in to report this asset.

Sign In with Github



Either download the source code:

Download Source

Or download the asset definition: