package
0.195.1
Repository: https://github.com/influxcommunity/flux.git
Documentation: pkg.go.dev

# README

VictorOps Package

Use this Flux package to send alerts to VictorOps (now Splunk On-Call).

Event fields are described in REST Endpoint Integration Guide documentation topic.

victorops.event

victorops.event sends an alert to VictorOps. It has the following arguments:

NameTypeDescription
urlstringREST integration URL. Usually https://alert.victorops.com/integrations/generic/20131114/alert/$api_key/$routing_key, use valid api_key and routing_key.
monitoringToolstringMonitoring agent name. Default: ""
messageTypestringAlert behavior. Valid values: "CRITICAL", "WARNING", "INFO".
entityIDstringIncident ID. Default: "".
entityDisplayNamestringIncident summary. Default: "".
stateMessagestringVerbose message. Default: "".
timestampstringIncident timestamp. Default: now()

Example:

import "contrib/bonitoo-io/victorops"
import "influxdata/influxdb/secrets"
import "strings"

apiKey = secrets.get(key: "VICTOROPS_APIKEY")
routingKey = secrets.get(key: "VICTOROPS_ROUTING")

lastReported =
  from(bucket: "example-bucket")
    |> range(start: -1m)
    |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_idle")
    |> last()
    |> tableFind(fn: (key) => true)
    |> getRecord(idx: 0)

victorops.event(
    url: "https://alert.victorops.com/integrations/generic/20131114/alert/${apiKey}/${routingKey}",
    messageType:
        if lastReported._value < 1.0 then "CRITICAL"
        else if lastReported._value < 5.0 then "WARNING"
        else "INFO",
    entityID: "custom-alert-1",
    entityDisplayName: "Custom Alert 1",
    stateMessage: "last cpu idle alert"
)

victorops.endpoint

victorops.endpoint creates a factory function that creates a target function for pipeline |> to send events to VictorOps for each row.

NameTypeDescription
urlstringREST integration URL. Usually https://alert.victorops.com/integrations/generic/20131114/alert/$api_key/$routing_key, use valid api_key and routing_key.

The returned factory function accepts a mapFn parameter. The mapFn accepts a row and returns a record with the following events fields:

NameTypeDescription
urlstringREST integration URL. Usually https://alert.victorops.com/integrations/generic/20131114/alert/$api_key/$routing_key, use valid api_key and routing_key.
monitoringToolstringMonitoring agent name.
messageTypestringAlert behavior. Valid values: "CRITICAL", "WARNING", "INFO".
entityIDstringIncident ID.
entityDisplayNamestringIncident summary.
stateMessagestringVerbose message.
timestampstringIncident timestamp.

Example:

import "contrib/bonitoo-io/victorops"
import "influxdata/influxdb/secrets"
import "strings"

apiKey = secrets.get(key: "VICTOROPS_APIKEY")
routingKey = secrets.get(key: "VICTOROPS_ROUTING")

endpoint = victorops.endpoint(
    url: "https://alert.victorops.com/integrations/generic/20131114/alert/${apiKey}/${routingKey}",
)

from(bucket: "example-bucket")
  |> range(start: -1m)
  |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_idle")
  |> last()
  |> endpoint(mapFn: (r) => ({
      messageType:
          if r._value < 1.0 then "CRITICAL"
          else if r._value < 5.0 then "WARNING"
          else "INFO",
      entityID: "custom-alert-1",
      entityDisplayName: "Custom Alert 1",
      stateMessage: "last cpu idle alert"
    })
  )()

Contact