Redis Metrics Exporter:https://github.com/oliver006/redis_exporter

下载

下载地址:https://github.com/oliver006/redis_exporter/releases

1
2
3
4
5
mkdir -p /monitor/exporter
cd /monitor/exporter
VER=1.XX.X # 选择需要安装的版本号
wget "https://github.com/oliver006/redis_exporter/releases/download/v${VER}/redis_exporter-v${VER}.linux-amd64.tar.gz"
tar zxf redis_exporter-v${VER}.linux-amd64.tar.gz -C redis_exporter

配置

配置如图,支持监控多个Redis实例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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

配置说明:

Name Environment Variable Name Description
redis.addr REDIS_ADDR Address of the Redis instance, defaults to redis://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).
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.
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 0if 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.
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.
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.
script REDIS_EXPORTER_SCRIPT Path to Redis Lua script for gathering extra metrics.
debug REDIS_EXPORTER_DEBUG Verbose debug output
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 also export go runtime 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.
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.
is-tile38 REDIS_EXPORTER_IS_TILE38 Whether to scrape Tile38 specific metrics, defaults to false.
export-client-list REDIS_EXPORTER_EXPORT_CLIENT_LIST Whether to scrape Client List specific metrics, defaults to false.
skip-tls-verification REDIS_EXPORTER_SKIP_TLS_VERIFICATION Whether to to skip TLS verification
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-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.

启动

1
2
3
4
# 无密码
nohup ./redis_exporter -redis.addr 192.168.10.12:6379 &
# 有密码
nohup ./redis_exporter -redis.addr 192.168.10.12:6379 -redis.password 123456 &