write_redis plugin¶
| Plugin name | write_redis |
| Type | write |
| Callbacks | config, write |
| Status | experimental |
| Since | 5.0 |
| Copyright | 2010 Florian octo Forster |
| License | MIT License |
| Configuration | collectd.conf(5) |
The Write Redis plugin stores values in Redis, a “data structures server”.
The plugin is currently experimental. Different ways of structuring the data is being discussed at Plugin-Write-Redis-Design – please feel free to add your ideas and experience.
Synopsis¶
This will register a writer by the name
write_redis/localhost
Redis config¶
Virtual memory¶
Per default Redis keeps all data in memory. This means that as more and more data is written to Redis, your system will run out of memory. Once all memory is consumed, the system will start swapping and become unusable. It is therefore absolutely necessary that you use the virtual memory option that was added in Redis 2.0. You can start with the following example config when setting up virtual memory.
# Enable virtual memory and specify swap file location
vm-enabled yes
vm-swap-file /var/lib/redis/redis.swap
# Use 1 Gbyte of memory
vm-max-memory 1073741824
# Create a 128 Gbyte swap file
vm-page-size 1024
vm-pages 134217728
# Number of I/O threads
vm-max-threads 4
Dependencies¶
- credis, C library implementing the redis protocol.
See also¶
- Redis project page on Google Project Hosting.
- Credis project page on Google Project Hosting.
- Plugin-Redis
Configuration¶
Configuration options · from collectd.conf(5)
See this section in the full configuration reference
The write_redis plugin submits values to Redis, a data structure server.
Synopsis:
<Plugin "write_redis">
<Node "example">
Host "localhost"
Port "6379"
Timeout 1000
Prefix "collectd/"
Database 1
MaxSetSize -1
MaxSetDuration -1
StoreRates true
</Node>
</Plugin>
Values are submitted to Sorted Sets, using the metric name as the key, and the timestamp as the score. Retrieving a date range can then be done using the ZRANGEBYSCORE Redis command. Additionally, all the identifiers of these Sorted Sets are kept in a Set called collectd/values (or ${prefix}/values if the Prefix option was specified) and can be retrieved using the SMEMBERS Redis command. You can specify the database to use with the Database parameter (default is 0). See http://redis.io/commands#sorted_set and http://redis.io/commands#set for details.
The information shown in the synopsis above is the default configuration which is used by the plugin if no configuration is present.
The plugin can send values to multiple instances of Redis by specifying one Node block for each instance. Within the Node blocks, the following options are available:
- Node Nodename
- The Node block identifies a new Redis node, that is a new Redis instance running on a specified host and port. The node name is a canonical identifier which is used as plugin instance. It is limited to 51E<nbsp>characters in length.
- Host Hostname
- The Host option is the hostname or IP-address where the Redis instance is running on.
- Port Port
- The Port option is the TCP port on which the Redis instance accepts connections. Either a service name of a port number may be given. Please note that numerical port numbers must be given as a string, too.
- Timeout Milliseconds
- The Timeout option sets the socket connection timeout, in milliseconds.
- Prefix Prefix
- Prefix used when constructing the name of the Sorted Sets and the Set containing all metrics. Defaults to
collectd/, so metrics will have names likecollectd/cpu-0/cpu-user. When setting this to something different, it is recommended but not required to include a trailing slash in Prefix. - Database Index
- This index selects the redis database to use for writing operations. Defaults to
0. - MaxSetSize Items
- The MaxSetSize option limits the number of items that the Sorted Sets can hold. Negative values for Items sets no limit, which is the default behavior.
- MaxSetDuration Seconds
- The MaxSetDuration option limits the duration of items that the Sorted Sets can hold. Negative values for Items sets no duration, which is the default behavior.
- StoreRates true|false
- If set to true (the default), convert counter values to rates. If set to false counter values are stored as is, i.e. as an increasing integer number.