Giter Club home page Giter Club logo

sensu-pagerduty-handler's Introduction

Bonsai Asset Badge Go Test goreleaser

Sensu PagerDuty Handler

Table of Contents

Overview

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

Usage examples

Help output

The Sensu Go PagerDuty handler for incident management

Usage:
  sensu-pagerduty-handler [flags]
  sensu-pagerduty-handler [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  version     Print the version number of this plugin

Flags:
  -e, --alternate-endpoint string   The endpoint to use to send the PagerDuty events, can be set with PAGERDUTY_ALTERNATE_ENDPOINT
      --contact-routing             Enable contact routing
  -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}}")
      --details-format string       The format of the details output ('string' or 'json'), can be set with PAGERDUTY_DETAILS_FORMAT (default "string")
  -d, --details-template string     The template for the alert details, can be set with PAGERDUTY_DETAILS_TEMPLATE (default full event JSON)
  -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, can be set with PAGERDUTY_STATUS_MAP
  -S, --summary-template string     The template for the alert summary, can be set with PAGERDUTY_SUMMARY_TEMPLATE (default "{{.Entity.Name}}/{{.Check.Name}} : {{.Check.Output}}")
      --team string                 Envvar name for pager team(alphanumeric and underscores) holding PagerDuty V2 API authentication token, can be set with PAGERDUTY_TEAM
      --team-suffix string          Pager team suffix string to append if missing from team name, can be set with PAGERDUTY_TEAM_SUFFIX (default "_pagerduty_token")
      --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)
  -t, --token string                The PagerDuty V2 API authentication token, can be set with PAGERDUTY_TOKEN

Use "sensu-pagerduty-handler [command] --help" for more information about a command.

Deduplication key

The deduplication key is determined via the --dedup-key-template argument. It is a Golang template containing the event values and defaults to {{.Entity.Name}}-{{.Check.Name}}.

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

Configuration

Asset registration

Sensu Assets are the best way to make use of this plugin. If you're not using an asset, please consider doing so! If you're using sensuctl 5.13 with Sensu Backend 5.13 or later, you can use the following command to add the asset:

sensuctl asset add sensu/sensu-pagerduty-handler

If you're using an earlier version of sensuctl, you can find the asset on the Bonsai Asset Index.

Handler definition

---
type: Handler
api_version: core/v2
metadata:
  name: pagerduty
  namespace: default
spec:
  type: pipe
  command: >-
    sensu-pagerduty-handler
    --dedup-key-template "{{.Entity.Namespace}}-{{.Entity.Name}}-{{.Check.Name}}"
    --status-map "{\"info\":[0],\"warning\": [1],\"critical\": [2],\"error\": [3,127]}"
    --summary-template "[{{.Entity.Namespace}}] {{.Entity.Name}}/{{.Check.Name}}: {{.Check.State}}"
    --details-template "{{.Check.Output}}\n\n{{.Check}}"
    --details-format string
  timeout: 10
  runtime_assets:
    - sensu/sensu-pagerduty-handler
  filters:
    - is_incident
  secrets:
    - name: PAGERDUTY_TOKEN
      secret: pagerduty_authtoken

Environment variables

Most arguments for this handler are available to be set via environment variables. However, any arguments specified directly on the command line override the corresponding environment variable.

Argument Environment Variable
--alternate-endpoint PAGERDUTY_ALTERNATE_ENDPOINT
--dedup-key-template PAGERDUTY_DEDUP_KEY_TEMPLATE
--details-template PAGERDUTY_DETAILS_TEMPLATE
--details-format PAGERDUTY_DETAILS_FORMAT
--status-map PAGERDUTY_STATUS_MAP
--summary-template PAGERDUTY_SUMMARY_TEMPLATE
--team PAGERDUTY_TEAM
--team-suffix PAGERDUTY_TEAM_SUFFIX
--timeout PAGERDUTY_TIMEOUT
--token PAGERDUTY_TOKEN

Security Note: Care should be taken to not expose the auth token for this handler by specifying it on the command line or by directly setting the environment variable in the handler definition. It is suggested to make use of secrets management to surface it as an environment variable. The handler definition above references it as a secret. Below is an example secrets definition that make use of the built-in env secrets provider.

---
type: Secret
api_version: secrets/v1
metadata:
  name: pagerduty_token
spec:
  provider: env
  id: PAGERDUTY_TOKEN

Templates

This handler provides options for using templates to populate the values provided by the event in the message sent via SNS. More information on template syntax and format can be found in the documentation.

Argument annotations

All arguments for this handler are tunable on a per entity or check basis based on annotations. The annotations keyspace for this handler is sensu.io/plugins/sensu-pagerduty-handler/config.

NOTE: Due to check token substituion, supplying a template value such as for details-template as a check annotation requires that you place the desired template as a golang string literal (enlcosed in backticks) within another template definition. This does not apply to entity annotations.

Examples

To change the --details-template argument for a particular check, and taking into account the note above regarding templates, for that check's metadata add the following:

type: CheckConfig
api_version: core/v2
metadata:
  annotations:
    sensu.io/plugins/sensu-pagerduty-handler/config/details-template: "{{`{{.Check.Output}}`}}"
  [ ... ]

To change the --token argument for a particular check, for that checks's metadata add the following:

type: CheckConfig
api_version: core/v2
metadata:
  annotations:
    sensu.io/plugins/sensu-pagerduty-handler/config/token: abcde12345fabcd67890efabc12345de
  [ ... ]

Pager teams

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. Corresponding pager team token environment variables can be populated in the handler environment in 3 different ways

  1. Explicitly set in the handler definition
  2. Kept as Sensu secrets and referenced in the handler definition
  3. Defined in the backend service environment file, read in at backend service start.

Pager team names will be automatically suffixed with configured --team-suffix (default: _pagerduty_suffix) 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

If the team token lookup fails, the explicitly provided token will be used as a fallback if available.

Example of Check Using Pager Team and Handler Environment Variables:

First set the team annotation in the check or agent resource.

Check Snippet:
---
type: CheckConfig
api_version: core/v2
metadata:
  name: example-check
  annotations:
    sensu.io/plugins/sensu-pagerduty-handler/config/team: team_1

And define the corresponding evironment variable for the pager team's token in the handler's environment.

Handler Snippet:
---
type: Handler
api_version: core/v2
metadata:
  name: pagerduty
  namespace: default
spec:
  type: pipe
  command: >-
    sensu-pagerduty-handler
    --dedup-key-template "{{.Entity.Namespace}}-{{.Entity.Name}}-{{.Check.Name}}"
    --status-map "{\"info\":[0],\"warning\": [1],\"critical\": [2],\"error\": [3,127]}"
    --summary-template "[{{.Entity.Namespace}}] {{.Entity.Name}}/{{.Check.Name}}: {{.Check.State}}"
    --details-template "{{.Check.Output}}\n\n{{.Check}}"
  timeout: 10
  runtime_assets:
  - sensu/sensu-pagerduty-handler
  filters:
  - is_incident
  secrets:
  - name: PAGERDUTY_TOKEN
    secret: pagerduty_authtoken
  env_vars:
  - team_1_pagerduty_token="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Contact Routing

The Sensu Pagerduty Handler provides support for generating one Pagerduty event per "contact" via the --contact-routing flag.

With --contact-routing enabled, the Sensu Pagerduty Handler will do the following:

  • Check for and merge the entity, check, and/or event contacts annotation.

    The contacts annotation supports a comma-separated list of contact names containing alpha-numeric characters and underscore (_) characters only.

    Example:

    annotations:
      contacts: "team_a,team_b"
    

    NOTE: when --contact-routing is enabled, the handler will log a message like Pagerduty contact routing is enabled (contacts: team_a, team_b). 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.

  • Lookup contact-specific environment variables for Pagerduty API Authentication

    When --contact-routing is enabled, the Sensu Pagerduty Handler will attempt to create or update an event per configured "contact". For each configured "contact", the Sensu Pagerduty Handler will look for a matching environment variable containing a Pagerduty token. 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).

    NOTE: contact names are converted to environment variables via fmt.Sprintf("PAGERDUTY_TOKEN_%s",strings.ToUpper(contact)).

    If a matching contact environment variable is found, the event will be processed. 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).

Contact Routing Example

---
api_version: core/v2
type: Handler
metadata:
  name: pagerduty
spec:
  type: pipe
  command: >-
    sensu-pagerduty-handler
    --contact-routing
    --dedup-key-template "{{.Entity.Namespace}}-{{.Entity.Name}}-{{.Check.Name}}"
    --status-map "{\"info\":[0],\"warning\": [1],\"critical\": [2],\"error\": [3,127]}"
    --summary-template "[{{.Entity.Namespace}}] {{.Entity.Name}}/{{.Check.Name}}: {{.Check.State}}"
    --details-template "{{ .Check.Name }} is {{ .Check.State }} on {{ .Entity.Name }} (namespace: {{ .Entity.Namespace }})"
  timeout: 10
  filters: [ ]
  runtime_assets: [ ]
  env_vars: [ ]
  secrets:
    - name: PAGERDUTY_TOKEN_TEAM_A
      secret: pagerduty_token_team_a
    - name: PAGERDUTY_TOKEN_TEAM_B
      secret: pagerduty_token_team_b

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.

Proxy support

This handler supports the use of the environment variables HTTP_PROXY, HTTPS_PROXY, and NO_PROXY (or the lowercase versions thereof). HTTPS_PROXY takes precedence over HTTP_PROXY for https requests. The environment values may be either a complete URL or a "host[:port]", in which case the "http" scheme is assumed.

Installation from source

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

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

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

Contributing

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

sensu-pagerduty-handler's People

Contributors

amdprophet avatar ccressent avatar cwjohnston avatar echlebek avatar fguimond avatar hillaryfraley avatar jspaleta avatar pablolibo avatar portertech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensu-pagerduty-handler's Issues

Details Template Example

Hello,

I'm trying to override the default details template sent to pager duty:

Env: "PAGERDUTY_DETAILS_TEMPLATE",

I just want my Check output to be displayed in the details section, nothing else. I tried setting PAGERDUTY_DETAILS_TEMPLATE={{.Check.Output}} as an environment variable on my handler, but I'm still getting the full check JSON.

When I configure an annotation on the check like this:
"sensu.io/plugins/sensu-pagerduty-handler/config/details-template": "{{.Check.Output}}"

I get this error message:
error preparing check: unmatched token: template: :1:945: executing "" at <.Check.Output>: map has no entry for key "Check"

Do you have a working example of how to modify the Check JSON or a way to only send the check output to pager duty?

Thanks!

Feature Request: Silencing in Sensu silences in PD

As a user, I'd like to be able to have a silence in Sensu also silence in PD. For example, if I receive an alert that I need to silence, it would be useful to not have to silence in 2 different places. Likewise, if I remove a silence in Sensu, that silence should also be removed in PD.

Feature Request: Support for priority flag

Expected Behavior

When configuring a check, I should be able to specify the priority of that check in a "pagerduty" scope and let pagerduty handle incident priority.

Current Behavior

This is not present

Possible Solution

Allow for configuration of priority in the default pagerduty integration configuration and/or the check/contact level.

Feature Request: Support settable dedupe key

This helps bring the golang handler up to feature parity to the existing community ruby plugin.

Strawman
expose dedupkey value as a settable via this priority list:
named envvar PAGERDUTY_DEDUP_KEY
cli arg: --dedup-key
named label: pagerduty.dedup_key

envvar acts as fallback of last resort

named label is used if set

Label Scopes
label scope is also prioritied:
agent scope , client scope, handler scope

I'm not sure what label priority order makes the most sense... we should make a decision and make it a best practice for all handlers.

PAGERDUTY_SUMMARY_TEMPLATE directive appears to be ignored

Within the yaml file defining the pagerduty handler, I am unable to see any effect when setting the PAGERDUTY_SUMMARY_TEMPLATE variable under the env_vars section. It seems that when notification is received via pagerduty, the default value of "{{.Entity.Name}}/{{.Check.Name}} : {{.Check.Output}}" is always used instead.

Q1'21 handler maintenance

Repository Updates

Module Updates

  • Update SDK, core, and all other modules with 'go get -u' (note: This may require some manual cleanup)
  • Cleanup with 'go mod tidy'

README Updates

  • Add note on templates and link to docs, when needed
  • Ensure help output is current
  • Caveat on using check annotations (ref https://github.com/sensu/sensu-pagerduty-handler/blob/master/README.md)
  • Make sure annotations are explained as overrides
  • Add table of environment variables available
  • Make sure layout matches current standard
  • Remove empty sections (e.g. Files, Additional Notes)

Golang version updates

  • Update go.mod to use 1.14
  • Update GitHub Actions (release and test) to use 1.14

GitHub Actions Updates

  • All have lint, test, and release actions
  • Add PR to lint and test actions on OSS handlers

Secrets update

  • For any password/token arguments, ensure 'Secret: true' is set

Code updates

  • Output supporting templates where it makes sense to (make sure to document in README)
  • Replace import of types with api/core/v2 and change *types.Event references to *corev2.Event
  • Run 'gofmt' on all source files

Output logging

  • Output logging information (e.g. any incident or job # created)

Release

  • Make sure Bonsai and GoReleaser configs are in sync and functioning Remove 32 bit macOS from Bonsai
  • Add any changes to CHANGELOG
  • Submit PR
  • After merge, cut a new release
  • In bonsai make sure the handler has the right tier (supported, enterprise)

Update curation(s)

  • Update (or add new) curations to use new version/assets (add in template args if available)

Feature Request: allow custom map of event status enum into allowed pagerduty severity

process a user defined json key,value hash that defines a mapping from integer valued check status, into pagerduty severity strings.

keys are pagerduty severity strings "info","critical","warning","error"

values are arrays of status values

map example:
{"info":[130,10],"error":[4]}
would map status 10 and 130 to "info" and status 4 to "error"

Additionally, if there was a way to encode numeric range that would be fantastic and would lead to very compact representation of complicated status mappings.

Strawman

Implement as a commandline switch --status-map
and as entity,check scoped label ex: pagerduty.status_map

Recommend a namespaced --dedup-key-template for Pagerduty

If you're integrating with Pagerduty from multiple namespaces, it may be prudent to use a "namespaced" Pagerduty dedup_key (see: https://support.pagerduty.com/docs/event-management#section-deduplicating-incidents).

type: Handler
api_version: core/v2
metadata:
  name: pagerduty
spec:
  command: >-
    sensu-pagerduty-handler
    --dedup-key-template "{{.Entity.Namespace}}-{{.Entity.Name}}-{{.Check.Name}}"
    --summary-template "{{.Entity.Name}}/{{.Check.Name}}: {{.Check.Output}}"
    --status-map "{\"info\":[0],\"warning\": [1],\"critical\": [2],\"error\": [3,127]}"
  filters:
  - is_incident
  - not_silenced
  runtime_assets:
  - sensu/sensu-pagerduty-handler:2.0.1
  secrets:
  - name: PAGERDUTY_TOKEN
    secret: pagerduty_token
  timeout: 0
  type: pipe

Support additional PD-CEF fields and optionally send templated details as Struct/JSON

This is a single issue, but contains two parts:

  1. A request to add support for the remaining PD-CEF fields of:
    1. Timestamp
    2. Class
    3. Group
  2. A request to support processing the details template as json so we can send structured data through to Pagerduty. At the moment the options are:
    1. Send through the full event JSON. This is a lot of unnecessary data and the deep nesting of fields (when using labels and annotations) makes it hard to read some fields on Pagerduty
    2. Use a template to select required fields. Which unfortunately sends through the data as a string with no structure on the Pagerduty side which means you can't really use custom details in event rules

I'm hoping 1 is pretty uncontroversial and can be done. I would prefer it if these work similarly to summary and use a template.

I could accept 2 not happening if 1 goes ahead, but it really would be nice to have the option of templating structured data one-way or another.

In accordance with the contributing guidelines I'm opening an issue to discuss first, but I have made initial code changes on this branch. The changes can be seen on this compare view

I have tried to separate the commits to cover both requests:

  • These two commits for adding the additional PD-CEF fields.
  • This commit which adds a --send-details-as-json flag to process the template as json.

There is undoubtably a better way of doing 2 than what I've done - and I definitely welcome feedback and guidance. What I've done is pretty simplistic: When I realised that using the template returned a string I just used a json.Unmarshal to parse that string as a Struct/JSON. It "works", but maybe a real solution lies deeper in the templating stuff?

The title of incident without hostname and check name

Hi all,

I'm having a strange behavior about this handler to pagerduty, when sending the event is not included hostname and the check name of the alert like old version of handler pagerduty written in ruby.

for example, the ruby version the 'Related to Incident' in pagerduty console is like:

services-01289.ops/elasticsearch-cluster-status : ESClusterStatus WARNING: Cluster is yellow
hostname/check_name: output

that is fine, but the pagerduty in GO I have something like this:

CheckHttp CRITICAL: Request error: end of file reached
this is the output command without the hostname and check name, I would like to add these fields for a better understanding of the alert.

How I can fix it?

Thanks!

Errors in .bonsai.yml

I was reviewing .bonsai.yml and I noticed a few issues.

  • The filter for 64 bit Windows says "entity.system.os == 'darwin'"
  • The filter for 32 bit Linux ARM says "entity.system.arch == 'armv7'", but it should says "entity.system.arch == 'arm'" instead.
  • There is no entry for 32 bit Windows, when there could be.

[Feature Request] Provide ability to specify alternate pagerduty endpoints

In internal ref https://secure.helpscout.net/conversation/2205602449/31243?folderId=5845954, it was noted that other applications sending events to pagerduty have the ability to override the default events.pagerduty.com endpoint with a different URL. This is useful in cases where someone is using 3rd party software like the Pagerduty Alt Agent to send events to pagerduty. A good example of this is the Splunk Pagerduty Integration. Specifically, it looks like the integration URL there is the kind of feature that should be added.

Feature Request - Pass details template content deserialized to PD

The PD handler is serializing everything under details template but we want this to be available deserialized in pagerduty.

Json format (when the default payload is sent without -d) can translate to table nicely. We look to be serializing the string with details template producing an undesirable view for the customer.

Config
image

Event details
image

Introducing functionality like -T, --bodyTemplateFile from the email handler could be useful here?

Internal ref - https://secure.helpscout.net/conversation/2188359742/31097?folderId=4465878

Add support for basic contact routing

Add a new --contact-routing flag

  • Looks for and merges the entity, check, and/or event contacts annotation.

    The contacts annotation(s) should be formatted as a comma-separate list of contact names.

    annotations:
      contacts: "team_a,team_b"

    NOTE: Contact names may contain only alpha-numeric characters and underscore (_).

  • The --contact-routing flag should cause the handler to log the merged list of contacts

    Example:

    Pagerduty contact routing is enabled (contacts: team_a, team_b)
    
  • Execute manageIncident() function once per contact

    Lookup environment variable matching fmt.Sprintf("PAGERDUTY_TOKEN_%s", strings.ToUpper(contact)) (or similar).

    Notes on environment variable lookups:

    • TBD if --contact-routing could be used with the existing --team and --team-suffix flags for looking up contact environment variables.
    • TBD if environment variables should use a configurable or hardcoded prefix (e.g. PAGERDUTY_TOKEN_) or suffix (see above RE: reusing existing --team-suffix flag).
    • Perhaps a --contact-prefix flag would be best so it doesn't conflict with existing functionality?

    If the contact environment is found, perform the manageIncident() function.

    If the contact environment variable is not found, log an warning (e.g. WARNING: skipping contact: "team-a" (no environment variable found for "PAGERDUTY_TOKEN_TEAM_A")\n).

    If at least one matching contact environment variable is found and manageIncident() returns no errors, the handler should exit with status 0.

Example pipeline configuration:

---
api_version: core/v2
type: Pipeline
metadata:
  name: pagerduty
spec:
  workflows:
    - name: pagerduty
      filters:
        - api_version: core/v2
          type: EventFilter
          name: is_incident
        - api_version: core/v2
          type: EventFilter
          name: not_silenced
      handler:
        api_version: core/v2
        type: Handler
        name: pagerduty
---
# Requires PAGERDUTY_TOKEN environment variable or secret
api_version: core/v2
type: Handler
metadata:
  name: pagerduty
spec:
  type: pipe
  command: >-
    sensu-pagerduty-handler
    --contact-routing
    --contact-prefix "PAGERDUTY_TOKEN_"
    --dedup-key-template "{{.Entity.Namespace}}-{{.Entity.Name}}-{{.Check.Name}}"
    --status-map "{\"info\":[0],\"warning\": [1],\"critical\": [2],\"error\": [3,127]}"
    --summary-template "[{{.Entity.Namespace}}] {{.Entity.Name}}/{{.Check.Name}}: {{.Check.State}}"
    --details-template ""{{ .Check.Name }} is {{ .Check.State }} on {{ .Entity.Name }} (namespace: {{ .Entity.Namespace }})\n\n{{ or (index .Annotations \"sensu.io/notifications/critical\") (index .Annotations \"sensu.io/notifications/warning\") .Check.Output }}""
  timeout: 10
  filters: []
  runtime_assets:
    - sensu/sensu-pagerduty-handler
  env_vars: []
  secrets:
    - name: PAGERDUTY_TOKEN_TEAM_A
      secret: pagerduty_team_a
    - name: PAGERDUTY_TOKEN_TEAM_B
      secret: pagerduty_team_B

Example agent config:

---
# example agent.yml
name: i-424242
labels: {}
annotations:
  contacts: "team_a,team_b"

Example check config:

---
api_version: core/v2
type: CheckConfig
metadata:
  name: example-check
  annotations:
    contacts: "team_c"
spec:
  ...: ...

Truncate summary to 1024 characters

According to PagerDuty API documentation, for payload.summary

The maximum permitted length of this property is 1024 characters.

Trying to send a payload with a longer summary results in the following error: Error: HTTP Status Code: 400, Message: {"status":"invalid event","message":"Event object is invalid","errors":["'summary' is too long (maximum is 1024 characters)"]}

This handler should truncate the summary at 1024 characters, rather than failing to send to PagerDuty.

What is PAGERDUTY_TOKEN and PAGERDUTY_DEDUP_KEY?

I am using sensugo for monitoring. What following parameter should be.

Mu service name is devstack and team name is devcon.

  • PAGERDUTY_TOKEN=76f82173acf040b8a36799bf78b4cbd1 ### Integration API key
    • PAGERDUTY_DEDUP_KEY=PAGERDUTY_DEDUP_KEY ### what is this?
    • PAGERDUTY_DEDUP_KEY_TEMPLATE={{.Entity.Name}}-{{.Check.Name}} . ### what is this?
    • PAGERDUTY_STATUS_MAP={"info":[130,10],"error":[4]} . ### what is this?

SENSU_EVENT_LABEL

Hi,

SENSU_EVENT_LABEL is empty therefore the integration is not working, is sensu suppose to fill in or do we need to create it and if so what would be the value?

Add new --pager-team and --pager-team-suffix flags for PD contact routing

Inspired by the sensu-plugins/sensu-plugins-pagerduty contact routing implementation (see comments regarding pager_team check or client attribute).

Overview

Users need the ability to override the default Pagerduty API Token on a per-check and/or per-entity basis. This enhancement will enable users to add a single annotation to check or entity resources to configure the behavior of the Pagerduty handler.

Here's an example check with the sensu.io/plugins/sensu-pagerduty-handler/config/pager-team annotation:

---
type: CheckConfig 
api_version: core/v2 
metadata: 
  name: example-check 
  annotations: 
    sensu.io/plugins/sensu-pagerduty-handler/config/pager-team: team_1

Here's an example agent.yaml file with the sensu.io/plugins/sensu-pagerduty-handler/config/pager-team annotation set:

---
##
# agent configuration
##
# name: example-agent
# namespace: default
backend-url:
- wss://sensu-backend-0.sensu.sensu-system.svc.cluster.local:8081 
- wss://sensu-backend-1.sensu.sensu-system.svc.cluster.local:8081 
- wss://sensu-backend-2.sensu.sensu-system.svc.cluster.local:8081
subscriptions:
- linux
- docker
- kubernetes
labels:
  org: Sensu, Inc.
annotations: 
  sensu.io/plugins/sensu-pagerduty-handler/config/pager-team: team_1

Proposed changes

  • Add a new --pager-team flag and corresponding annotation (i.e. sensu.io/plugins/sensu-pagerduty-handler/config/pager-team)
  • Add a new --pager-team-suffix flag (default to _pagerduty_token)
  • Use the string values of --pager-team and --pager-team-suffix to read the corresponding Pagerduty API Token value as an environment variable
  • Users can set Pagerduty team tokens using the Handler env_vars field, or using Sensu's built-in secrets management
  • Users can also manage Pagerduty team tokens outside of Sensu (e.g. by editing /etc/default/sensu-backend or via config management on the Sensu backend nodes), but we will recommend keeping the config in Sensu

Bonsai asset creation has wrong filter for Windows 386

The Bonsai asset definition for the Windows 386 build has amd64 for the arch.

spec:
  builds:
  - url: https://assets.bonsai.sensu.io/e6722787284bd20f68d0375ee927aa0ec5d2e57b/sensu-pagerduty-handler_1.3.2_windows_386.tar.gz
    sha512: 10eb353c624fa1853a5b6175366e6ae325315208b2289b1191629004737dbacbfc576f54b95a89560a5226e24aa0438458256b04ac1ffdc9876cf0afdf6441dd
    filters:
    - entity.system.os == 'windows'
    - entity.system.arch == 'amd64'

Feature request: Support custom summary formatting

Would be useful to be able to provide a custom summary string with token substitution.

What I propose is being able to set another environment variable like:
"PAGERDUTY_SUMMARY_FORMAT={ENTITY}/{CHECK} : {OUTPUT}"

Upgrade to Pagerduty Webhooks v3

We just received a notification from the PagerDuty partner team regarding upcoming changes to PagerDuty APIs that we need to review.

Re: Your integration with PagerDuty built with PagerDuty's APIs and webhooks

https://www.pagerduty.com/integrations/sensu/

Just wanted to email you to let you know the following changes will be happening in the near future.

  1. CHANGES TO WEBHOOKS: We are happy to launch our v3 webhooks utilized to build a native integration. In addition, we wanted to let you know that we are deprecating our v1 webhooks and v2 webhooks at the end of November 2021 (v1 webhooks) and March, 2022 (v2 webhooks). Please review your current integration listed on the PagerDuty Directory and upgrade your integration to v3 webhooks before November, 2021.

    Resource Links for webhooks:
    https://support.pagerduty.com/docs/webhooks
    https://support.pagerduty.com/docs/webhooks#migrating-from-v1v2-generic-extensions-to-v3-webhook-subscriptions

    Integration Documentation: Please also review your integration documentation and make any changes needed.

  2. INCIDENT AND ALERT ID CHANGES: We are also making changes to the Incident and Alert ID. The Incident and Alert ID are being increased in character length to 14 in place of the current 7 characters to support the increasing storage capacity of our systems starting in the month of October, 2021.
    We will first roll this out to our EU service region on October 5, 2021, followed by a rollout to the North American service region on October 12, 2021.

If you have a custom integration or your own code that makes use of PagerDuty’s API, you should review that code at this time to ensure that it will continue to function with the new identifiers. Specifically, you should confirm that your code does not rely on the existence of a P prefix for incident identifiers, nor make assumptions that they are of a certain length.

Handle PagerDuty API rate limiting

PagerDuty API has rate limits; see here and here. I would like to see this handler tackle the issue of hitting the rate limit (for example in case of a larger outage).

Maybe something like number of --retries parameter? Maybe even with configurable backoff, multiplier etc?

Configure trust store

Hello,
I'm attempting to send pagerduty events via an encrypted proxy. I am getting this error:

{"assets":null,"component":"pipelined","handler":"pagerduty","level":"info","msg":"event pipe handler executed","namespace":"default","output":"Error: Post https://events.pagerduty.com/v2/enqueue: proxyconnect tcp: x509: certificate signed by unknown authority\nUsage:\n  sensu-pagerduty-handler [flags]\n\nFlags:\n  -h, --help           help for sensu-pagerduty-handler\n  -t, --token string   The PagerDuty V2 API authentication token, use default from PAGERDUTY_TOKEN env var (default \"xxx\")\n\nerror: Post https://events.pagerduty.com/v2/enqueue: proxyconnect tcp: x509: certificate signed by unknown authority\n","status":1,"time":"2019-03-08T23:05:06Z"}

I believe the problem is that the CA which signed the cert for my proxy is not in the trust store for the sensu-pagerduty-handler. Is there a way to configure this? If not, please consider this report as a feature-request.

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.