Prometheus - redis_exporter监控redis
简介
Prometheus针对redis的监控,需要安装redis_exporter来获取指标。
下载地址
项目地址:https://github.com/oliver006/redis_exporter
安装
直接解压就可以直接运行,我们可以使用systemd来管理服务。
vim /usr/lib/systemd/system/redis_exporter.service
[Unit]
Description=redis_exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/redis_exporter/redis_exporter --redis.addr redis://127.0.0.1:7000 --redis.password "opcai"
LimitNOFILE=65536
PrivateTmp=true
RestartSec=2
StartLimitInterval=0
Restart=always
[Install]
WantedBy=multi-user.targe
redis_exporter 参数
redis.addr :指定redis的地址 ,不指定,默认是 redis://127.0.0.1:6379 redis.password:redis密码,默认是空字符串,没有密码。
默认端口是9121
Prometheus设置
+ job_name: redis_exporter
static_configs:
- targets: ['192.168.100.100:9121']
启动服务
客户端:
systemctl daemon-reload
systemctl enable redis_exporter
systemctl start redis_export
Prometheus:reload 一下即可,确保服务端能访问到客户端的端口。
全部参数
Name | Environment Variable Name | Description |
---|---|---|
redis.addr | REDIS_ADDR | Address of the Redis instance, defaults to redis://localhost:6379 . |
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 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 . |
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 |
set-client-name | REDIS_EXPORTER_SET_CLIENT_NAME | Whether to set client name to redis_exporter, defaults to true. |
- 原文作者:Linux运维菜
- 原文链接:https://www.opcai.top/post/2020/2020-06/redis_exporter/
- 版权声明:本作品采用进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。