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*

  1. import "contrib/sranka/opsgenie"
  2. opsgenie.sendAlert(
  3. url: "https://api.opsgenie.com/v2/alerts",
  4. apiKey: "YoUrSup3R5ecR37AuThK3y",
  5. message: "Example message",
  6. alias: "Example alias",
  7. description: "Example description",
  8. priority: "P3",
  9. responders: ["user:john@example.com", "team:itcrowd"],
  10. tags: ["tag1", "tag2"],
  11. entity: "example-entity",
  12. actions: ["action1", "action2"],
  13. details: "{}",
  14. visibleTo: []
  15. )

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
  1. import "influxdata/influxdb/secrets"
  2. import "contrib/sranka/opsgenie"
  3. apiKey = secrets.get(key: "OPSGENIE_APIKEY")
  4. lastReported =
  5. from(bucket: "example-bucket")
  6. |> range(start: -1m)
  7. |> filter(fn: (r) => r._measurement == "statuses")
  8. |> last()
  9. |> findRecord(fn: (key) => true, idx: 0)
  10. opsgenie.sendAlert(
  11. apiKey: apiKey,
  12. message: "Disk usage is: ${lastReported.status}.",
  13. alias: "example-disk-usage",
  14. responders: ["user:john@example.com", "team:itcrowd"]
  15. )

Package author and maintainer

Github: @sranka
InfluxDB Slack: @sranka