pagerduty.endpoint() function

The pagerduty.endpoint() function returns a function that can be used to send a message to PagerDuty that includes output data.

import "pagerduty"

    url: ""



PagerDuty v2 Events API URL. Default is


pagerduty.endpoint is a factory function that outputs another function. The output function requires a mapFn parameter. See the PagerDuty v2 Events API documentation for more information about these parameters.


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

mapFn accepts a table row (r) and returns a record that must include the following fields:

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

For more information, see pagerduty.sendEvent()


Send critical statuses to a PagerDuty endpoint
import "pagerduty"
import "influxdata/influxdb/secrets"

routingKey = secrets.get(key: "PAGERDUTY_ROUTING_KEY")
toPagerDuty = pagerduty.endpoint()

crit_statuses = from(bucket: "example-bucket")
    |> range(start: -1m)
    |> filter(fn: (r) => r._measurement == "statuses" and r.status == "crit")

    |> toPagerDuty(
        mapFn: (r) => ({r with
            routingKey: routingKey,
            client: r.client,
            clientURL: r.clientURL,
            class: r.class,
            eventAction: r.eventAction,
            severity: r.severity,
            component: r.component,
            source: r.source,
            summary: r.summary,
            component: r.component,
            timestamp: r._time,
            customDetails: {"ping time":, load: lastReported.load},

Was this page helpful?

Thank you for your feedback!

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.