Documentation

tickscript.deadman() function

The tickscript.deadman() function is a user-contributed function maintained by the package author and can be updated or removed at any time.

The tickscript.deadman() function detects low data throughput and writes a point with a critical status to the InfluxDB _monitoring system bucket. 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.

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

(Required) InfluxDB check data. See tickscript.defineCheck().

Data type: Record

measurement

(Required) Measurement name. Should match the queried measurement.

Data type: String

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.

Data type: Integer

id

Function that returns the InfluxDB check ID provided by the check record. Default is (r) => "${r._check_id}".

Data type: Function

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").

Data type: Function

topic

Check topic. Default is "".

Data type: String

Examples

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
  )
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" }}')

Package author and maintainer

Github: @bonitoo-io, @alespour
InfluxDB Slack: @Ales Pour


Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.