content/flux/v0/stdlib/contrib/sranka/opsgenie/sendalert.md
opsgenie.sendAlert() sends an alert message to Opsgenie.
(
apiKey: string,
message: string,
?actions: A,
?alias: string,
?description: string,
?details: B,
?entity: string,
?priority: string,
?responders: [string],
?tags: C,
?url: string,
?visibleTo: [string],
) => int where B: Stringable
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Opsgenie API URL. Defaults to https://api.opsgenie.com/v2/alerts.
({{< req >}}) (Required) Opsgenie API authorization key.
({{< req >}}) (Required) Alert message text. 130 characters or less.
Opsgenie alias usee to de-deduplicate alerts. 250 characters or less. Defaults to message.
Alert description. 15000 characters or less.
Opsgenie alert priority.
Valid values include:
P1P2P3 (default)P4P5List of responder teams or users.
Use the user: prefix for users and teams: prefix for teams.
Alert tags.
Alert entity used to specify the alert domain.
List of actions available for the alert.
Additional alert details. Must be a JSON-encoded map of key-value string pairs.
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.
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:[email protected]", "team:itcrowd"],
)