Prometheus Valkey & Redis Metrics Exporter

Prometheus exporter for Valkey metrics (Redis-compatible).
Supports Valkey 7.x, 8.x, 9.x (and Redis)
____ _ ___ ____ _____
/ ___|| |_ ___ _ __ |_ _/ ___| ____|
\___ \| __/ _ \| '_ \ | | | | _|
___) | || (_) | |_) | | | |___| |___
|____/ \__\___/| .__/ |___\____|_____|
|_|
Stop ICE's Attack On Our Communities!

Building and running the exporter
Build and run locally
git clone https://github.com/oliver006/redis_exporter.git
cd redis_exporter
go build .
./redis_exporter --version
Pre-build binaries
For pre-built binaries please take a look at the releases.
Basic Prometheus Configuration
Add a block to the scrape_configs of your prometheus.yml config file:
scrape_configs:
- job_name: redis_exporter
static_configs:
- targets: ['<<REDIS-EXPORTER-HOSTNAME>>:9121']
and adjust the host name accordingly.
Kubernetes SD configurations
To have instances in the drop-down as human readable names rather than IPs, it is suggested to use instance relabelling.
For example, if the metrics are being scraped via the pod role, one could add:
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: instance
regex: (.*redis.*)
as a relabel config to the corresponding scrape config. As per the regex value, only pods with “redis” in their name will be relabelled as such.
Similar approaches can be taken with other role types depending on how scrape targets are retrieved.
Prometheus Configuration to Scrape Multiple Redis Hosts
The Prometheus docs have a very informative article on how multi-target exporters are intended to work.
Run the exporter with the command line flag --redis.addr= so it won’t try to access the local instance every time the /metrics endpoint is scraped. Using below config instead of the /metric endpoint the /scrape endpoint will be used by prometheus. As an example the first target will be queried with this web request:
http://exporterhost:9121/scrape?target=first-redis-host:6379
scrape_configs:
## config for the multiple Redis targets that the exporter will scrape
- job_name: 'redis_exporter_targets'
static_configs:
- targets:
- redis://first-redis-host:6379
- redis://second-redis-host:6379
- redis://second-redis-host:6380
- redis://second-redis-host:6381
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: <<REDIS-EXPORTER-HOSTNAME>>:9121
## config for scraping the exporter itself
- job_name: 'redis_exporter'
static_configs:
- targets:
- <<REDIS-EXPORTER-HOSTNAME>>:9121
The Redis instances are listed under targets, the Redis exporter hostname is configured via the last relabel_config rule.
If authentication is needed for the Redis instances, --redis.password applies the same password to every target.
--redis.user sets the default username, and a username in the target overrides it: with --redis.user=alice and the target
redis://bob@server:6379, the exporter connects as bob.
For per-target passwords, leave --redis.password empty and set --redis.password-file: it maps target URIs to passwords and is
used by /scrape too. A password-file key must match the target exactly as the exporter looks it up: redis:// is added when the
target has no scheme, valkey:// is changed to redis:// (and valkeys:// to rediss://), and the key contains a username only
if one is configured, in the target or via --redis.user. For example, valkey://bob@server:6379 is looked up as
redis://bob@server:6379, and server:6379 without a username as redis://server:6379
(see Authenticating with Redis).
For TLS targets whose certificate hostname differs from the target address, pass tls_server_name to /scrape (for example via
the Prometheus relabel target __param_tls_server_name).
/scrape also takes check-keys, check-single-keys, check-streams, check-single-streams and count-keys to override
those options per target. Each of them is accepted with underscores too (check_single_keys, …), so it can be set from service
discovery with a relabel target such as __param_check_single_keys (Prometheus label names can’t contain -).
You can also use a json file to supply multiple targets by using file_sd_configs like so:
scrape_configs:
- job_name: 'redis_exporter_targets'
file_sd_configs:
- files:
- targets-redis-instances.json
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: <<REDIS-EXPORTER-HOSTNAME>>:9121
## config for scraping the exporter itself
- job_name: 'redis_exporter'
static_configs:
- targets:
- <<REDIS-EXPORTER-HOSTNAME>>:9121
The targets-redis-instances.json should look something like this:
[
{
"targets": [ "redis://redis-host-01:6379", "redis://redis-host-02:6379"],
"labels": { }
}
]
Prometheus uses file watches and all changes to the json file are applied immediately.
Prometheus Configuration to Scrape All Nodes in a Redis Cluster
When using a Redis Cluster, the exporter provides a discovery endpoint that can be used to discover all nodes in the cluster.
To use this feature, the exporter must be started with the --is-cluster flag.
The discovery endpoint is available at /discover-cluster-nodes and can be used in the Prometheus configuration like this:
scrape_configs:
- job_name: 'redis_exporter_cluster_nodes'
http_sd_configs:
- url: http://<<REDIS-EXPORTER-HOSTNAME>>:9121/discover-cluster-nodes
refresh_interval: 10m
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: <<REDIS-EXPORTER-HOSTNAME>>:9121
## config for scraping the exporter itself
- job_name: 'redis_exporter'
static_configs:
- targets:
- <<REDIS-EXPORTER-HOSTNAME>>:9121
By default, Redis cluster node discovery will use the IP address of the nodes. If the cluster is running with
--cluster-preferred-endpoint-type hostname and --cluster-announce-hostname <cluster-node-name> then you can set the
--cluster-discover-hostnames flag or theREDIS_EXPORTER_CLUSTER_DISCOVER_HOSTNAMES environment variable to true and
the discovery endpoint will return hostnames instead of IP addresses for the nodes. This flag is helpful when the cluster
is deployed in container environments.
P.S. Consider using -append-instance-role-label option to easily distinguish master and replica nodes metrics.
Command line flags
| Name |
Environment Variable Name |
Description |
| redis.addr |
REDIS_ADDR |
Address of the Redis instance, defaults to redis://localhost:6379. If TLS is enabled, the address must be like the following rediss://localhost:6379 |
| redis.user |
REDIS_USER |
User name to use for authentication (Redis ACL for Redis 6.0 and newer). |
| redis.password |
REDIS_PASSWORD |
Password of the Redis instance, defaults to "" (no password). |
| redis.password-file |
REDIS_PASSWORD_FILE |
Password file of the Redis instance to scrape, defaults to "" (no password file). |
| check-keys |
REDIS_EXPORTER_CHECK_KEYS |
Comma separated list of key patterns to export value and length/size, eg: db3=user_count will export key user_count from db 3. db defaults to 0 if omitted. The key patterns specified with this flag will be found using SCAN. Use this option if you need glob pattern matching; check-single-keys is faster for non-pattern keys. Warning: using --check-keys to match a very large number of keys can slow down the exporter to the point where it doesn’t finish scraping the redis instance. In cluster mode, pattern scans are local to the scraped node, not cluster-wide. |
| check-single-keys |
REDIS_EXPORTER_CHECK_SINGLE_KEYS |
Comma separated list of keys to export value and length/size, eg: db3=user_count will export key user_count from db 3. db defaults to 0 if omitted. The keys specified with this flag will be looked up directly without any glob pattern matching. Use this option if you don’t need glob pattern matching; it is faster than check-keys. |
| disable-exporting-key-values |
REDIS_EXPORTER_DISABLE_EXPORTING_KEY_VALUES |
Whether to stop exporting the values of string keys matched by check-keys/check-single-keys (the key_value and key_value_as_string metrics), defaults to false. |
| check-streams |
REDIS_EXPORTER_CHECK_STREAMS |
Comma separated list of stream-patterns to export info about streams, groups and consumers. Syntax is the same as check-keys. Only keys of type stream are matched (needs Redis 6.0+, older servers match keys of all types). |
| check-single-streams |
REDIS_EXPORTER_CHECK_SINGLE_STREAMS |
Comma separated list of streams to export info about streams, groups and consumers. The streams specified with this flag will be looked up directly without any glob pattern matching. Use this option if you don’t need glob pattern matching; it is faster than check-streams. |
| streams-exclude-consumer-metrics |
REDIS_EXPORTER_STREAMS_EXCLUDE_CONSUMER_METRICS |
Don’t collect per consumer metrics for streams (decreases amount of metrics and cardinality). |
| check-keys-batch-size |
REDIS_EXPORTER_CHECK_KEYS_BATCH_SIZE |
Approximate number of keys to process in each execution. This is basically the COUNT option that will be passed into the SCAN command as part of the execution of the key or key group metrics, see COUNT option. Larger value speeds up scanning. Still Redis is a single-threaded app, huge COUNT can affect production environment. |
| count-keys |
REDIS_EXPORTER_COUNT_KEYS |
Comma separated list of patterns to count, eg: db3=sessions:* will count all keys with prefix sessions: from db 3. db defaults to 0 if omitted. Warning: The exporter runs SCAN to count the keys. This might not perform well on large databases. |
| skip-checkkeys-for-role-master |
REDIS_EXPORTER_SKIP_CHECKKEYS_FOR_ROLE_MASTER |
Whether to skip the check-keys, check-single-keys, count-keys and stream metrics when the instance is a master, to reduce load on master nodes, defaults to false. |
| script |
REDIS_EXPORTER_SCRIPT |
Comma separated list of path(s) to Redis Lua script(s) for gathering extra metrics. |
| lua-script-read-only |
REDIS_EXPORTER_LUA_SCRIPT_READ_ONLY |
Use the EVAL_RO command for gathering extra metrics with a Lua script instead of EVAL. To protect data in Redis from bugs or Lua script compromise. |
| debug |
REDIS_EXPORTER_DEBUG |
Verbose debug output |
| log-level |
REDIS_EXPORTER_LOG_LEVEL |
Set log level |
| log-format |
REDIS_EXPORTER_LOG_FORMAT |
Log format, valid options are txt (default) and json. |
| namespace |
REDIS_EXPORTER_NAMESPACE |
Namespace for the metrics, defaults to redis. |
| connection-timeout |
REDIS_EXPORTER_CONNECTION_TIMEOUT |
Timeout for connection to Redis instance, defaults to “15s” (in Golang duration format) |
| web.listen-address |
REDIS_EXPORTER_WEB_LISTEN_ADDRESS |
Address to listen on for web interface and telemetry, defaults to 0.0.0.0:9121. |
| web.telemetry-path |
REDIS_EXPORTER_WEB_TELEMETRY_PATH |
Path under which to expose metrics, defaults to /metrics. |
| redis-only-metrics |
REDIS_EXPORTER_REDIS_ONLY_METRICS |
Whether to export only Redis metrics (omit Go process+runtime metrics), defaults to false. |
| include-go-runtime-metrics |
REDIS_EXPORTER_INCLUDE_GO_RUNTIME_METRICS |
Whether to include Go runtime metrics, defaults to false. |
| include-config-metrics |
REDIS_EXPORTER_INCL_CONFIG_METRICS |
Whether to include all config settings as metrics, defaults to false. |
| include-system-metrics |
REDIS_EXPORTER_INCL_SYSTEM_METRICS |
Whether to include system metrics like total_system_memory_bytes, defaults to false. |
| include-rdb-file-size-metric |
REDIS_EXPORTER_INCL_RDB_FILE_SIZE_METRIC |
Whether to include RDB file size metric (requires filesystem access to RDB file), defaults to false. |
| include-modules-metrics |
REDIS_EXPORTER_INCL_MODULES_METRICS |
Whether to collect Redis Modules metrics, defaults to false. |
| include-search-indexes-metrics |
REDIS_EXPORTER_INCL_SEARCH_INDEXES_METRICS |
Whether to collect Redis Search indexes metrics, defaults to false. |
| include-cluster-slot-stats |
REDIS_EXPORTER_INCL_CLUSTER_SLOT_STATS |
Whether to collect per-slot metrics from CLUSTER SLOT-STATS (Valkey 8.0+, cluster mode only), defaults to false. Can produce up to 4 series per slot (16384 slots) so enable with care. Valkey only reports the CPU and network metrics when cluster-slot-stats-enabled yes is set on the server; otherwise only redis_cluster_slot_key_count is exported and the other series are omitted (not reported as 0). |
| include-keysizes-metrics |
REDIS_EXPORTER_INCL_KEYSIZES_METRICS |
Whether to collect key size distribution metrics from the KEYSIZES section of INFO (Redis 8.0+), defaults to false. Exports redis_keysizes_key_count, one series per non-empty power-of-two bucket per data type, measure (sizes/items) and db — in theory up to 64 buckets, in practice far fewer since buckets grow by powers of two and only non-empty buckets are reported. Enable with care on instances with many databases. |
| check-search-indexes |
REDIS_EXPORTER_CHECK_SEARCH_INDEXES |
Regex pattern for Redis Search indexes to export metrics from FT.INFO command, defaults to “.*”. |
| exclude-latency-histogram-metrics |
REDIS_EXPORTER_EXCLUDE_LATENCY_HISTOGRAM_METRICS |
Do not try to collect latency histogram metrics (to avoid WARNING, LOGGED ONCE ONLY: cmd LATENCY HISTOGRAM error on Redis < v7). |
| exclude-slowlog-metrics |
REDIS_EXPORTER_EXCLUDE_SLOWLOG_METRICS |
Do not try to collect slowlog metrics. Skips the SLOWLOG commands on every scrape; slowlog statistics parsed from INFO are still exported. |
| exclude-commandlog-metrics |
REDIS_EXPORTER_EXCLUDE_COMMANDLOG_METRICS |
Do not try to collect commandlog metrics. Skips the COMMANDLOG commands, including the support probe, on every scrape. |
| redact-config-metrics |
REDIS_EXPORTER_REDACT_CONFIG_METRICS |
Whether to redact config settings that include potentially sensitive information like passwords. |
| ping-on-connect |
REDIS_EXPORTER_PING_ON_CONNECT |
Whether to ping the redis instance after connecting and record the duration as a metric, defaults to false. |
| include-sentinel-peer-info |
REDIS_EXPORTER_INCL_SENTINEL_PEER_INFO |
Whether to export redis_sentinel_peer_info metrics for the other Sentinels discovered via SENTINEL SENTINELS (high cardinality), defaults to false. |
| is-tile38 |
REDIS_EXPORTER_IS_TILE38 |
Whether to scrape Tile38 specific metrics, defaults to false. |
| is-cluster |
REDIS_EXPORTER_IS_CLUSTER |
Whether this is a redis cluster (Enable this if you need to fetch key level data on a Redis Cluster). |
| cluster-discover-hostnames |
REDIS_EXPORTER_CLUSTER_DISCOVER_HOSTNAMES |
Whether to use hostname for cluster node discovery if available via /discover-cluster-nodes endpoint, defaults to false. |
| export-client-list |
REDIS_EXPORTER_EXPORT_CLIENT_LIST |
Whether to scrape Client List specific metrics, defaults to false. |
| export-client-idle-threshold |
REDIS_EXPORTER_EXPORT_CLIENT_IDLE_THRESHOLD |
Export redis_idle_clients for clients idle longer than this many seconds, excluding blocked, pub/sub, replication, and MONITOR clients. Independent of export-client-list. Defaults to 0 (disabled). |
| export-client-port |
REDIS_EXPORTER_EXPORT_CLIENT_PORT |
Whether to include the client’s port when exporting the client list. Warning: including the port increases the number of metrics generated and will make your Prometheus server take up more memory |
| skip-tls-verification |
REDIS_EXPORTER_SKIP_TLS_VERIFICATION |
Whether to skip TLS verification when the exporter connects to a Redis instance |
| tls-server-name |
REDIS_EXPORTER_TLS_SERVER_NAME |
Server name used to verify the Redis server certificate when the exporter connects to a Redis instance over TLS. Also sets the TLS SNI server name. |
| tls-client-key-file |
REDIS_EXPORTER_TLS_CLIENT_KEY_FILE |
Name of the client key file (including full path) if the server requires TLS client authentication |
| tls-client-cert-file |
REDIS_EXPORTER_TLS_CLIENT_CERT_FILE |
Name the client cert file (including full path) if the server requires TLS client authentication |
| tls-server-key-file |
REDIS_EXPORTER_TLS_SERVER_KEY_FILE |
Name of the server key file (including full path) if the web interface and telemetry should use TLS |
| tls-server-cert-file |
REDIS_EXPORTER_TLS_SERVER_CERT_FILE |
Name of the server certificate file (including full path) if the web interface and telemetry should use TLS |
| tls-server-ca-cert-file |
REDIS_EXPORTER_TLS_SERVER_CA_CERT_FILE |
Name of the CA certificate file (including full path) if the web interface and telemetry should use TLS |
| tls-server-min-version |
REDIS_EXPORTER_TLS_SERVER_MIN_VERSION |
Minimum TLS version that is acceptable by the web interface and telemetry when using TLS, defaults to TLS1.2 (supports TLS1.0,TLS1.1,TLS1.2,TLS1.3). |
| tls-ca-cert-file |
REDIS_EXPORTER_TLS_CA_CERT_FILE |
Name of the CA certificate file (including full path) if the server requires TLS client authentication |
| set-client-name |
REDIS_EXPORTER_SET_CLIENT_NAME |
Whether to set client name to redis_exporter, defaults to true. |
| check-key-groups |
REDIS_EXPORTER_CHECK_KEY_GROUPS |
Comma separated list of LUA regexes for classifying keys into groups. The regexes are applied in specified order to individual keys, and the group name is generated by concatenating all capture groups of the first regex that matches a key. A key will be tracked under the unclassified group if none of the specified regexes matches it. |
| max-distinct-key-groups |
REDIS_EXPORTER_MAX_DISTINCT_KEY_GROUPS |
Maximum number of distinct key groups that can be tracked independently per Redis database. If exceeded, only key groups with the highest memory consumption within the limit will be tracked separately, all remaining key groups will be tracked under a single overflow key group. |
| config-command |
REDIS_EXPORTER_CONFIG_COMMAND |
What to use for the CONFIG command, defaults to CONFIG, , set to “-” to skip config metrics extraction. |
| basic-auth-username |
REDIS_EXPORTER_BASIC_AUTH_USERNAME |
Username for Basic Authentication with the redis exporter needs to be set together with basic-auth-password to be effective. |
| basic-auth-password |
REDIS_EXPORTER_BASIC_AUTH_PASSWORD |
Password for Basic Authentication with the redis exporter needs to be set together with basic-auth-username to be effective, conflicts with basic-auth-hash-password. |
| basic-auth-hash-password |
REDIS_EXPORTER_BASIC_AUTH_HASH_PASSWORD |
Bcrypt-hashed password for Basic Authentication with the redis exporter needs to be set together with basic-auth-username to be effective, conflicts with basic-auth-password. |
| disable-scrape-endpoint |
REDIS_EXPORTER_DISABLE_SCRAPE_ENDPOINT |
Whether to disable the /scrape endpoint, defaults to false. |
| include-metrics-for-empty-databases |
REDIS_EXPORTER_INCL_METRICS_FOR_EMPTY_DATABASES |
Whether to emit db metrics (like db_keys) for empty databases. |
| append-instance-role-label |
REDIS_EXPORTER_APPEND_INSTANCE_ROLE_LABEL |
Whether to append ‘instance_role’ label to redis metrics. It allows easy creation of dashboards/alerts with a selector for instance role (master/replica). NOTE: This increases the cardinality of Redis metrics. |
Redis instance addresses can be tcp addresses: redis://localhost:6379, redis.example.com:6379 or e.g. unix sockets: unix:///tmp/redis.sock.
SSL is supported by using the rediss:// schema, for example: rediss://azure-ssl-enabled-host.redis.cache.windows.net:6380 (note that the port is required when connecting to a non-standard 6379 port, e.g. with Azure Redis instances).
If the Redis address does not match the certificate hostname, set --tls-server-name or pass tls_server_name to the /scrape endpoint.
Command line settings take precedence over any configurations provided by the environment variables.
Authenticating with Redis
If your Redis instance requires authentication then there are several ways how you can supply
a username (new in Redis 6.x with ACLs) and a password.
You can provide the username and password as part of the address, see here for the official documentation of the redis:// scheme.
You can set -redis.password-file=sample-pwd-file.json to specify a password file, it’s used whenever the exporter connects to a Redis instance,
no matter if you’re using the /scrape endpoint for multiple instances or the normal /metrics endpoint when scraping just one instance.
It only takes effect when redis.password == "". See the contrib/sample-pwd-file.json for a working example, and make sure to always include the redis:// in your password file entries.
An example for a URI including a password is: redis://<<username (optional)>>:<<PASSWORD>>@<<HOSTNAME>>:<<PORT>>
Alternatively, you can provide the username and/or password using the --redis.user and --redis.password directly to the redis_exporter.
With --is-cluster, Valkey 9.0+ supports database-qualified keys and streams such as
--check-single-keys=db3=jobs. Database selection is preserved across cluster
redirects. Pattern scans, key counts, and key groups remain local to the scraped
node; scrape each node to cover the cluster. The exporter does not use CLUSTERSCAN.
cluster-databases determines how many databases to inspect for key groups and
empty-database metrics. If CONFIG GET is unavailable, the exporter uses the
highest database visible in INFO (at least DB 0); additional empty databases
cannot be discovered. Explicit database-qualified key and stream checks still work.
If you want to use a dedicated Redis user for the redis_exporter (instead of the default user) then you need to enable a list of commands for that user.
Use the command below that matches your server and version, replacing <<<USERNAME>>> and <<<PASSWORD>>> with your desired values.
For Redis before 8.8:
ACL SETUSER <<<USERNAME>>> -@all +@connection +memory -readonly +strlen +config|get +xinfo +pfcount -quit +zcard +type +xlen -readwrite -command +command|info +client -wait +scard +llen +hlen +get +eval +slowlog +cluster|info +cluster|slots +cluster|nodes -hello -echo +info +latency +scan -reset -auth -asking ><<<PASSWORD>>>
For Redis 8.8 and later, also grant ARCOUNT to collect array key sizes:
ACL SETUSER <<<USERNAME>>> -@all +@connection +memory -readonly +strlen +config|get +xinfo +pfcount -quit +zcard +type +xlen -readwrite -command +command|info +client -wait +scard +llen +hlen +arcount +get +eval +slowlog +cluster|info +cluster|slots +cluster|nodes -hello -echo +info +latency +scan -reset -auth -asking ><<<PASSWORD>>>
For Valkey 8.1 and later, also grant COMMANDLOG LEN to collect command log metrics:
ACL SETUSER <<<USERNAME>>> -@all +@connection +memory -readonly +strlen +config|get +xinfo +pfcount -quit +zcard +type +xlen -readwrite -command +command|info +client -wait +scard +llen +hlen +get +eval +slowlog +commandlog|len +cluster|info +cluster|slots +cluster|nodes -hello -echo +info +latency +scan -reset -auth -asking ><<<PASSWORD>>>
All three examples grant COMMAND INFO so the exporter can check whether COMMANDLOG is supported without generating an ACL permission error on each scrape.
Do not add +arcount on servers without ARCOUNT or +commandlog|len on servers without COMMANDLOG: unknown commands cause the entire ACL SETUSER command to be rejected.
For Valkey 8.0+ or Redis 8.2+ the CLUSTER SLOT-STATS needs a specific ACL of +cluster|slot-stats included for a dedicated user. This is only needed when --include-cluster-slot-stats enables requesting and scraping the metrics.
ACL SETUSER <<<USERNAME>>> +cluster|slot-stats
For monitoring a Sentinel-node you may use the following command with the right ACL:
ACL SETUSER <<<USERNAME>>> -@all +@connection -command +client -hello +info -auth +sentinel|masters +sentinel|replicas +sentinel|slaves +sentinel|sentinels +sentinel|ckquorum ><<<PASSWORD>>>
Run via Docker
The latest release is automatically published to Docker Hub registry
You can run it like this:
docker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter
Docker images are also published to the Github Container Registry (ghcr.io) and to quay.io so you can pull them from there if for instance you run into rate limiting issues with Docker hub.
docker run -d --name redis_exporter -p 9121:9121 quay.io/oliver006/redis_exporter
# or
docker run -d --name redis_exporter -p 9121:9121 ghcr.io/oliver006/redis_exporter
The latest docker image contains only the exporter binary.
If e.g. for debugging purposes, you need the exporter running
in an image that has a shell then you can run the alpine image:
docker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter:alpine
If you try to access a Redis instance running on the host node, you’ll need to add --network host so the
redis_exporter container can access it:
docker run -d --name redis_exporter --network host oliver006/redis_exporter
Run on Kubernetes
Here is an example Kubernetes deployment configuration for how to deploy the redis_exporter as a sidecar to a Redis instance.
Tile38
Tile38 now has native Prometheus support for exporting server metrics and basic stats about number of objects, strings, etc.
You can also use redis_exporter to export Tile38 metrics, especially more advanced metrics by using Lua scripts or the -check-keys flag.
To enable Tile38 support, run the exporter with --is-tile38=true.
What’s exported
Most items from the INFO command are exported,
see documentation for details.
In addition, for every database there are metrics for total keys, expiring keys and the average TTL for keys in the database.
You can also export values of keys by using the -check-keys (or related) flag. The exporter will also export the size (or, depending on the data type, the length) of the key.
This can be used to export the number of elements in (sorted) sets, hashes, lists, streams, etc. For Redis arrays, key_size uses ARCOUNT and reports the number of non-empty elements, not the sparse logical length returned by ARLEN.
If a key is in string format and matches with --check-keys (or related) then its string value will be exported as a label in the key_value_as_string metric.
If you require custom metric collection, you can provide comma separated list of path(s) to Redis Lua script(s) using the -script flag. If you pass only one script, you can omit comma. An example can be found in the contrib folder.
The redis_idle_clients metric
Set --export-client-idle-threshold=300 (or REDIS_EXPORTER_EXPORT_CLIENT_IDLE_THRESHOLD=300) to export a single redis_idle_clients gauge counting clients whose CLIENT LIST idle time is strictly greater than 300 seconds. Blocked, pub/sub (including sharded pub/sub), replication, and MONITOR clients are excluded. The default of 0 disables this metric; negative thresholds are rejected.
This works independently of --export-client-list and adds no per-client labels or metrics. It requires permission to run CLIENT LIST and reads the full client list on each scrape, so collection cost grows with the number of connections. When both options are enabled, they share one CLIENT LIST request. A successful scrape with no matching clients emits zero; a failed CLIENT LIST request omits the metric.
The redis_memory_max_bytes metric
The metric redis_memory_max_bytes will show the maximum number of bytes Redis can use.
It is zero if no memory limit is set for the Redis instance you’re scraping (this is the default setting for Redis).
You can confirm that’s the case by checking if the metric redis_config_maxmemory is zero or by connecting to the Redis instance via redis-cli and running the command CONFIG GET MAXMEMORY.
What it looks like
Example Grafana screenshots:


Grafana dashboard is available on grafana.com and/or github.com.
Viewing multiple Redis simultaneously
If running Redis Sentinel, it may be desirable to view the metrics of the various cluster members simultaneously. For this reason the dashboard’s drop down is of the multi-value type, allowing for the selection of multiple Redis. Please note that there is a caveat; the single stat panels up top namely uptime, total memory use and clients do not function upon viewing multiple Redis.
Using the mixin
There is a set of sample rules, alerts and dashboards available in redis-mixin
Upgrading from 0.x to 1.x
PR #256 introduced breaking changes which were released as version v1.0.0.
If you only scrape one Redis instance and use command line flags --redis.addr
and --redis.password then you’re most probably not affected.
Otherwise, please see PR #256 and [this README](https://github.com/oliver006/redis_exporter#prometheus-configuration-to-scrape-
README 内容过长,已截取前 64 KB。完整内容请前往 GitHub 仓库查看。
评论