forked from cogcmd/pagerduty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yaml
193 lines (171 loc) · 6.25 KB
/
config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
---
cog_bundle_version: 4
name: pagerduty
version: 0.1.0
description: Interact with pagerduty
long_description: |
The pagerduty bundle can be configured with a few env vars. All
commands require PAGERDUTY_ACCOUNT_SUBDOMAIN and
PAGERDUTY_ACCOUNT_TOKEN to be set. That would be the subdomain for
your PagerDuty account and the V1 API token respectively.
The alert command has an optional var, PAGERDUTY_DEFAULT_SERVICE_KEY.
This is the integration key found on the integration tab for the
service on PagerDuty's web UI. If set, any alerts that don't specify a
service will be sent here. Note that if the service key is not set or
a service isn't passed to the command, it will fail.
Commands ack and resolve have a couple extra vars.
PAGERDUTY_DEFAULT_EMAIL, similar to PAGERDUTY_DEFAULT_SERVICE_KEY,
will be used as the requester when acking or resolving incidents.
Additionally, you may attach the requester to cog accounts. Using vars
in the form, PAGERDUTY_EMAIL_FOR_<COG_USER> you can specify which
PagerDuty email is associated with which Cog user. So for example, if
your Cog username is 'bob', you would set the var
PAGERDUTY_EMAIL_FOR_BOB. Then whenever you ack or resolve the proper
PagerDuty account is associated with the action.
author: Matthew Peck <matt@operable.io>
homepage: https://github.com/cogcmd/pagerduty
docker:
image: cogcmd/pagerduty
tag: 0.1.0
permissions:
- pagerduty:read
- pagerduty:write
- pagerduty:alert
commands:
alert:
executable: /home/bundle/cog-command
description: Trigger alerts
arguments: "<message>"
long_description: |
Returns a confirmation message on success
Requires the following environment variables:
PAGERDUTY_ACCOUNT_SUBDOMAIN
PAGERDUTY_ACCOUNT_TOKEN
Behavior is configured by the following environment variables:
PAGERDUTY_DEFAULT_SERVICE_KEY
If no service is passed, this is the id of the service to use.
notes: If no service is passed and the default service key is not set, the command will fail.
rules:
- must have pagerduty:alert
options:
service:
type: string
required: false
short_flag: s
oncall:
executable: /home/bundle/cog-command
description: Find out who is on-call for all services, or for a specific service
long_description: |
Requires the following environment variables:
PAGERDUTY_ACCOUNT_SUBDOMAIN
PAGERDUTY_ACCOUNT_TOKEN
arguments: "[service]"
rules: ["allow"]
ack:
executable: /home/bundle/cog-command
description: Acknowledge incidents
long_description: |
Returns confirmation of acknowledgement
Requires the following environment variables:
PAGERDUTY_ACCOUNT_SUBDOMAIN
PAGERDUTY_ACCOUNT_TOKEN
Behavior is configured by the following environment variables:
PAGERDUTY_DEFAULT_EMAIL
The default pagerduty email to acknowledge incidents as
PAGERDUTY_EMAIL_FOR_<COG_USER>
Used to map cog users to pagerduty emails
An email mapping to a pagerduty account is required in order to
ack incidents. If the '--as' option has been specified then that
email will be used. If not this command will first look for an
environment variable in the form of
'PAGERDUTY_EMAIL_FOR_<COG_USER>', so if your user name is 'bob',
the env var will be 'PAGERDUTY_EMAIL_FOR_BOB', and use that email
to acknowledge the incident. If that fails it will try
'PAGERDUTY_DEFAULT_EMAIL' If none of those vars are specified and
the '--as' option is not passed, the command will fail.
arguments: "<incident-id>"
rules:
- must have pagerduty:write
options:
as:
type: string
required: false
short_flag: a
description: The email of a PagerDuty user
resolve:
executable: /home/bundle/cog-command
description: Resolve incidents
long_description: |
Returns confirmation of resolution
Requires the following environment variables:
PAGERDUTY_ACCOUNT_SUBDOMAIN
PAGERDUTY_ACCOUNT_TOKEN
Behavior is configured by the following environment variables:
PAGERDUTY_DEFAULT_EMAIL
The default pagerduty email to acknowledge incidents as
PAGERDUTY_EMAIL_FOR_<COG_USER>
Used to map cog users to pagerduty emails
An email mapping to a pagerduty account is required in order to
resolve incidents. If the '--as' option has been specified then
that email will be used. If not this command will first look for
an environment variable in the form of
'PAGERDUTY_EMAIL_FOR_<COG_USER>', so if your user name is 'bob'
the env var will be 'PAGERDUTY_EMAIL_FOR_BOB', and use that email
to acknowledge the incident. If that fails it will try
'PAGERDUTY_DEFAULT_EMAIL' If none of those vars are specified and
the '--as' option is not passed, the command will fail.
arguments: "<incident-id>"
rules:
- must have pagerduty:write
options:
as:
type: string
required: false
short_flag: a
description: The email of a PagerDuty user
incidents:
executable: /home/bundle/cog-command
description: List incidents
long_description: |
Retrieves incidents matching the specified option. By default,
only returns triggered incidents.
Requires the following environment variables:
PAGERDUTY_ACCOUNT_SUBDOMAIN
PAGERDUTY_ACCOUNT_TOKEN
rules:
- must have pagerduty:read
options:
triggered:
type: bool
required: false
short_flag: t
acked:
type: bool
required: false
short_flag: a
resolved:
type: bool
required: false
short_flag: r
limit:
type: int
required: false
short_flag: l
templates:
oncall:
body: |
~each var=$results~
| ~$item.name~ |
| --- |
~each var=$item.oncall~
| ~$item.name~ <<~$item.email~>> |
~end~
~br~
~end~
incidents:
body: |
| Service | Status | Subject | URL |
| ------- | ------ | ------- | --- |
~each var=$results~
| ~$item.service.name~ | ~$item.status~ | ~$item.summary.subject~ | ~$item.url~ |
~end~