mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
a2ded58600
According to Ruler specification, only labels returned within time series should be available for use in annotations. For long time, vmalert didn't respect this rule. And in PR https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2403 this was fixed for the sake of compatibility. However, this resulted into users confusion, as they expected all configured and extra labels to be available - https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3013 This fix allows to use extra labels in Annotations. But in the case of conflicts the original labels (extracted from time series) are preferred. Signed-off-by: hagen1778 <roman@victoriametrics.com> Signed-off-by: hagen1778 <roman@victoriametrics.com>
62 lines
No EOL
2 KiB
Text
62 lines
No EOL
2 KiB
Text
groups:
|
|
- name: TestGroup
|
|
interval: 5s
|
|
concurrency: 2
|
|
limit: 1000
|
|
headers:
|
|
- "MyHeader: foo"
|
|
params:
|
|
denyPartialResponse: ["true"]
|
|
rules:
|
|
- alert: Conns
|
|
expr: vm_tcplistener_conns > 0
|
|
for: 3m
|
|
debug: true
|
|
annotations:
|
|
labels: "Available labels: {{ $labels }}"
|
|
summary: Too high connection number for {{ $labels.instance }}
|
|
{{ with printf "sum(vm_tcplistener_conns{instance=%q})" .Labels.instance | query }}
|
|
{{ . | first | value }}
|
|
{{ end }}
|
|
description: "It is {{ $value }} connections for {{$labels.instance}}"
|
|
- alert: ExampleAlertAlwaysFiring
|
|
expr: sum by(job)
|
|
(up == 1)
|
|
labels:
|
|
job: '{{ $labels.job }}'
|
|
dynamic: '{{ $x := query "up" | first | value }}{{ if eq 1.0 $x }}one{{ else }}unknown{{ end }}'
|
|
annotations:
|
|
description: Job {{ $labels.job }} is up!
|
|
external: cluster-{{ $externalLabels.cluster }}; replica-{{ $externalLabels.replica }}
|
|
summary: All instances up {{ range query "up" }}
|
|
{{ . | label "instance" }}
|
|
{{ end }}
|
|
- record: handler:requests:rate5m
|
|
expr: sum(rate(prometheus_http_requests_total[5m])) by (handler)
|
|
labels:
|
|
recording: true
|
|
- record: code:requests:rate5m
|
|
expr: sum(rate(promhttp_metric_handler_requests_total[5m])) by (code)
|
|
labels:
|
|
env: dev
|
|
recording: true
|
|
- record: code:requests:rate5m
|
|
expr: sum(rate(promhttp_metric_handler_requests_total[5m])) by (code)
|
|
labels:
|
|
env: staging
|
|
recording: true
|
|
- record: successful_requests:ratio_rate5m
|
|
labels:
|
|
recording: true
|
|
expr: |2
|
|
sum(code:requests:rate5m{code="200"})
|
|
/
|
|
sum(code:requests:rate5m)
|
|
- record: code:requests:slo
|
|
labels:
|
|
recording: true
|
|
expr: 0.95
|
|
- record: time:current
|
|
labels:
|
|
recording: true
|
|
expr: time() |