tickscript.deadman() 函数
tickscript.deadman() 是一个由 包作者 维护的用户贡献函数。
tickscript.deadman() 检测低数据吞吐量,并将一个具有关键状态的点写入 InfluxDB _monitoring 系统桶。
对于每个输入表,包含的行数小于或等于指定阈值,函数将为 _level 列分配一个 crit 值。
该函数可与 Kapacitor AlertNode deadman 相媲美。
函数类型签名
(
<-tables: stream[M],
check: {A with tags: E, _type: D, _check_name: C, _check_id: B},
measurement: string,
?id: (r: {F with _check_name: C, _check_id: B}) => G,
?message: (
r: {
H with
dead: bool,
_type: D,
_time: J,
_time: time,
_source_timestamp: int,
_source_measurement: I,
_measurement: I,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
},
) => K,
?threshold: L,
?topic: string,
) => stream[{
H with
dead: bool,
_type: D,
_time: J,
_time: time,
_source_timestamp: int,
_source_measurement: I,
_message: K,
_measurement: I,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
}] where E: Record, F: Record, L: Comparable + Equatable, M: Record
有关更多信息,请参见 Function type signatures。
参数
检查
(必填)
InfluxDB 检查数据。参见 tickscript.defineCheck()。
测量
(必需) 测量名称。应与查询的测量匹配。
阈值
计数阈值。默认值是 0。
该函数将crit状态分配给行数小于或等于阈值的输入表。
身份标识
返回由检查记录提供的 InfluxDB 检查 ID 的函数。默认值是 (r) => "${r._check_id}"。
消息
该函数使用输入行中的数据返回InfluxDB检查消息。 默认值是 (r) => "Deadman Check: ${r._check_name} is: " + (if r.dead then "dead" else "alive")。
主题
检查主题。默认值是 ""。
表格
输入数据。默认是管道转发数据 (<-).
示例
检测何时一系列停止报告
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,
)