feat(alloy): make scrape/housekeeping interval configurable #68

Merged
fauno merged 1 commits from configurable-scrape-interval into main 2026-12-01 22:35:37 +00:00
Owner

cadvisor's housekeeping interval defaults to 1s regardless of the Prometheus scrape interval (120s), so container stats were being collected more often than needed.

Alloy 1.22 added a housekeeping_interval argument to prometheus.exporter.cadvisor. This PR sets it explicitly to match the default scrape interval instead of relying on the 1s default, lowering Alloy's CPU usage.

Two new env vars:

  • PROMETHEUS_SCRAPE_INTERVAL (default 120s, unchanged): how often metrics are sent to Prometheus.
  • CADVISOR_HOUSEKEEPING_INTERVAL (default 60s): how often cadvisor refreshes its container stats.

Both are independent timers. Keep the cadvisor housekeeping interval below the scrape interval, so a new sample is collected before every scrape. Otherwise, some scrapes can read the same cached value twice.

cadvisor's housekeeping interval defaults to 1s regardless of the Prometheus scrape interval (120s), so container stats were being collected more often than needed. Alloy 1.22 added a `housekeeping_interval` argument to `prometheus.exporter.cadvisor`. This PR sets it explicitly to match the default scrape interval instead of relying on the 1s default, lowering Alloy's CPU usage. Two new env vars: - `PROMETHEUS_SCRAPE_INTERVAL` (default 120s, unchanged): how often metrics are sent to Prometheus. - `CADVISOR_HOUSEKEEPING_INTERVAL` (default 60s): how often cadvisor refreshes its container stats. Both are independent timers. Keep the cadvisor housekeeping interval below the scrape interval, so a new sample is collected before every scrape. Otherwise, some scrapes can read the same cached value twice.
dannygroenewegen added 1 commit 2026-12-01 14:21:29 +00:00
Alloy v1.22.0 added housekeeping_interval to the cadvisor exporter,
which previously defaulted to 1s regardless of scrape interval,
wasting CPU. Make it configurable via CADVISOR_HOUSEKEEPING_INTERVAL
(default 60s), and the Prometheus scrape interval via
PROMETHEUS_SCRAPE_INTERVAL (default 120s, unchanged).
CODEOWNERS rules requested review from monitoring-ng-maintainers 2026-12-01 14:21:29 +00:00
p4u1 approved these changes 2026-12-01 16:07:26 +00:00
Owner

Nice 😍

Nice 😍
fauno approved these changes 2026-12-01 22:28:14 +00:00
fauno merged commit 250824d0fe into main 2026-12-01 22:35:37 +00:00
fauno deleted branch configurable-scrape-interval 2026-12-01 22:35:37 +00:00
Sign in to join this conversation.