Git Product home page Git Product logo

sensu-pagerduty-handler's Introduction

Sensu Go PagerDuty Handler

TravisCI: TravisCI Build Status

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

Installation

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

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

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

Configuration

Example Sensu Go handler definition:

{
    "api_version": "core/v2",
    "type": "Handler",
    "metadata": {
        "namespace": "default",
        "name": "pagerduty"
    },
    "spec": {
        "type": "pipe",
        "command": "sensu-pagerduty-handler",
        "env_vars": [
          "PAGERDUTY_TOKEN=SECRET",
          "PAGERDUTY_DEDUP_KEY=SENSU_EVENT_LABEL",
          "PAGERDUTY_DEDUP_KEY_TEMPLATE={{.Entity.Name}}-{{.Check.Name}}",
          "PAGERDUTY_STATUS_MAP={\"info\":[130,10],\"error\":[4]}"
          "PAGERDUTY_SUMMARY_FORMAT={ENTITY}/{CHECK} : {OUTPUT}"
        ],
        "timeout": 10,
        "filters": [
            "is_incident"
        ]
    }
}

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": [
            "pagerduty"
        ]
    }
}

Usage Examples

Help:

Usage:
  sensu-pagerduty-handler [flags]

Flags:
  -d, --dedup-key string            The Sensu event label specifying the PagerDuty V2 API deduplication key, use default from PAGERDUTY_DEDUP_KEY env var
  -k, --dedup-key-template string   The PagerDuty V2 API deduplication key template, use default from PAGERDUTY_DEDUP_KEY_TEMPLATE env var
  -h, --help                        help for sensu-pagerduty-handler
  -s, --status-map string           The status map used to translate a Sensu check status to a PagerDuty severity, use default from PAGERDUTY_STATUS_MAP env var
  -t, --token string                The PagerDuty V2 API authentication token, use default from PAGERDUTY_TOKEN env var
  -f, --summary-format string       The format to use when crafting pagerduty incident summary , use default from PAGERDUTY_SUMMARY_FORMAT

Note: Make sure to set the PAGERDUTY_TOKEN 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 --token argument is provided as an override primarily for testing purposes.

Deduplication Key Priority

The deduplication key is determined using the following priority:

  1. --dedup-key -- specifies the entity label containing the key
  2. --dedup-key-template -- a template containing the values
  3. the default value containing the entity and check names

PagerDuty Severity Mapping

Optionally you can provide mapping information between the Sensu check status and the PagerDuty incident severity. To provide the mapping you need to use the --status-map command line option or the PAGERDUTY_STATUS_MAP environment variable. The option accepts a JSON document containing the mapping information. Here's an example of the JSON document:

{
    "info": [
        0,
        1
    ],
    "warning": [
        2
    ],
    "critical:": [
        3
    ],
    "error": [
        4,
        5,
        6,
        7,
        8,
        9,
        10
    ]
}

The valid PagerDuty alert severity levels are the following:

  • info
  • warning
  • critical
  • error

Summary Formatting

When using a custom formatting for the summary the following tokens can be used:

  • {ENTITY} == Entity Name
  • {CHECK} == Check Name
  • {OUTPUT} == Check Output
  • {STATUS} == Numerical Check status (0, 1, 2, ...)
  • {STATUS_NAME} == String name of Check status (OK, WARNING, CRITICAL, UNKNOWN)

Contributing

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

sensu-pagerduty-handler's People

Contributors

ccressent avatar echlebek avatar fguimond avatar pablolibo avatar portertech avatar proofpoint-mlariz avatar skorn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.