count_over_time 函数返回数值(Vector)。mysql 任务中包含 error 关键字的日志条数。count_over_time({job="mysql"} |= "error" [5m])$A > 50 (5分钟内错误日志超过 50 条)$A > 10 (5分钟内错误日志超过 10 条)$A < 5,避免在阈值附近震荡。${label_name} 变量替换。count_over_time({job="mysql"} |= "recovered" [5m])。count_over_time({job="ingress"} |= "error-code-500" [5m]) / count_over_time({job="ingress"} [5m]) * 100 > 5> 5 的条件)时,判定恢复。rate({job="node-logs"} [1m])instance="host-1")在之前的周期中存在,但在当前及连续 N 个周期中查不到数据,则触发“数据缺失”告警。
{{- if eq $status "firing" }}
error log count: {{ $value | printf "%.3f" }}
{{- range $x := $relates.R1}}
Loki log time: {{(nanoTime $x.Fields.__time__ 8).Format "2006-01-02T15:04:05Z07:00"}}
Loki Log line: {{$x.Fields.__log__}}
{{- end}}
{{- end}}