鑒於上一篇隨筆已經寫了如何搭建prometheus故此篇附上連接:https://www.cnblogs.com/lc226/p/11222048.html,同時省略了一些基礎步驟
一.安裝redis_exporter
下載可以去git上下或者https://www.cnblogs.com/lc226/p/11222048.html去我的隨筆找,有鏈接
這里是監控的單機redis
1.解壓后直接 nohup ./redis_exporter -redis.addr 172.16.16.74 &
-redis.addr:指明一個或多個 Redis 節點的地址,多個節點使用逗號分隔,默認為 localhost:6379
-redis.password:驗證 Redis 時使用的密碼;
-redis.file:包含一個或多個redis 節點的文件路徑,每行一個節點,此選項與 -redis.addr 互斥。
-web.listen-address:監聽的地址和端口,默認為 0.0.0.0:9121
2.tail -f nohup.out
3.訪問指標 http://172.16.16.80:9121/metrics
二.配置prometheus.yml
這里還是要注意格式問題。
- job_name: 'redis'
metrics_path: "/metrics"
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9121']
三.grafana展示
可以看到db0里面有一個key
這里可以測試隨筆添加一個key
可以看到key增長了一個