rsyslog/tests/stats-json-prometheus.sh
Rainer Gerhards 2abe06bada
action: add batchesprocessed pstats counter
Why:
Track batch usage in pstats so operators can infer average batch size.

Impact:
Action statistics now include batchesprocessed and docs note it.

Before/After:
Before: action pstats only reported message totals.
After: action pstats reports processed and batchesprocessed.

Technical Overview:
- Add a batchesprocessed stats counter to action state.
- Register the counter with the core.action stats object.
- Increment it for direct actions and per processed batch.
- Document the counter in rsyslog_statistic_counter.rst.

closes https://github.com/rsyslog/rsyslog/issues/503

With the help of AI-Agents: ChatGPT
2026-01-24 11:32:54 +01:00

32 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# added 2016-03-30 by singh.janmejay
# This file is part of the rsyslog project, released under ASL 2.0
echo ===============================================================================
echo \[stats-json-es.sh\]: test for verifying stats are reported correctly json-elasticsearch format
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
ruleset(name="stats") {
action(type="omfile" file="'${RSYSLOG_DYNNAME}'.out.stats.log")
}
module(load="../plugins/impstats/.libs/impstats" interval="1" severity="7" resetCounters="on" Ruleset="stats" bracketing="on" format="prometheus")
if ($msg == "this condition will never match") then {
action(name="an_action_that_is_never_called" type="omfile" file=`echo $RSYSLOG_OUT_LOG`)
}
'
startup
injectmsg_file $srcdir/testsuites/dynstats_input_1
wait_queueempty
wait_for_stats_flush ${RSYSLOG_DYNNAME}.out.stats.log
echo doing shutdown
shutdown_when_empty
echo wait on shutdown
wait_shutdown
custom_content_check 'an_action_that_is_never_called_processed_total 0' "${RSYSLOG_DYNNAME}.out.stats.log"
custom_content_check 'an_action_that_is_never_called_batchesprocessed_total 0' "${RSYSLOG_DYNNAME}.out.stats.log"
custom_content_check 'an_action_that_is_never_called_failed_total 0' "${RSYSLOG_DYNNAME}.out.stats.log"
custom_assert_content_missing '@cee' "${RSYSLOG_DYNNAME}.out.stats.log"
exit_test