alertmanager-to-github

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

alertmanager-to-github

This receives webhook requests from Alertmanager and creates GitHub issues.

It does:

  • open an issue on a new alert
  • close the issue when the alert is in resolved status
  • reopen the issue when the alert is in firing status
    • alerts are identified by groupKey; configurable via --alert-id-template option

screen shot

Installation

go get
go get github.com/pfnet-research/alertmanager-to-github

Usage

Start webhook server:

$ read ATG_GITHUB_TOKEN
(Personal Access Token)
$ export ATG_GITHUB_TOKEN

$ alertmanager-to-github start

Add a receiver to Alertmanager config:

route:
  receiver: 'togithub' # default

receivers:
- name: "togithub"
  webhook_configs:
  # Create issues in "bar" repo in "foo" organization.
  # repo and owner parameters must be URL-encoded.
  - url: 'http://localhost:8080/v1/webhook?owner=foo&repo=bar'

Configuration

$ alertmanager-to-github start -h
NAME:
   alertmanager-to-github start - Start webhook HTTP server

USAGE:
   alertmanager-to-github start [command options] [arguments...]

OPTIONS:
   --listen value               HTTP listen on (default: ":8080") [$ATG_LISTEN]
   --github-url value           GitHub Enterprise URL (e.g. https://github.example.com) [$ATG_GITHUB_URL]
   --labels value               Issue labels [$ATG_LABELS]
   --body-template-file value   Body template file [$ATG_BODY_TEMPLATE_FILE]
   --title-template-file value  Title template file [$ATG_TITLE_TEMPLATE_FILE]
   --alert-id-template value    Alert ID template (default: "{{.Payload.GroupKey}}") [$ATG_ALERT_ID_TEMPLATE]
   --github-token value         GitHub API token (command line argument is not recommended) [$ATG_GITHUB_TOKEN]
   --help, -h                   show help (default: false)
GitHub Enterprise

To create issues in GHE, set --github-url option or ATG_GITHUB_URL environment variable.

Customize issue title and body

Issue title and body are rendered from Go template and you can use custom templates via --body-template-file and --title-template-file options. In the templates, you can use the following variables and functions.

  • Variables
    • .Payload: Webhook payload incoming to this receiver. For more information, see WebhookPayload in pkg/types/payload.go
  • Functions
    • urlQueryEscape: Escape a string as a URL query
    • json: Marshal an object to JSON string
    • timeNow: Get current time

Deployment

Kubernetes

https://github.com/pfnet-research/alertmanager-to-github/tree/master/example/kubernetes

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL