Return to
Portfolio

109.26. 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.

The output counterpart, om_redis, can be used to populate the Redis server with data.

109.26.1. 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

This optional directive defines the Redis channel this module will subscribe to. This directive can be specified multiple times within the module definition. When the Command directive is set to PSUBSCRIBE, each Channel directive specifies a glob that will be matched by the Redis server against its available channels. For the SUBSCRIBE command, Channel specifies the channel names which will be matched as is (no globbing). The usage of this directive is mutually exclusive with the usage of the LPOP and RPOP commands in the Command directive.

Command

This optional directive can be used to choose between the LPOP, RPOP, SUBSCRIBE and PSUBSCRIBE commands. The default Command is set to LPOP, if this directive is not specified.

InputType

See the InputType directive in the list of common module directives. The default is the Dgram reader function, which expects a plain string. To preserve structured data Binary can be used, but it must also be set on the other end.

Key

This specifies the Key used by the LPOP command. The default is nxlog. The usage of this directive is mutually exclusive with the usage of the SUBSCRIBE and PSUBSCRIBE commands in the Command directive.

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 the SUBSCRIBE and PSUBSCRIBE commands in the Command directive.

Port

This specifies the port number of the Redis server. The default is port 6379.

109.26.2. Fields

The following fields are used by im_redis.

$raw_event (type: string)

The received string.

$Channel (type: string)

For the SUBSCRIBE and PSUBSCRIBE commands, this is the Redis Pub/Sub channel from which the message was received. Otherwise, it is undefined.