opsgenie.sendAlert() function
The opsgenie.sendAlert()
function is a user-contributed function maintained by the package author and can be updated or removed at any time.
The opsgenie.sendAlert()
function sends an alert message to Opsgenie.
*Function type: Output*
import "contrib/sranka/opsgenie"
opsgenie.sendAlert(
url: "https://api.opsgenie.com/v2/alerts",
apiKey: "YoUrSup3R5ecR37AuThK3y",
message: "Example message",
alias: "Example alias",
description: "Example description",
priority: "P3",
responders: ["user:john@example.com", "team:itcrowd"],
tags: ["tag1", "tag2"],
entity: "example-entity",
actions: ["action1", "action2"],
details: "{}",
visibleTo: []
)
Parameters
url
Opsgenie API URL. Defaults to https://api.opsgenie.com/v2/alerts
.
*Data type: String*
apiKey
Required Opsgenie API authorization key.
*Data type: String*
message
Required Alert message text. 130 characters or less.
*Data type: String*
alias
Opsgenie alias usee to de-deduplicate alerts. 250 characters or less. Defaults to message.
*Data type: String*
description
Alert description. 15000 characters or less.
*Data type: String*
priority
Opsgenie alert priority. Valid values include:
P1
P2
P3
(default)P4
P5
*Data type: String*
responders
List of responder teams or users. Use the user:
prefix for users and teams:
prefix for teams.
*Data type: Array of strings*
tags
Alert tags.
*Data type: Array of strings*
entity
Alert entity used to specify the alert domain.
*Data type: String*
actions
List of actions available for the alert.
*Data type: Array of strings*
details
Additional alert details. Must be a JSON-encoded map of key-value string pairs.
*Data type: String*
visibleTo
List of teams and users the alert will be visible to without sending notifications. Use the user:
prefix for users and teams:
prefix for teams.
*Data type: Array of strings*
Examples
Send the last reported status to a Opsgenie
import "influxdata/influxdb/secrets"
import "contrib/sranka/opsgenie"
apiKey = secrets.get(key: "OPSGENIE_APIKEY")
lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> findRecord(fn: (key) => true, idx: 0)
opsgenie.sendAlert(
apiKey: apiKey,
message: "Disk usage is: ${lastReported.status}.",
alias: "example-disk-usage",
responders: ["user:john@example.com", "team:itcrowd"]
)
Package author and maintainer
Github: @sranka
InfluxDB Slack: @sranka