Documentation

alerta.alert() function

alerta.alert() is a user-contributed function maintained by the package author.

alerta.alert() sends an alert to Alerta.

Function type signature
(
    apiKey: string,
    attributes: A,
    event: B,
    resource: C,
    severity: D,
    url: string,
    ?environment: E,
    ?group: F,
    ?origin: G,
    ?service: H,
    ?tags: I,
    ?text: J,
    ?timestamp: K,
    ?type: L,
    ?value: M,
) => int
  • Copy
  • Fill window

For more information, see Function type signatures.

Parameters

url

(Required) (Required) Alerta URL.

apiKey

(Required) (Required) Alerta API key.

resource

(Required) (Required) Resource associated with the alert.

event

(Required) (Required) Event name.

environment

Alerta environment. Valid values: “Production”, “Development” or empty string (default).

severity

(Required) (Required) Event severity. See Alerta severities.

service

List of affected services. Default is [].

group

Alerta event group. Default is "".

value

Event value. Default is "".

text

Alerta text description. Default is "".

tags

List of event tags. Default is [].

attributes

(Required) (Required) Alert attributes.

origin

monitoring component.

type

Event type. Default is "".

timestamp

time alert was generated. Default is now().

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(),
)
  • Copy
  • Fill window

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out: