rsyslog/tests/impstats-push-to-vm.sh
Rainer Gerhards c253fc36cc
impstats: add VictoriaMetrics push via Remote Write
Adds first-class integration with VictoriaMetrics to simplify ops
dashboards and move toward project-supported telemetry without
sidecar collectors.

Impact: New optional feature (off by default). No behavior change
unless configured via push.* parameters.

Before: impstats could only log locally or emit text formats.
After: impstats can push counters to Prometheus-compatible endpoints.

Technical: implement a native Prometheus Remote Write path in
impstats, encoding counters to protobuf and compressing with snappy
over HTTP via libcurl. Replace interim text parsing with a new
statsobj v14 API (GetAllCounters) that iterates raw uint64 counters,
keeps atomic reads for IntCtr and best-effort reads for Int. Add
metric builder with Prometheus-compliant sanitization and the naming
pattern <origin>_<name>_<counter>_total. Provide TLS knobs (CA, mTLS,
insecureSkipVerify), static/dynamic labels, timeout, and optional
batching by bytes/series. Build is gated behind
--enable-impstats-push with protobuf-c/snappy/curl checks. Ship docs,
basic/VM integration tests, and a GitHub Actions workflow using a
VictoriaMetrics service; TSAN jobs disable impstats-push.

Configuration: push.url, push.labels, push.timeout.ms,
push.label.{instance,job,origin,name}, push.tls.{cafile,certfile,
keyfile,insecureSkipVerify}, push.batch.{maxBytes,maxSeries}.

With the Help of AI Agents: ChatGPT codex 5.2
2026-02-06 16:02:08 +01:00

37 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Test for impstats push support - basic compilation and load test
# This file is part of the rsyslog project, released under ASL 2.0
. ${srcdir:=.}/diag.sh init
skip_platform "SunOS" "Solaris has limitations"
generate_conf
add_conf '
module(load="../plugins/impstats/.libs/impstats"
interval="1"
format="prometheus"
log.file="'$RSYSLOG_OUT_LOG'"
resetCounters="off"
# Push config (will fail to connect but that is OK for this test)
push.url="http://localhost:8428/api/v1/write"
push.labels=["test=impstats-push", "instance=prototype"]
push.timeout.ms="1000"
)
action(type="omfile" file=`echo $RSYSLOG2_OUT_LOG`)
'
startup
# Wait for impstats to generate at least one stats interval
# (interval is 1 second, wait 2 seconds to ensure stats are emitted)
sleep 2
shutdown_when_empty
wait_shutdown
# Verify stats were generated locally (push will fail but that's OK - no endpoint running)
content_check "resource-usage" "$RSYSLOG_OUT_LOG"
content_check "origin" "$RSYSLOG_OUT_LOG"
exit_test