Skip to content

alerta/sensu-alerta-handler

Repository files navigation

Sensu Go Alerta Handler

Bonsai Asset Badge build-test

Forward Sensu events to Alerta.

Installation

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

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

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

Configuration

Example Sensu Go handler definition:

alerta-handler.json

{
    "api_version": "core/v2",
    "type": "Handler",
    "metadata": {
        "namespace": "default",
        "name": "alerta"
    },
    "spec": {
        "type": "pipe",
        "command": "sensu-alerta-handler --endpoint-url https://alerta.example.com/api",
        "env_vars": [
            "ALERTA_API_KEY=G25k9JR2yoZIcHROQGS477nk_Riw4CIghFC6j9NE"
        ],

        "timeout": 30,
        "filters": [
            "is_incident"
        ]
    }
}

Create the handler resource:

$ sensuctl create -f alerta-handler.json

Example Sensu Go check definition:

{
    "api_version": "core/v2",
    "type": "CheckConfig",
    "metadata": {
        "namespace": "default",
        "name": "dummy-app-healthz"
    },
    "spec": {
        "command": "check-http -u http://localhost:8080/healthz",
        "subscriptions":[
            "dummy"
        ],
        "publish": true,
        "interval": 10,
        "handlers": [
            "alerta"
        ]
    }
}

Usage Examples

Help:

The Sensu Go Alerta handler for event forwarding

Usage:
  sensu-alerta-handler [flags]

Flags:
  -K, --api-key string        API key for authenticated access
      --endpoint-url string   API endpoint URL (default "http://localhost:8080")
  -E, --environment string    Environment eg. Production, Development (default "Entity Namespace")
  -h, --help                  help for sensu-alerta-handler

Contributing

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