Skip to main content

Redis

Prerequisites

This node-type requires hiredis (>= 1.0.0) and redis++ (>= 1.2.3).

Implementation

The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/redis.cpp

Configuration

mode
string
Default: "key"
Enum: "key" "hash" "channel"
  • key: Get/Set of Redis strings
    • The implementation uses the Redis MSET and MGET commands.
  • hash: Hashtables using hash data-type
    • The implementation uses the Redis HMSET and HGETALL commands.
  • channel: Publish/subscribe
    • The implementation uses the Redis PUBLISH and SUBSCRIBE commands.
uri
string <uri>

A Redis connection URI in the form of: redis://<user>:<password>@<host>:<post>/<db>.

host
string
Default: "localhost"

The hostname or IP address of the Redis server.

You can also connect to Redis server with a URI:

  • tcp://[[username:]password@]host[:port][/db]
  • unix://[[username:]password@]path-to-unix-domain-socket[/db]
port
integer
Default: 6379

The port number of the Redis server to connect to.

path
string

A path of a Unix socket which should be used for the connection.

user
string
Default: "default"

The username which should be used for authentication.

See: https://redis.io/commands/auth

password
string

The password which should be used for authentication.

See: https://redis.io/commands/auth

db
integer
Default: 0

The logical database which should be used by the Redis client.

See: https://redis.io/commands/select

object
keepalive
boolean
Default: false

Enable periodic keepalive packets.

key
string
Default: "<node-name>"

The key which this node will use in the Redis keyspace.

channel
string
Default: "<node-name>"

The channel which this node will use when mode setting is channel.

notify
boolean
Default: true

Use Redis keyspace notifications to listen for new updates. This setting is only used if setting mode is set to key or hash.

object
object (Input configuration (received by VILLASnode))
vectorize
integer
Default: 1

This setting allows to send multiple samples in a single message to the destination nodes.

The value of this setting determines how many samples will be combined into one packet.

Array of Hook Object (object) or Hook Name (string) (hook_list)
builtin
boolean (Builtin hook functions)
Default: true

By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled.

object (Output configuration (sent out by VILLASnode))
{
  • "mode": "key",
  • "host": "localhost",
  • "port": 6379,
  • "path": "string",
  • "user": "default",
  • "password": "string",
  • "db": 0,
  • "timeout": {
    },
  • "keepalive": false,
  • "key": "<node-name>",
  • "channel": "<node-name>",
  • "notify": true,
  • "ssl": {
    },
  • "in": {
    },
  • "vectorize": 1,
  • "hooks": [
    ],
  • "builtin": true,
  • "out": {
    }
}

Example

node/etc/examples/nodes/redis.conf
nodes = {
redis_node = {
type = "redis"

# Only valid for mode = 'channel' and 'key'
# With mode = 'hash' we will use a simple human readable format
format = "json"

# The Redis key to be used for mode = 'key' or 'hash' (default is the node name)
key = "my_key"

# The Redis channel tp be used for mode = 'channel' (default is the node name)
channel = "my_channel"

# One of:
# - 'channel' (publish/subscribe)
# - 'key' (set/get)
# - 'hash' (hmset/hgetall)
mode = "key"

# Whether or not to use Redis keyspace event notifications to get notified about updates
notify = false

# The polling rate when notify = false
rate = 1.0

# The Redis connection URI
uri = "tcp://localhost:6379/0"

# Alternatively the connection options can be specified independently
# host = "localhost"

# Note: options here will overwrite the respective part of the URI if both are given
# port = 6379
# db = 0

# path = "/var/run/redis.sock"

# user = "guest"
# password = "guest"

# ssl = {
# enabled = true
# cacert = "/etc/ssl/certs/ca-certificates.crt"
# cacertdir = "/etc/ssl/certs"
# cert = "./my_cert.crt"
# key = "./my_key.key"
# }
}
}