impstats: Generate Periodic Statistics of Internal Counters

Module Name:

impstats

Author:

Rainer Gerhards <rgerhards@adiscon.com>

Purpose

This module provides periodic output of rsyslog internal counters.

The set of available counters will be output as a set of syslog messages. This output is periodic, with the interval being configurable (default is 5 minutes). Be sure that your configuration records the counter messages (default is syslog.=info). Besides logging to the regular syslog stream, the module can also be configured to write statistics data into a (local) file.

When logging to the regular syslog stream, impstats records are emitted just like regular log messages. As such, counters increase when processing these messages. This must be taken into consideration when testing and troubleshooting.

Note that loading this module has some impact on rsyslog performance. Depending on settings, this impact may be noticeable for high-load environments, but in general the overhead is pretty light.

Note that there is a rsyslog statistics online analyzer available. It can be given a impstats-generated file and will return problems it detects. Note that the analyzer cannot replace a human in getting things right, but it is expected to be a good aid in starting to understand and gain information from the pstats logs.

The rsyslog website has an overview of available rsyslog statistic counters. When browsing this page, please be sure to take note of which rsyslog version is required to provide a specific counter. Counters are continuously being added, and older versions do not support everything.

Notable Features

Configuration Parameters

The configuration parameters for this module are designed for tailoring the method and process for outputting the rsyslog statistics to file.

Note

Parameter names are case-insensitive; camelCase is recommended for improved readability.

Note

This module supports module parameters, only.

Module Parameters

Parameter

Summary

interval

Configures how often, in seconds, impstats emits statistics messages.

facility

Selects the numeric syslog facility value used for generated statistics messages.

severity

Sets the syslog severity value that impstats assigns to emitted messages.

resetcounters

Controls whether impstats resets counters after emitting them so they show deltas.

format

Specifies which output format impstats uses for emitted statistics records.

log.syslog

Enables or disables sending statistics to the regular syslog stream.

log.file

Writes impstats statistics records to the specified local file in addition to other outputs.

ruleset

Binds impstats-generated messages to the specified ruleset for further processing.

bracketing

Adds BEGIN and END marker messages so post-processing can group statistics blocks.

Statistic Counter

The impstats plugin gathers some internal statistics. They have different names depending on the actual statistics. Obviously, they do not relate to the plugin itself but rather to a broader object – most notably the rsyslog process itself. The “resource-usage” counter maintains process statistics. They base on the getrusage() system call. The counters are named like getrusage returned data members. So for details, looking them up in “man getrusage” is highly recommended, especially as value may be different depending on the platform. A getrusage() call is done immediately before the counter is emitted. The following individual counters are maintained:

  • utime - this is the user time in microseconds (thus the timeval structure combined)

  • stime - again, time given in microseconds

  • maxrss

  • minflt

  • majflt

  • inblock

  • outblock

  • nvcsw

  • nivcsw

  • openfiles - number of file handles used by rsyslog; includes actual files, sockets and others

Caveats/Known Bugs

  • This module MUST be loaded right at the top of rsyslog.conf, otherwise stats may not get turned on in all places.

Examples

Load module, send stats data to syslog stream

This activates the module and records messages to /var/log/rsyslog-stats in 10 minute intervals:

module(load="impstats"
       interval="600"
       severity="7")

# to actually gather the data:
syslog=debug/var/log/rsyslog-stats

Load module, send stats data to local file

Here, the default interval of 5 minutes is used. However, this time, stats data is NOT emitted to the syslog stream but to a local file instead.

module(load="impstats"
       interval="600"
       severity="7"
       logSyslog="off"
       # need to turn log stream logging off!
       logFile="/path/to/local/stats.log")

Load module, send stats data to local file and syslog stream

Here we log to both the regular syslog log stream as well as a file. Within the log stream, we forward the data records to another server:

module(load="impstats"
       interval="600"
       severity="7"
       logFile="/path/to/local/stats.log")

syslog=debug@central.example.net

Explanation of output

Example output for illustration:

Sep 17 11:43:49 localhost rsyslogd-pstats: imuxsock: submitted=16
Sep 17 11:43:49 localhost rsyslogd-pstats: main Q: size=1 enqueued=2403 full=0 maxqsize=2

Explanation:

All objects are shown in the results with a separate counter, one object per line.

Line 1: shows details for

  • imuxsock, an object

  • submitted=16, a counter showing that 16 messages were received by the imuxsock object.

Line 2: shows details for the main queue:

  • main Q, an object

  • size, messages in the queue

  • enqueued, all received messages thus far

  • full, how often was the queue was full

  • maxqsize, the maximum amount of messages that have passed through the queue since rsyslog was started

See Also


Support: rsyslog Assistant | GitHub Discussions | GitHub Issues: rsyslog source project

Contributing: Source & docs: rsyslog source project

© 2008–2025 Rainer Gerhards and others. Licensed under the Apache License 2.0.