3.3 KiB
title | description | menu | weight | aliases | related | flux/v0.x/tags | introduced | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tickscript.deadman() function | The `tickscript.deadman()` function detects low data throughput and writes a point with a critical status to the InfluxDB `_monitoring` system bucket. |
|
302 |
|
|
|
0.111.0 |
The tickscript.deadman()
function detects low data throughput and writes a point
with a critical status to the InfluxDB [_monitoring
system bucket](/{{< latest "influxdb" >}}/reference/internals/system-buckets/).
For each input table containing a number of rows less than or equal to the specified
threshold, the function assigns a crit
value to the _level
column.
This function is comparable to the [Kapacitor AlertNode deadman](/{{< latest "kapacitor" >}}/nodes/alert_node/#deadman).
import "contrib/bonitoo-io/tickscript"
tickscript.deadman(
check: {},
measurement: "example-measurement",
threshold: 0,
id: (r) => "${r._check_id}",
message: (r) => "Deadman Check: ${r._check_name} is: " + (if r.dead then "dead" else "alive"),
topic: "",
)
Parameters
check
({{< req >}})
InfluxDB check data.
See tickscript.defineCheck()
.
measurement
({{< req >}}) Measurement name. Should match the queried measurement.
threshold
Count threshold.
The function assigns a crit
status to input tables with a number of rows less
than or equal to the threshold.
Default is 0
.
id
Function that returns the InfluxDB check ID provided by the check
record.
Default is (r) => "${r._check_id}"
.
message
Function that returns the InfluxDB check message using data from input rows.
Default is (r) => "Deadman Check: ${r._check_name} is: " + (if r.dead then "dead" else "alive")
.
topic
Check topic.
Default is ""
.
tables
Input data.
Default is piped-forward data (<-
).
Examples
{{< code-tabs-wrapper >}} {{% code-tabs %}} Flux TICKscript {{% /code-tabs %}} {{% code-tab-content %}}
import "contrib/bonitoo-io/tickscript"
option task = {name: "Example task", every: 1m}
from(bucket: "example-bucket")
|> range(start: -task.every)
|> filter(fn: (r) => r._measurement == "pulse" and r._field == "value")
|> tickscript.deadman(
check: tickscript.defineCheck(id: "000000000000", name: "task/${r.service}"),
measurement: "pulse",
threshold: 2,
)
{{% /code-tab-content %}} {{% code-tab-content %}}
data = batch
|query('SELECT value from pulse')
.every(1m)
data
|deadman(2.0, 1m)
.id('kapacitor/{{ index .Tags "service" }}')
.message('{{ .ID }} is {{ .Level }} value:{{ index .Fields "value" }}')
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}