Redis (im_redis)
This module can retrieve data stored in a Redis server. The module issues LPOP commands using the Redis Protocol to pull data.
To examine the supported platforms, see the list of installer packages in the Available Modules chapter. |
The output counterpart, om_redis, can be used to populate the Redis server with data.
Configuration
The im_redis module accepts the following directives in addition to the common module directives. The Host directive is required.
- Host
-
This mandatory directive specifies the IP address or DNS hostname of the Redis server to connect to.
- Channel
-
Optional directive to define the Redis channel(s) to subscribe to. The default is
nxlog
. This directive can be specified multiple times within the module definition. The Command directive must be set toSUBSCRIBE
orPSUBSCRIBE
when using this directive. When the command is set toPSUBSCRIBE
, each Channel directive specifies a glob pattern that will be used by the Redis server to match available channels. For theSUBSCRIBE
command, Channel specifies the channel name without a pattern.
- Command
-
This optional directive can be used to choose between the LPOP (the default), RPOP, SUBSCRIBE, and PSUBSCRIBE commands.
- InputType
-
See the InputType directive in the list of common module directives. The default is the
Dgram
reader function, which expects a plain string. You can useBinary
to read structured data if the logs are written to Redis by another NXLog instance inBinary
format.
- LocalPort
-
This optional directive specifies the local port number of the connection. If not specified, a random high port number will be used, which may be unsuitable for firewalled network environments.
- PollInterval
-
This directive specifies how frequently the module will check for new data, in seconds. If this directive is not specified, the default is 1 second. Fractional seconds may be specified (
PollInterval 0.5
will check twice every second). The usage of this directive is mutually exclusive with the usage of theSUBSCRIBE
andPSUBSCRIBE
commands in the Command directive.
- Port
-
This specifies the port number of the Redis server. The default is port 6379.
Examples
This configuration only sets the mandatory Host directive to the Redis server IP address.
The module default will use the LPOP
command to retrieve logs from a key named nxlog
.
<Input redis>
Module im_redis
Host 192.168.1.213
</Input>
The configuration below sets the mandatory Host directive to the Redis server IP address.
It also specifies the Command and Key directives to use the RPOP
command for retrieving logs from a key named event_logs
.
<Input redis>
Module im_redis
Host 192.168.1.213
Command RPOP
Key event_logs
</Input>
The configuration below sets the mandatory Host directive to the Redis server IP address.
It also specifies the Command and multiple Channel directives for subscribing to any Redis channel names ending with _metrics
or _logs
.
<Input redis>
Module im_redis
Host 192.168.1.213
Command PSUBSCRIBE
Channel *_metrics
Channel *_logs
</Input>