我有以下通知规则:
curl -X POST http://influx:8086/api/v2/notificationRules -H "Authorization: Token <my token>" -H "Content-Type: application/json" -d '{
"description": "Alert on spikes detected in traffic data",
"endpointID": "1261ec31969a7d96",
"every": "15s",
"messageTemplate": "Spike detected in {{ .Name }}: Last value: {{ index .Fields \"last\" }}, Mean: {{ index .Fields \"mean\" }}, StdDev: {{ index .Fields \"stddev\" }}",
"name": "spike_detection_rule",
"orgID": "a6ce0bd763dc7a0b",
"query": {
"text": "option task = {name: \"spike_detection_task\", every: 15s}\n\nfrom(bucket: \"one_hour\")\n |> range(start: -15m)\n |> filter(fn: (r) => r._measurement == \"convs_traffic_over_time_15m\")\n |> filter(fn: (r) => r._field == \"all_data\")\n |> mean()\n |> yield(name: \"mean\")\n |> stddev()\n |> yield(name: \"stddev\")\n |> last()",
"type": "flux"
},
"status": "active",
"statusRules": [
{
"currentLevel": "OK"
},
{
"currentLevel": "CRITICAL"
}
],
"type": "http"
}
当规则任务运行时,它会成功完成。然而,http post 请求并没有因为大量涌入而出去。该端点在通知端点中定义,我在脚本中为其指定端点 ID。 “one_hour”存储桶数据如下所示:
Result: _result
Table: keys: [_start, _stop, _field, _measurement]
_start:time _stop:time _field:string _measurement:string _time:time _value:int
------------------------------ ------------------------------ ---------------------- --------------------------- ------------------------------ --------------------------
2024-09-26T14:06:07.862164087Z 2024-09-26T15:06:07.862164087Z all_data convs_traffic_over_time_15m 2024-09-26T14:06:17.272195842Z 0
Table: keys: [_start, _stop, _field, _measurement]
_start:time _stop:time _field:string _measurement:string _time:time _value:int
------------------------------ ------------------------------ ---------------------- --------------------------- ------------------------------ --------------------------
2024-09-26T14:06:07.862164087Z 2024-09-26T15:06:07.862164087Z count convs_traffic_over_time_15m 2024-09-26T14:06:17.272195842Z 0
存储桶是否缺少某些信息来触发规则任务?我的规则脚本有问题吗? influx 日志不显示有关 http post 请求的任何详细信息。 如有任何帮助,我们将不胜感激。
我没有收到任何错误。任务顺利完成