Dashboard Preview Grafana Dashboard
- Support for multiple Redis sentinel groups
- Global and master-specific Redis password configuration
- Prometheus metrics endpoint
- User-friendly web interface for Redis node status
- Multi-threaded parallel collection of Redis metrics
- Support for both KVRocks and Redis engines
- Python 3.9+
- Redis 5.0+
- Flask 2.3+
- Prometheus Client
# Clone repository
git clone https://github.com/luger1990/kvdb-sentinel-exporter.git
cd kvdb-sentinel-exporter
# Install dependencies
pip install -r requirements.txt
# Configure
cp .env.example .env
cp config.yaml config.local.yaml # Modify configuration as needed
# Use pre-built image
docker pull luger1990/kvdb-sentinel-exporter
# Or build from Dockerfile
docker build -t kvdb-sentinel-exporter .
# Run container
docker run -dit \
-p 16379:16379 \
--name=kvdb-sentinel-exporter \
-v $(pwd)/config.yaml:/app/config.yaml \
luger1990/kvdb-sentinel-exporter
# Environment variables
8000
supported by Docker
docker run -dit \
-p 16379:16379 \
--name=kvdb-sentinel-exporter \
-e DEBUG=true \
-e HOST=127.0.0.1 \
-e PORT=6379 \
-e CONFIG_PATH=/app/config/config.yaml \
-v $(pwd)/config.yaml:/app/config.yaml \
luger1990/kvdb-sentinel-exporter
# It is recommended to run in Docker Host mode
docker run -dit \
--net=host \
--name=kvdb-sentinel-exporter \
-e DEBUG=false \
-v $(pwd)/config.yaml:/app/config.yaml \
luger1990/kvdb-sentinel-exporter
Configuration uses YAML format, with the default path being config.yaml
. You can customize the config file path using the CONFIG_PATH
environment variable.
# KVDB Sentinel Exporter 配置文件
# Redis哨兵配置
sentinels:
# 第一个哨兵组
redis-group-1:
# 本组Redis默认密码(可选,当master没有单独指定密码时使用此密码)
default_password: "ce67a0a422243742573ac12024c39f82"
sentinel_hosts:
- "127.0.0.1:26379"
- "127.0.0.1:26380"
- "127.0.0.1:26391"
# 为特定master_name指定密码配置(会覆盖默认密码)
master_groups:
# 示例:为特定master_name设置专用密码
kvrocks-group-1:
password: "cfc44dfc4f1a3f36400740680fd8c30c"
# 注意:未在此处列出的master_name将使用default_password
# 第二个哨兵组
redis-group-2:
# 本组Redis默认密码(可选)
default_password: ""
sentinel_hosts:
- "127.0.0.1:16379"
- "127.0.0.1:16380"
- "127.0.0.1:16391"
# 指标收集配置
metrics:
# 收集线程池大小
thread_pool_size: 10
# 连接超时时间(秒)
connect_timeout: 3
# 读取超时时间(秒)
read_timeout: 5
# Web UI配置
web_ui:
# 刷新间隔(秒)
refresh_interval: 30
Configuration can be set via .env
file or environment variables:
DEBUG
: Enable debug mode (default: false)HOST
: Listen address (default: 0.0.0.0)PORT
: Listen port (default: 16379)CONFIG_PATH
: Config file path (default: config.yaml)
# Run directly
python run.py
# Specify config file
python run.py /path/to/config.yaml
# Use environment variable for config
CONFIG_PATH=/path/to/config.yaml python run.py
Visit http://localhost:16379/
to view the sentinel group list
Visit http://localhost:16379/<sentinel_name>/info
to view the Redis node status for a specific sentinel group
Prometheus metrics endpoint: http://localhost:16379/<sentinel_name>/metrics
Key metrics include:
kvdb_up
: Redis instance online statuskvdb_role
: Redis node rolekvdb_memory_used_bytes
: Redis memory usagekvdb_connected_clients
: Number of client connectionskvdb_commands_processed_total
: Total processed commandskvdb_instantaneous_ops_per_sec
: Operations per secondkvdb_engine_type
: Engine type (Redis/KVRocks)
scrape_configs:
- job_name: 'redis_sentinel'
scrape_interval: 15s
static_configs:
- targets: ['localhost:16379']
metrics_path: '/nct-redis-sentinel/metrics'
For improved development efficiency, this project supports hot reloading, which automatically restarts the server when code or templates are modified.
-
Install development dependencies
pip install -r requirements.txt
-
Create development environment configuration file
cp .env.example .env
-
Edit the
.env
file to enable debug modeDEBUG=true
-
Start the server
python run.py
When DEBUG=true
is set, the application automatically enables:
- Auto-reload: The application reloads when Python files, HTML templates, JavaScript, or CSS files are modified
- No static resource caching: The browser always gets the latest version of static resources
- Debug toolbar: Displays a debug toolbar in the web interface with request, route, and configuration information
Monitored file extensions include:
.py
(Python source files).html
(HTML templates).js
(JavaScript files).css
(CSS stylesheets).yaml
and.yml
(Configuration files)