opsgenie.endpoint() function

The opsgenie.endpoint() function is a user-contributed function maintained by the package author and can be updated or removed at any time.

The opsgenie.endpoint() function sends an alert message to Opsgenie using data from table rows.

*Function type: Output*

  1. import "contrib/sranka/opsgenie"
  2. opsgenie.endpoint(
  3. url: "https://api.opsgenie.com/v2/alerts",
  4. apiKey: "YoUrSup3R5ecR37AuThK3y",
  5. entity: "example-entity"
  6. )

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*

entity

Alert entity used to specify the alert domain.

*Data type: String*

Usage

opsgenie.endpoint is a factory function that outputs another function. The output function requires a mapFn parameter.

mapFn

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

*Data type: Function*

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

  • message
  • alias
  • description
  • priority
  • responders
  • tags
  • actions
  • details
  • visibleTo

For more information, see opsgenie.sendAlert().

Examples

Send critical statuses to Opsgenie
  1. import "influxdata/influxdb/secrets"
  2. import "contrib/sranka/opsgenie"
  3. apiKey = secrets.get(key: "OPSGENIE_APIKEY")
  4. endpoint = opsgenie.endpoint(apiKey: apiKey)
  5. crit_statuses = from(bucket: "example-bucket")
  6. |> range(start: -1m)
  7. |> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
  8. crit_statuses
  9. |> endpoint(mapFn: (r) => ({
  10. message: "Great Scott!- Disk usage is: ${r.status}.",
  11. alias: "disk-usage-${r.status}",
  12. description: "",
  13. priority: "P3",
  14. responders: ["user:john@example.com", "team:itcrowd"],
  15. tags: [],
  16. entity: "my-lab",
  17. actions: [],
  18. details: "{}",
  19. visibleTo: []
  20. })
  21. )()

Package author and maintainer

Github: @sranka
InfluxDB Slack: @sranka