Select Supported Platforms

Select Supported Architectures

Select Tier

Github Name


README
Asset Definition
Release Notes
Release Assets

Sensu Go OpsGenie Handler

Sensu Bonsai Asset
Go Test
goreleaser
Go Report Card

Sensu Go OpsGenie Handler

Table of Contents

Overview

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.

Files

N/A

Usage Examples

Help:

The Sensu Go OpsGenie handler for incident management

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

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

Flags:
  -a, --auth string                  The OpsGenie V2 API authentication token, use default from OPSGENIE_AUTHTOKEN env var
  -h, --help                         help for sensu-opsgenie-handler
  -i, --includeEventInNote           Include the event JSON in the payload sent to OpsGenie
  -m, --messageTemplate string       The template for the message to be sent (default "{{.Entity.Name}}/{{.Check.Name}}")
  -l, --messageLimit int             The maximum length of the message field (default 100)
  -d, --descriptionTemplate string   The template for the description to be sent (default "{{.Check.Output}}")
  -L, --descriptionLimit int         The maximum length of the description field (default 100)
  -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 V2 API Team, use default from OPSGENIE_TEAM env var
  -u, --url string                   The OpsGenie V2 API URL, use default from OPSGENIE_APIURL env var (default "https://api.opsgenie.com")

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

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

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 use Opsgenie Priority

Please add this annotations inside sensu-agent:

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

Or inside check:

{
  "type": "CheckConfig",
  "api_version": "core/v2",
  "metadata": {
    "name": "interval_check",
    "namespace": "default",
    "annotations": {
        "opsgenie_priority": "P2",
        "documentation": "https://docs.sensu.io/sensu-go/latest"
    }
  },
  "spec": {
    "command": "check-cpu.sh -w 75 -c 90",
    "subscriptions": ["system"],
    "handlers": ["opsgenie"],
    "interval": 60,
    "publish": true
  }
}

Configuration

Sensu Go

Asset registration

Sensu Assets are the best way to make use of this plugin. If you're not using an asset, please
consider doing so! If you're using sensuctl 5.13 with Sensu Backend 5.13 or later, you can use the
following command to add the asset:

sensuctl asset add nixwiz/sensu-opsgenie-handler

If you're using an earlier version of sensuctl, you can find the asset on the Bonsai Asset Index.

Handler definition

{
    "api_version": "core/v2",
    "type": "Handler",
    "metadata": {
        "namespace": "default",
        "name": "opsgenie"
    },
    "spec": {
        "type": "pipe",
        "command": "sensu-opsgenie-handler",
        "env_vars": [
          "OPSGENIE_AUTHTOKEN=SECRET",
          "OPSGENIE_TEAM=TEAM_NAME",
          "OPSGENIE_APIURL=https://api.eu.opsgenie.com"
        ],
        "timeout": 10,
        "filters": [
            "is_incident"
        ]
    }
}

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 sensu.io/plugins/sensu-opsgenie-handler/config.

Examples

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

type: CheckConfig
api_version: core/v2
metadata:
  annotations:
    sensu.io/plugins/sensu-opsgenie-handler/config/team: WebOps
[...]

Proxy Support

This handler supports the use of the environment variables HTTP_PROXY,
HTTPS_PROXY, and NO_PROXY (or the lowercase versions thereof). HTTPS_PROXY takes
precedence over HTTP_PROXY for https requests. The environment values may be
either a complete URL or a "host[:port]", in which case the "http" scheme is assumed.

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.

Another option is to manually register the asset by providing a URL to the tar.gz file, and sha512 hash for that file:

sensuctl asset create sensu-opsgenie-handler --url "https://assets.bonsai.sensu.io/fba8c41f2b5bc817f8fb201144627042a3e31ee3/sensu-opsgenie-handler_0.0.4_linux_amd64.tar.gz" --sha512 "5eda4b31371fae83860604dedbf8527d0d6919bfae8e4f5b33f71bd314f6d706ef80356b14f11d7d2f86923df722338a3d11b84fa1e35323959120b46b738487"

Sensu Core

See this plugin

Installation from source

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

Contributing

See https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md

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

Download

×

Either download the source code:

Download Source

Or download the asset definition: