alerts-cluster: TooHighChurnRate and TooHighSlowInsertsRate always evaluate to +Inf (regression in #7670)
Describe the bug
TooHighChurnRate and TooHighSlowInsertsRate in
deployment/docker/rules/alerts-cluster.yml cannot produce a meaningful value in a
cluster deployment. Both divide by vm_rows_inserted_total grouped by(job):
(
sum(rate(vm_new_timeseries_created_total[5m])) by(job)
/
sum(rate(vm_rows_inserted_total[5m])) by(job)
) > 0.1In cluster mode the numerators and the denominator live on different components:
| metric | vminsert | vmstorage |
|---|---|---|
vm_new_timeseries_created_total |
— | yes |
vm_slow_row_inserts_total |
— | yes |
vm_rows_inserted_total |
yes (real counts) | exposed, pinned at 0 |
by(job) therefore cannot join the numerator with vminsert's denominator. The only
matching job is vmstorage, where vmstorage still exports
vm_rows_inserted_total{type="promremotewrite"} but never increments it. The
expression reduces to N / 0:
N > 0→+Inf, and+Inf > 0.1is true → alert firesN == 0→0/0=NaN, dropped by the comparison → series disappears → alert resolves
Because the numerators are low-rate counters, the 5m rate intermittently hits exactly
zero. Each time it does, the series vanishes for one evaluation and the alert resolves,
then re-enters for: 15m and fires again. The practical result is that both alerts
flap continuously on a healthy cluster, and every firing evaluation records +Inf
rather than a real ratio.
Regression
This was introduced in #7670:
- sum(rate(vm_new_timeseries_created_total[5m]))
+ sum(rate(vm_new_timeseries_created_total[5m])) by(job)
- sum(rate(vm_rows_inserted_total[5m]))
+ sum(rate(vm_rows_inserted_total[5m])) by(job)
- sum(rate(vm_slow_row_inserts_total[5m]))
+ sum(rate(vm_slow_row_inserts_total[5m])) by(job)
- sum(rate(vm_rows_inserted_total[5m]))
+ sum(rate(vm_rows_inserted_total[5m])) by(job)Before that change the sums were unqualified, so numerator (vmstorage) and denominator
(vminsert) were aggregated cluster-wide and the ratio was correct. Adding by(job)
forced a per-job join between metrics that by design never share a job.
Single-node alerts.yml is unaffected — that PR only reformatted by (instance) to
by(instance) there, and in single-node both counters are in the same process.
Suggested fix
The vmstorage-side denominator is vm_rows_added_to_storage_total, which is already
used by the disk-estimation rules in this same file:
@@ TooHighChurnRate
sum(rate(vm_new_timeseries_created_total[5m])) by(job)
/
- sum(rate(vm_rows_inserted_total[5m])) by(job)
+ sum(rate(vm_rows_added_to_storage_total[5m])) by(job)
) > 0.1
@@ TooHighSlowInsertsRate
sum(rate(vm_slow_row_inserts_total[5m])) by(job)
/
- sum(rate(vm_rows_inserted_total[5m])) by(job)
+ sum(rate(vm_rows_added_to_storage_total[5m])) by(job)
) > 0.05If the by() grouping exists specifically to let Helm inject a cluster label, then
grouping by cluster (or dropping the grouping and injecting the label another way)
would also resolve it without changing the metric.
To Reproduce
- Deploy VictoriaMetrics in cluster mode (vminsert + vmstorage as separate jobs).
- Load the rules from
deployment/docker/rules/alerts-cluster.yml. - Evaluate the operands separately:
sum(rate(vm_rows_inserted_total[5m])) by(job)
# {job="...-vminsert"} 10815
# {job="...-vmstorage"} 0 <-- denominator used by the rule
sum(rate(vm_new_timeseries_created_total[5m])) by(job)
# {job="...-vmstorage"} 0.11 <-- vmstorage only
sum(rate(vm_slow_row_inserts_total[5m])) by(job)
# {job="...-vmstorage"} 1.11 <-- vmstorage only- Evaluate either full rule expression — it returns
+Inf, not a ratio.
With the corrected denominator the same cluster reports plausible values, peaking at roughly 0.043% for both ratios over 6h, against thresholds of 10% and 5%:
sum(rate(vm_rows_added_to_storage_total[5m])) by(job)
# {job="...-vmstorage"} 10793 (consistent with vminsert's 10815)Version
VictoriaMetrics cluster v1.153.0
alert rules from deployment/docker/rules/alerts-cluster.yml @ masterLogs
Alert state transitions, showing +Inf as the evaluated value on every firing and
NoData on every resolve (rather than the value falling back below the threshold):
Pending -> Alerting query=+Inf
Alerting -> Normal (NoData) query=-1
Normal -> Pending query=+Inf
Pending -> Alerting query=+Inf
Alerting -> Normal (NoData) query=-1Screenshots
No response
Used command-line flags
No response
Additional information
Evaluated against VM cluster v1.153.0 with 2x vminsert / 2x vmstorage, ingesting ~10.8k samples/s. Both alerts were firing continuously and flapping roughly every 1-2 hours while the actual churn and slow-insert ratios were three to four orders of magnitude below their thresholds.
Source: VictoriaMetrics/VictoriaMetrics