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

# README

Zenoss Package

Use this Flux package to send events to Zenoss.

Event fields are described in Event Fields Zenoss documentation topic.

zenoss.event

zenoss.event sends an event to Zenos. It has the following arguments:

NameTypeDescriptionDefault value
urlstringZenoss events endpoint URL.
usernamestringHTTP BASIC authentication username."" (no auth)
passwordstringHTTP BASIC authentication username."" (no auth)
apiKeystringZenoss Cloud API key."" (no key)
actionstringRouter name."EventsRouter"
methodstringRouter method"add_event"
typestringEvent type"rpc"
tidintTemporary request transaction ID1
summarystringEvent summary""
devicestringRelated device""
componentstringRelated component""
severitystringEvent severity
eventClassstringEvent class""
eventClassKeystringEvent class key""
collectorstringCollector
messagestringRelated message

Supported severity values are: "Critical", "Warning", "Info", "Clear".

Example:

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

username = secrets.get(key: "ZENOSS_USERNAME")
password = secrets.get(key: "ZENOSS_PASSWORD")

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)

zenoss.event(
    url: "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router",
    username: username,
    username: password,
    device: lastReported.host,
    component: "CPU",
    eventClass: "/App,
    severity:
        if lastReported._value < 1.0 then "Critical"
        else if lastReported._value < 5.0 then "Warning"
        else "Info",
)

zenoss.endpoint

zenoss.endpoint creates a factory function that creates a target function for pipeline |> to send event to Zenoss for each row.

NameTypeDescriptionDefault value
urlstringZenoss events endpoint URL.
usernamestringHTTP BASIC authentication username.
passwordstringHTTP BASIC authentication username.
apiKeystringZenoss Cloud API key."" (no key)
actionstringRouter name."EventsRouter"
methodstringRouter method"add_event"
typestringEvent type"rpc"
tidintTemporary request transaction ID1

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

NameTypeDescription
summarystringEvent summary
devicestringRelated device
componentstringRelated component
severitystringEvent severity
eventClassstringEvent class
eventClassKeystringEvent class key
collectorstringCollector
messagestringRelated message

Example:

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

username = secrets.get(key: "ZENOSS_USERNAME")
password = secrets.get(key: "ZENOSS_PASSWORD")

endpoint = zenoss.endpoint(
    url: "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router",
    username: username,
    username: password
)

from(bucket: "example-bucket")
  |> range(start: -1m)
  |> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_idle")
  |> last()
  |> endpoint(mapFn: (r) => ({
      device: lastReported.host,
      component: "CPU",
      eventClass: "/App,
      severity:
          if r._value < 1.0 then "Critical"
          else if r._value < 5.0 then "Warning"
          else "Info",
    })
  )()

Contact