You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add support for alternate endpoints
* Add support to send events to a different endpoint than the PagerDuty events API
* Update to the latest sensu-plugin-skd
Signed-off-by: Francis Guimond [email protected]
-[Installation from source](#installation-from-source)
23
24
-[Contributing](#contributing)
24
25
@@ -31,6 +32,7 @@ The Sensu PagerDuty Handler is a [Sensu Event Handler][3] which manages
31
32
## Usage examples
32
33
33
34
### Help output
35
+
34
36
```
35
37
The Sensu Go PagerDuty handler for incident management
36
38
@@ -39,10 +41,12 @@ Usage:
39
41
sensu-pagerduty-handler [command]
40
42
41
43
Available Commands:
44
+
completion Generate the autocompletion script for the specified shell
42
45
help Help about any command
43
46
version Print the version number of this plugin
44
47
45
48
Flags:
49
+
-e, --alternate-endpoint string The endpoint to use to send the PagerDuty events, can be set with PAGERDUTY_ALTERNATE_ENDPOINT
46
50
--contact-routing Enable contact routing
47
51
-k, --dedup-key-template string The PagerDuty V2 API deduplication key template, can be set with PAGERDUTY_DEDUP_KEY_TEMPLATE (default "{{.Entity.Name}}-{{.Check.Name}}")
48
52
--details-format string The format of the details output ('string' or 'json'), can be set with PAGERDUTY_DETAILS_FORMAT (default "string")
@@ -52,14 +56,15 @@ Flags:
52
56
-S, --summary-template string The template for the alert summary, can be set with PAGERDUTY_SUMMARY_TEMPLATE (default "{{.Entity.Name}}/{{.Check.Name}} : {{.Check.Output}}")
53
57
--team string Envvar name for pager team(alphanumeric and underscores) holding PagerDuty V2 API authentication token, can be set with PAGERDUTY_TEAM
54
58
--team-suffix string Pager team suffix string to append if missing from team name, can be set with PAGERDUTY_TEAM_SUFFIX (default "_pagerduty_token")
59
+
--timeout uint The maximum amount of time in seconds to wait for the event to be created, can be set with PAGERDUTY_TIMEOUT (default 30)
55
60
-t, --token string The PagerDuty V2 API authentication token, can be set with PAGERDUTY_TOKEN
56
61
57
62
Use "sensu-pagerduty-handler [command] --help" for more information about a command.
58
63
```
59
64
60
65
### Deduplication key
61
66
62
-
The deduplication key is determined via the `--dedup-key-template` argument. It
67
+
The deduplication key is determined via the `--dedup-key-template` argument. It
63
68
is a Golang template containing the event values and defaults to
64
69
`{{.Entity.Name}}-{{.Check.Name}}`.
65
70
@@ -68,41 +73,42 @@ is a Golang template containing the event values and defaults to
68
73
Optionally you can provide mapping information between the Sensu check status
69
74
and the PagerDuty incident severity. To provide the mapping you need to use the
70
75
`--status-map` command line option or the `PAGERDUTY_STATUS_MAP` environment
71
-
variable. The option accepts a JSON document containing the mapping
76
+
variable. The option accepts a JSON document containing the mapping
72
77
information. Here's an example of the JSON document:
73
78
74
79
```json
75
80
{
76
-
"info": [
77
-
0,
78
-
1
79
-
],
80
-
"warning": [
81
-
2
82
-
],
83
-
"critical:": [
84
-
3
85
-
],
86
-
"error": [
87
-
4,
88
-
5,
89
-
6,
90
-
7,
91
-
8,
92
-
9,
93
-
10
94
-
]
81
+
"info": [
82
+
0,
83
+
1
84
+
],
85
+
"warning": [
86
+
2
87
+
],
88
+
"critical:": [
89
+
3
90
+
],
91
+
"error": [
92
+
4,
93
+
5,
94
+
6,
95
+
7,
96
+
8,
97
+
9,
98
+
10
99
+
]
95
100
}
96
101
```
97
102
98
103
The valid [PagerDuty alert severity levels][5] are the following:
104
+
99
105
*`info`
100
106
*`warning`
101
107
*`critical`
102
108
*`error`
103
109
104
-
105
110
## Configuration
111
+
106
112
### Asset registration
107
113
108
114
[Sensu Assets][6] are the best way to make use of this plugin. If you're not
@@ -136,36 +142,38 @@ spec:
136
142
--details-format string
137
143
timeout: 10
138
144
runtime_assets:
139
-
- sensu/sensu-pagerduty-handler
145
+
- sensu/sensu-pagerduty-handler
140
146
filters:
141
-
- is_incident
147
+
- is_incident
142
148
secrets:
143
-
- name: PAGERDUTY_TOKEN
144
-
secret: pagerduty_authtoken
149
+
- name: PAGERDUTY_TOKEN
150
+
secret: pagerduty_authtoken
145
151
```
146
152
147
153
### Environment variables
148
154
149
155
Most arguments for this handler are available to be set via environment
150
-
variables. However, any arguments specified directly on the command line
156
+
variables. However, any arguments specified directly on the command line
Instead of specifying the authentication token directly in the check or agent annotations, you can instead reference a pager team name, which will then be used to lookup the corresponding token from the handler environment.
236
+
Instead of specifying the authentication token directly in the check or agent annotations, you can instead reference a
237
+
pager team name, which will then be used to lookup the corresponding token from the handler environment.
229
238
Corresponding pager team token environment variables can be populated in the handler environment in 3 different ways
239
+
230
240
1. Explicitly set in the handler definition
231
241
2. Kept as Sensu [secrets][13] and referenced in the handler definition
232
242
3. Defined in the [backend service environment file][14], read in at backend service start.
233
243
234
244
Pager team names will be automatically suffixed with configured --team-suffix (default: `_pagerduty_suffix`)
235
-
Note: Pager team name strings should be alphameric and underscores only. Groups of illegal characters will be mapped into a single underscore character. Ex: `example-_-team` will be converted to `example_team`
245
+
Note: Pager team name strings should be alphameric and underscores only. Groups of illegal characters will be mapped
246
+
into a single underscore character. Ex: `example-_-team` will be converted to `example_team`
236
247
237
248
If the team token lookup fails, the explicitly provided token will be used as a fallback if available.
238
249
239
250
##### Example of Check Using Pager Team and Handler Environment Variables:
240
251
241
252
First set the team annotation in the check or agent resource.
253
+
242
254
###### Check Snippet:
255
+
243
256
```
244
257
---
245
258
type: CheckConfig
@@ -253,6 +266,7 @@ metadata:
253
266
And define the corresponding evironment variable for the pager team's token in the handler's environment.
254
267
255
268
###### Handler Snippet:
269
+
256
270
```
257
271
---
258
272
type: Handler
@@ -283,13 +297,15 @@ spec:
283
297
284
298
### Contact Routing
285
299
286
-
The Sensu Pagerduty Handler provides support for generating one Pagerduty event per "contact" via the `--contact-routing` flag.
300
+
The Sensu Pagerduty Handler provides support for generating one Pagerduty event per "contact" via
301
+
the `--contact-routing` flag.
287
302
288
303
With `--contact-routing` enabled, the Sensu Pagerduty Handler will do the following:
289
304
290
305
* Check for and merge the entity, check, and/or event `contacts` annotation.
291
306
292
-
The `contacts` annotation supports a comma-separated list of contact names containing alpha-numeric characters and underscore (`_`) characters only.
307
+
The `contacts` annotation supports a comma-separated list of contact names containing alpha-numeric characters and
308
+
underscore (`_`) characters only.
293
309
294
310
Example:
295
311
@@ -298,19 +314,26 @@ With `--contact-routing` enabled, the Sensu Pagerduty Handler will do the follow
298
314
contacts: "team_a,team_b"
299
315
```
300
316
301
-
_NOTE: when `--contact-routing` is enabled, the handler will log a message like `Pagerduty contact routing is enabled (contacts: team_a, team_b)`.
302
-
If `--contact-routing` is enabled and no `contacts` annotations are found, the handler will log an error like `contact routing enabled but no contacts were found`._
317
+
_NOTE: when `--contact-routing` is enabled, the handler will log a message
318
+
like `Pagerduty contact routing is enabled (contacts: team_a, team_b)`.
319
+
If `--contact-routing` is enabled and no `contacts` annotations are found, the handler will log an error
320
+
like `contact routing enabled but no contacts were found`._
303
321
304
322
* Lookup contact-specific environment variables for Pagerduty API Authentication
305
323
306
-
When `--contact-routing` is enabled, the Sensu Pagerduty Handler will attempt to create or update an event per configured "contact".
307
-
For each configured "contact", the Sensu Pagerduty Handler will look for a matching environment variable containing a Pagerduty token.
308
-
Pagerduty token environment variables should be prefixed with `PAGERDUTY_TOKEN_` and match the contact name in all-uppercase (e.g. the contact "team_a" needs a corresponding `PAGERDUTY_TOKEN_TEAM_A` environment variable).
324
+
When `--contact-routing` is enabled, the Sensu Pagerduty Handler will attempt to create or update an event per
325
+
configured "contact".
326
+
For each configured "contact", the Sensu Pagerduty Handler will look for a matching environment variable containing a
327
+
Pagerduty token.
328
+
Pagerduty token environment variables should be prefixed with `PAGERDUTY_TOKEN_` and match the contact name in
329
+
all-uppercase (e.g. the contact "team_a" needs a corresponding `PAGERDUTY_TOKEN_TEAM_A` environment variable).
309
330
310
-
_NOTE: contact names are converted to environment variables via `fmt.Sprintf("PAGERDUTY_TOKEN_%s",strings.ToUpper(contact))`._
331
+
_NOTE: contact names are converted to environment variables
332
+
via `fmt.Sprintf("PAGERDUTY_TOKEN_%s",strings.ToUpper(contact))`._
311
333
312
334
If a matching contact environment variable is found, the event will be processed.
313
-
If the contact environment variable is not found, the handler will log a warning (e.g. `WARNING: skipping contact: "team-a" (no environment variable found for "PAGERDUTY_TOKEN_TEAM_A")`\n).
335
+
If the contact environment variable is not found, the handler will log a warning (
336
+
e.g. `WARNING: skipping contact: "team-a" (no environment variable found for "PAGERDUTY_TOKEN_TEAM_A")`\n).
--details-template "{{ .Check.Name }} is {{ .Check.State }} on {{ .Entity.Name }} (namespace: {{ .Entity.Namespace }})"
332
355
timeout: 10
333
-
filters: []
334
-
runtime_assets: []
335
-
env_vars: []
356
+
filters: []
357
+
runtime_assets: []
358
+
env_vars: []
336
359
secrets:
337
360
- name: PAGERDUTY_TOKEN_TEAM_A
338
361
secret: pagerduty_token_team_a
339
362
- name: PAGERDUTY_TOKEN_TEAM_B
340
363
secret: pagerduty_token_team_b
341
364
```
342
365
343
-
_NOTE: contact routing is compatible with Sensu Secrets or environment variables set via Handler `env_vars`, but given the sensitive nature of a Pagerduty API token, using secrets management is strongly encouraged._
366
+
_NOTE: contact routing is compatible with Sensu Secrets or environment variables set via Handler `env_vars`, but given
367
+
the sensitive nature of a Pagerduty API token, using secrets management is strongly encouraged._
344
368
345
369
### Proxy support
346
370
347
371
This handler supports the use of the environment variables HTTP_PROXY,
348
372
HTTPS_PROXY, and NO_PROXY (or the lowercase versions thereof). HTTPS_PROXY takes
349
-
precedence over HTTP_PROXY for https requests. The environment values may be
373
+
precedence over HTTP_PROXY for https requests. The environment values may be
350
374
either a complete URL or a "host[:port]", in which case the "http" scheme is
351
375
assumed.
352
376
@@ -356,6 +380,7 @@ Download the latest version of the sensu-pagerduty-handler from [releases][4],
356
380
or create an executable from this source.
357
381
358
382
From the local path of the sensu-pagerduty-handler repository:
383
+
359
384
```
360
385
go build -o /usr/local/bin/sensu-pagerduty-handler
361
386
```
@@ -365,16 +390,29 @@ go build -o /usr/local/bin/sensu-pagerduty-handler
365
390
See https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md
0 commit comments