|
| 1 | +`pagerduty`: The Cog PagerDuty Command Bundle |
| 2 | +========================================= |
| 3 | + |
| 4 | +# TL;DR |
| 5 | + |
| 6 | + !pagerduty:alert Customers complaining the site is down. Need help in #support |
| 7 | + !pagerduty:oncall |
| 8 | + !pagerduty:incidents |
| 9 | + !pagerduty:ack PHNRH53 |
| 10 | + !pagerduty:resolve PHNRH53 |
| 11 | + |
| 12 | +# Overview |
| 13 | + |
| 14 | +The `pagerduty` bundle adds five new commands: ack, resolve, alert, incidents |
| 15 | +and oncall. |
| 16 | + |
| 17 | +* ack - Acknowledge triggered incidents |
| 18 | + `ack [-a | --as <pagerduty user email>] <incident id>` |
| 19 | + `ack` requires a pagerduty user's email address to acknowledge an |
| 20 | + incident. If `--as` is not passed ack will first look for an env |
| 21 | + var called `PAGERDUTY_EMAIL_FOR_<COG USER>` where `COG USER` is |
| 22 | + the Cog username for the user making the request. If that var |
| 23 | + isn't found it will fall back to `PAGERDUTY_DEFAULT_EMAIL`. If |
| 24 | + neither are found the command will fail. |
| 25 | +* resolve - Resolve incidents |
| 26 | + `resolve [-a | --as <pagerduty user email>] <incident id>` |
| 27 | + `resolve` works identically to `ack`. First looking for |
| 28 | + `PAGERDUTY_EMAIL_FOR_<COG USER>` and then `PAGERDUTY_DEFAULT_EMAIL`. |
| 29 | +* alert - Trigger an incident on a specific service. |
| 30 | + `alert [-s | --service <service name>] <msg>` |
| 31 | + Optionally you can set the `PAGERDUTY_DEFAULT_SERVICE_KEY` env var. |
| 32 | + `alert` will then trigger incidents on that service when no service |
| 33 | + is passed. |
| 34 | +* incidents - Get a list of incidents |
| 35 | + `incidents [-a | --acked] [-t | --triggered] [-r | --resolved] [-l | --limit]` |
| 36 | + Get a list of incidents based on the option or options passed. By default |
| 37 | + incidents will return only incidents in the `triggered` state. |
| 38 | +* oncall - Get a list of services with the current primary oncall |
| 39 | + `oncall [service name]` |
| 40 | + If a service is passed only the oncall for that service will be returned. |
| 41 | + Otherwise a list of services with their corresponding user will be returned. |
| 42 | + |
| 43 | +# Permissions |
| 44 | + |
| 45 | +pagerduty comes bundles with three permissions: pagerduty:alert, pagerduty:read, |
| 46 | +pagerduty:write. By default `oncall` is 'allowed'. To `alert` you will need the |
| 47 | +pagerduty:alert permission. To see incidents, pagerduty:read. And to `ack` or |
| 48 | +`resolve`, pagerduty:write. |
| 49 | + |
| 50 | +# Configuration |
| 51 | + |
| 52 | +pagerduty uses a few env vars to configure it. All commands require |
| 53 | +`PAGERDUTY_ACCOUNT_SUBDOMAIN` and `PAGERDUTY_ACCOUNT_TOKEN` to be set. That would |
| 54 | +be the subdomain for your PagerDuty account and the api token respectively. |
| 55 | + |
| 56 | +`alert` has an optional var, `PAGERDUTY_DEFAULT_SERVICE_KEY`. This is the integration |
| 57 | +key found on the integration tab for the service on PagerDuty's web ui. If set, any |
| 58 | +alerts that don't specify a service will be sent here. Note that if the service key |
| 59 | +is not set or a service isn't passed to the command, it will fail. |
| 60 | + |
| 61 | +`ack` and `resolve` have a couple extra vars. `PAGERDUTY_DEFAULT_EMAIL`, similar to |
| 62 | +`PAGERDUTY_DEFAULT_SERVICE_KEY`, `ack` and `resolve` will use this email as the |
| 63 | +requester when acking or resolving incidents. Additionally you may attach the |
| 64 | +requester to cog accounts. Using vars in the form, `PAGERDUTY_EMAIL_FOR_<COG USER>` |
| 65 | +you can specify which PagerDuty email is associated with which Cog user. So for |
| 66 | +example, if your Cog username is 'bob', you would set the var `PAGERDUTY_EMAIL_FOR_BOB`. |
| 67 | +Then whenever you `ack` or `resolve` the proper PagerDuty account is associated with the |
| 68 | +action. |
| 69 | + |
| 70 | +# Installing |
| 71 | + |
| 72 | + curl -O https://github.com/cogcmd/pagerduty/blob/master/config.yaml |
| 73 | + cogctl bundle install config.yaml |
| 74 | + |
| 75 | +# Building |
| 76 | + |
| 77 | +To build the Docker image, simply run: |
| 78 | + |
| 79 | + $ rake image |
| 80 | + |
| 81 | +Requires Docker and Rake. |
| 82 | + |
0 commit comments