Documentation

alerta.alert() function

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

The alerta.alert() function sends an alert to Alerta.

import "contrib/bonitoo-io/alerta"

alerta.alert(
  url: "https://alerta.io:8080/alert",
  apiKey: "0Xx00xxXx00Xxx0x0X",
  resource: "example-resource",
  event: "Example event",
  environment: "",
  severity: "critical",
  service: [],
  group: "",
  value: "",
  text: "",
  tags: [],
  attributes: {},
  origin: "InfluxDB",
  type: "",
  timestamp: now(),
)

Parameters

url

(Required) Alerta URL.

Data type: String

apiKey

(Required) Alerta API key.

Data type: String

resource

(Required) Resource associated with the alert.

Data type: String

event

(Required) Event name.

Data type: String

environment

Alert environment. Default is "".

Data type: String

Valid values:

  • ""
  • "Production"
  • "Development"

severity

(Required) Event severity. See Alerta severities.

Data type: String

service

List of affected services. Default is [].

Data type: Array of strings

group

Alerta event group. Default is "".

Data type: String

value

Event value. Default is "".

Data type: String

text

Alert text description. Default is "".

Data type: String

tags

List of event tags. Default is [].

Data type: Array of strings

attributes

(Required) Alert attributes.

Data type: Record

origin

Alert origin. Default is "InfluxDB".

Data type: String

type

Event type. Default is "".

Data type: String

timestamp

time alert was generated. Default is now().

Data type: Time

Examples

Send the last reported value and status to Alerta
import "contrib/bonitoo-io/alerta"
import "influxdata/influxdb/secrets"

apiKey = secrets.get(key: "ALERTA_API_KEY")

lastReported =
  from(bucket: "example-bucket")
    |> range(start: -1m)
    |> filter(fn: (r) =>
      r._measurement == "example-measurement" and
      r._field == "level"
    )
    |> last()
    |> findRecord(fn: (key) => true, idx: 0)

severity = if lastReported._value > 50 then "warning" else "ok"

alerta.alert(
  url: "https://alerta.io:8080/alert",
  apiKey: apiKey,
  resource: "example-resource",
  event: "Example event",
  environment: "Production",
  severity: severity,
  service: ["example-service"],
  group: "example-group",
  value: string(v: lastReported._value),
  text: "Service is ${severity}. The last reported value was ${string(v: lastReported._value)}.",
  tags: ["ex1", "ex2"],
  attributes: {},
  origin: "InfluxDB",
  type: "exampleAlertType",
  timestamp: now(),
)

Package author and maintainer

Github: @alespour, @bonitoo-io
InfluxDB Slack: @Ales Pour


Select your region

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.