Back to Influxdb

bigpanda.statusFromLevel() function

content/flux/v0/stdlib/contrib/rhajek/bigpanda/statusfromlevel.md

latest2.7 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/contrib/rhajek/bigpanda/bigpanda.flux#L75-L90 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

bigpanda.statusFromLevel() converts an alert level to a BigPanda status.

BigPanda accepts one of ok, warning, or critical,.

Function type signature
js
(level: string) => string

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

level

({{< req >}}) Alert level.

Supported alert levels
Alert levelBigPanda status
critcritical
warnwarning
infook
okok
All other alert levels return a critical BigPanda status.

Examples

Convert an alert level to a BigPanda status

js
import "contrib/rhajek/bigpanda"

bigpanda.statusFromLevel(level: "crit")// Returns "critical"


Convert alert levels in a stream of tables to BigPanda statuses

Use map() to iterate over rows in a stream of tables and convert alert levels to Big Panda statuses.

js
import "contrib/rhajek/bigpanda"

data
    |> map(fn: (r) => ({r with big_panda_status: bigpanda.statusFromLevel(level: r._level)}))

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time_level
2021-01-01T00:00:00Zok
2021-01-01T00:01:00Zinfo
2021-01-01T00:02:00Zwarn
2021-01-01T00:03:00Zcrit

Output data

_level_timebig_panda_status
ok2021-01-01T00:00:00Zok
info2021-01-01T00:01:00Zok
warn2021-01-01T00:02:00Zwarning
crit2021-01-01T00:03:00Zcritical

{{% /expand %}} {{< /expand-wrapper >}}