feat(monitoring): alert when vmagent refuses an oversized scrape

A target whose response exceeds the scrape size limit reports up == 0,
which is indistinguishable from the target being down: TargetDown and
KubeAPIDown fire and nothing names the real cause. Alert on
vm_promscrape_max_scrape_size_exceeded_errors_total so the first alert
says what is wrong. The counter has no target label, so the description
points at the vmagent targets page to find the target.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
(cherry picked from commit a17c5b2667)
Signed-off-by: cozystack-ci[bot] <274107086+cozystack-ci[bot]@users.noreply.github.com>
This commit is contained in:
IvanHunters authored and Myasnikov Daniil committed 2026-11-26 16:18:52 +00:00
1 parent 9658de6ef2
commit 0be2b2e41c
2 files changed
+38 -1

No files matched your search

@@ -0,0 +1,25 @@
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMRule
metadata:
name: alerts-vmagent
spec:
groups:
- name: vmagent
params: {}
rules:
- alert: VMAgentScrapeSizeExceeded
expr: increase(vm_promscrape_max_scrape_size_exceeded_errors_total[10m]) > 0
for: 5m
labels:
severity: warning
exported_instance: '{{ $labels.namespace }}/{{ $labels.pod }}'
service: vmagent
annotations:
summary: vmagent refuses scrape responses larger than its size limit.
description: >-
vmagent {{ $labels.namespace }}/{{ $labels.pod }} dropped scrape responses that exceed
-promscrape.maxScrapeSize or the scrape's max_scrape_size. The affected targets report
up == 0, so TargetDown or KubeAPIDown may fire for a healthy target. The counter carries
no target label: find the target on the vmagent /targets page, where the last error names
the size limit, then raise max_scrape_size on that scrape (vmagent.apiserverMaxScrapeSize
for kube-apiserver).
@@ -1,4 +1,4 @@
suite: kube-apiserver scrape size limit
suite: kube-apiserver scrape size limit and its alert
# kube-apiserver's /metrics grows with the number of resources and CRDs, and a
# full install pushes it past the global 32MB -promscrape.maxScrapeSize. vmagent
@@ -43,3 +43,15 @@ tests:
path: spec.extraArgs["promscrape.maxScrapeSize"]
value: 32MB
- it: a refused oversized scrape raises its own alert
template: templates/alerts.yaml
documentSelector:
path: metadata.name
value: alerts-vmagent
asserts:
- equal:
path: spec.groups[0].rules[0].alert
value: VMAgentScrapeSizeExceeded
- equal:
path: spec.groups[0].rules[0].expr
value: increase(vm_promscrape_max_scrape_size_exceeded_errors_total[10m]) > 0