pagerduty.endpoint() function

The pagerduty.endpoint() function sends a message to PagerDuty that includes output data.

*Function type: Output*

  1. import "pagerduty"
  2. pagerduty.endpoint(
  3. url: "https://events.pagerduty.com/v2/enqueue"
  4. )

Parameters

pagerdutyURL

The PagerDuty API URL. Defaults to https://events.pagerduty.com/v2/enqueue.

*Data type: String*

Usage

pagerduty.endpoint is a factory function that outputs another function. The output function requires a mapFn parameter.

mapFn

A function that builds the record used to generate the POST request. Requires an r parameter.

*Data type: Function*

The returned record must include the following fields:

  • routingKey
  • client
  • client_url
  • class
  • eventAction
  • group
  • severity
  • component
  • source
  • summary
  • timestamp

For more information, see pagerduty.sendEvent()

Examples

Send critical statuses to a PagerDuty endpoint
  1. import "pagerduty"
  2. import "influxdata/influxdb/secrets"
  3. token = secrets.get(key: "PAGERDUTY_TOKEN")
  4. e = pagerduty.endpoint(token: token)
  5. crit_statuses = from(bucket: "example-bucket")
  6. |> range(start: -1m)
  7. |> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
  8. crit_statuses
  9. |> e(mapFn: (r) => ({ r with
  10. routingKey: r.routingKey,
  11. client: r.client,
  12. clientURL: r.clientURL,
  13. class: r.class,
  14. eventAction: r.eventAction,
  15. group: r.group,
  16. severity: r.severity,
  17. component: r.component,
  18. source: r.source,
  19. summary: r.summary,
  20. timestamp: r._time,
  21. })
  22. )()

endpoints