3.9 KiB
title | description | aliases | menu | weight | introduced | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pagerduty.sendEvent() function | The `pagerduty.sendEvent()` function sends an event to PagerDuty. |
|
|
202 | 0.43.0 |
The pagerduty.sendEvent()
function sends an event to PagerDuty.
import "pagerduty"
pagerduty.sendEvent(
pagerdutyURL: "https://events.pagerduty.com/v2/enqueue",
routingKey: "ExampleRoutingKey",
client: "ExampleClient",
clientURL: "http://examplepagerdutyclient.com",
dedupKey: "ExampleDedupKey",
class: "cpu usage",
group: "app-stack",
severity: "ok",
eventAction: "trigger",
source: "monitoringtool:vendor:region",
component: "example-component",
summary: "This is an example summary.",
timestamp: "2016-07-17T08:42:58.315+0000",
customDetails: {exampleDetail: "Details"},
)
Parameters
pagerdutyURL
The URL of the PagerDuty endpoint.
Defaults to https://events.pagerduty.com/v2/enqueue
.
routingKey
The routing key generated from your PagerDuty integration.
client
The name of the client sending the alert.
clientURL
The URL of the client sending the alert.
dedupKey
A per-alert ID that acts as deduplication key and allows you to acknowledge or change the severity of previous messages. Supports a maximum of 255 characters.
{{% note %}}
When using pagerduty.endpoint()
to send data to PagerDuty, the function uses the pagerduty.dedupKey()
function to populate the dedupKey
parameter.
{{% /note %}}
class
The class or type of the event.
Classes are user-defined.
For example, ping failure
or cpu load
.
group
A logical grouping used by PagerDuty.
Groups are user-defined.
For example, app-stack
.
severity
The severity of the event.
Valid values include:
critical
error
warning
info
eventAction
Event type to send to PagerDuty.
Valid values include:
trigger
resolve
acknowledge
source
The unique location of the affected system. For example, the hostname or fully qualified domain name (FQDN).
component
Component responsible for the event.
summary
A brief text summary of the event used as the summaries or titles of associated alerts. The maximum permitted length is 1024 characters.
timestamp
The time the detected event occurred in RFC3339nano format.
customDetails
Additional event details.
Examples
Send the last reported status to PagerDuty
import "pagerduty"
import "influxdata/influxdb/secrets"
lastReported = from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> findRecord(fn: (key) => true, idx: 0)
pagerduty.sendEvent(
routingKey: "example-routing-key",
client: lastReported.client,
clientURL: lastReported.clientURL,
class: lastReported.class,
eventAction: lastReported.eventAction,
group: lastReported.group,
severity: lastReported.severity,
component: lastReported.component,
source: lastReported.source,
component: lastReported.component,
summary: lastReported.summary,
timestamp: lastReported._time,
customDetails: {"ping time": lastReported.ping, load: lastReported.load},
)