redis_exporter 1.96.0 开始把 Redis 8 INFO Threads 里的按线程计数导出成 Prometheus 指标。1.95.0 只有汇总的 redis_io_threaded_*,看不到每个 IO 线程的 clients / reads / writes。下面用同一台 io-threads 4 的 Redis 8.10.2 对照跑了这两个版本。
官方 Release Notes 对应 PR #1206。Redis 8 在 INFO ALL 里加了 # Threads 段,行形如 io_thread_1:clients=1,reads=3347,writes=496。旧版 exporter 没有 Threads 分支,这些行落到通用解析,值不是单个数字,于是整段丢了。1.96.0 按线程号打 label,导出 redis_io_thread_clients、redis_io_thread_reads_processed_total、redis_io_thread_writes_processed_total。
实验环境
Redis 用官方镜像 redis:8,启动参数 --io-threads 4 --io-threads-do-reads yes。流量用 Spring Boot 4.1.2 + Lettuce 连上打 300 次 set/get。exporter 分别用官方发布的 linux-amd64 包 v1.95.0 和 v1.96.0,指到同一 redis://127.0.0.1:16379。所有输出来自一次 verify.sh 的 verify.log。
+ sudo docker start redis8-io (reuse)
+ sudo docker exec redis8-io redis-cli INFO server | head
redis_version:8.10.2
io_threads_active:1
+ sudo docker exec redis8-io redis-cli INFO Threads
# Threads
io_thread_0:clients=0,reads=0,writes=0
io_thread_1:clients=1,reads=6286,writes=6285
io_thread_2:clients=1,reads=2854,writes=1444
io_thread_3:clients=0,reads=0,writes=0
===== Spring Boot traffic (Lettuce) =====
+ java -jar ./app/target/redis-io-traffic-0.0.1-SNAPSHOT.jar
TRAFFIC_OPS=600
1.95.0:只有汇总,没有按 thread
===== redis_exporter 1.95.0 scrape =====
+ ./redis_exporter-v1.95.0.linux-amd64/redis_exporter --redis.addr=redis://127.0.0.1:16379 --web.listen-address=127.0.0.1:9121
exporter_pid=345075
+ curl -s http://127.0.0.1:9121/metrics | rg 'redis_io_thread'
NO_PER_THREAD_IO_METRICS
----- aggregate io metrics (both versions have) -----
redis_config_io_threads 4
redis_io_threaded_reads_processed 10011
redis_io_threaded_writes_processed 8596
redis_io_threads_active 1
用 redis_io_thread 去扫 metrics,没有 redis_io_thread_clients 这类按线程序列。汇总项还在,能看出开了 4 个 IO 线程,但分不清负载落在哪条线程上。
1.96.0:四个 thread label
===== redis_exporter 1.96.0 scrape =====
+ ./redis_exporter-v1.96.0.linux-amd64/redis_exporter --redis.addr=redis://127.0.0.1:16379 --web.listen-address=127.0.0.1:9122
exporter_pid=345098
+ curl -s http://127.0.0.1:9122/metrics | rg 'redis_io_thread'
# HELP redis_io_thread_clients io_thread_clients metric
# TYPE redis_io_thread_clients gauge
redis_io_thread_clients{thread="0"} 0
redis_io_thread_clients{thread="1"} 1
redis_io_thread_clients{thread="2"} 1
redis_io_thread_clients{thread="3"} 0
# HELP redis_io_thread_reads_processed_total io_thread_reads_processed_total metric
# TYPE redis_io_thread_reads_processed_total counter
redis_io_thread_reads_processed_total{thread="0"} 0
redis_io_thread_reads_processed_total{thread="1"} 6553
redis_io_thread_reads_processed_total{thread="2"} 3490
redis_io_thread_reads_processed_total{thread="3"} 0
# HELP redis_io_thread_writes_processed_total io_thread_writes_processed_total metric
# TYPE redis_io_thread_writes_processed_total counter
redis_io_thread_writes_processed_total{thread="0"} 0
redis_io_thread_writes_processed_total{thread="1"} 6552
redis_io_thread_writes_processed_total{thread="2"} 2074
redis_io_thread_writes_processed_total{thread="3"} 0
----- aggregate io metrics (both versions have) -----
redis_config_io_threads 4
redis_io_threaded_reads_processed 10043
redis_io_threaded_writes_processed 8626
redis_io_threads_active 1
四个 thread 都出来了。这次流量主要落在 thread 1 和 2,和前面 INFO Threads 的分布一致。汇总指标两个版本都有,没有消失。
同版本还加了可选的空闲连接汇总指标(PR #1203),默认关闭,这篇不展开。未开 io-threads(或等于 1)时,Redis 通常不会给出这段多线程明细,导出侧也就没有对应序列。
一起交流
分享你的思考,让讨论更进一步。