tickscript.alert() 函数
tickscript.alert()
是用户贡献的函数,由包作者维护。
tickscript.alert()
识别不同严重程度级别的事件,并将它们写入 InfluxDB _monitoring
系统存储桶中的 statuses
测量。
此函数与 TICKscript alert()
相当。
函数类型签名
(
<-tables: stream[M],
check: {A with tags: E, _type: D, _check_name: C, _check_id: B},
?crit: (r: {F with _time: H, _measurement: G}) => bool,
?details: (r: {I with id: J, _check_name: C, _check_id: B}) => K,
?id: (r: {I with _check_name: C, _check_id: B}) => J,
?info: (r: {F with _time: H, _measurement: G}) => bool,
?message: (
r: {
F with
_type: D,
_time: H,
_time: time,
_source_timestamp: int,
_source_measurement: G,
_measurement: G,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
},
) => L,
?ok: (r: {F with _time: H, _measurement: G}) => bool,
?topic: string,
?warn: (r: {F with _time: H, _measurement: G}) => bool,
) => stream[{
F with
_type: D,
_time: H,
_time: time,
_source_timestamp: int,
_source_measurement: G,
_message: L,
_measurement: G,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
}] where E: Record, I: Record, M: Record
有关更多信息,请参阅函数类型签名。
参数
check
(必需)InfluxDB 检查数据。 请参阅 tickscript.defineCheck()
。
id
返回检查记录提供的 InfluxDB 检查 ID 的函数。 默认为 (r) => "${r._check_id}"
。
details
使用输入行中的数据返回 InfluxDB 检查详细信息的函数。 默认为 (r) => ""
。
message
使用输入行中的数据返回 InfluxDB 检查消息的函数。 默认为 (r) => "阈值检查:${r._check_name} 为:${r._level}"
。
crit
确定 crit
状态的谓词函数。 默认为 (r) => false
。
warn
确定 warn
状态的谓词函数。 默认为 (r) => false
。
info
确定 info
状态的谓词函数。 默认为 (r) => false
。
ok
确定 ok
状态的谓词函数。 默认为 (r) => true
。
topic
检查主题。 默认为 ""
。
tables
输入数据。 默认为管道转发数据 (<-
)。
示例
存储错误计数的警报状态
import "contrib/bonitoo-io/tickscript"
option task = {name: "Example task", every: 1m}
check = tickscript.defineCheck(id: "000000000000", name: "Errors", type: "threshold")
from(bucket: "example-bucket")
|> range(start: -task.every)
|> filter(fn: (r) => r._measurement == "errors" and r._field == "value")
|> count()
|> tickscript.alert(
check: {check with _check_id: "task/${r.service}"},
message: "task/${r.service} is ${r._level} value: ${r._value}",
crit: (r) => r._value > 30,
warn: (r) => r._value > 20,
info: (r) => r._value > 10,
)
此页面是否有帮助?
感谢您的反馈!