使用prometheus监控redis
下载redis_exporter插件
官方没提供专门的redis_exporter,github上有人开发了
https://github.com/oliver006/redis_exporter
安装步骤:
git clone https://github.com/oliver006/redis_exporter.git
cd redis_exporter
go build .
./redis_exporter --version
编译时遇到报错
-
# go build .
-
go: golang.org/x/sys@v0.0.0-20190405154228-4b34438f7a67: unrecognized import path "golang.org/x/sys" (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 216.239.37.1:443: connect: connection timed out
可以先设置 GOPROXY 变量
export GOPROXY=https://goproxy.io
go build .
启动redis_exporter
redis_exporter 可以支持监控单实例和多实例。如果监控一个redis 可以使用
nohup ./redis_exporter -redis.addr 127.0.0.1:6379 &
监控多个redis 则需要先启动exporter
nohup ./redis_exporter &
然后在prometheus.yml 的文件中添加
-
- job_name: 'redis_exporter_targets'
-
static_configs:
-
- targets:
-
- redis://10.9.106.217:6379
-
- redis://10.9.106.217:6381
-
metrics_path: /scrape
-
relabel_configs:
-
- source_labels: [__address__]
-
target_label: __param_target
-
- source_labels: [__param_target]
-
target_label: instance
-
- target_label: __address__
-
replacement: 10.9.11.22:9121
-
-
## config for scraping the exporter itself
-
- job_name: 'redis_exporter'
-
static_configs:
-
- targets:
-
- 10.9.11.22:9121
重新reload配置
sudo curl 'http://localhost:9090/-/reload' -X POST
采集到的redis监控数据
配置grafna
-
配置prometheus数据源,添加prometheus插件
-
下载redis仪表盘模板,选择prometheus数据源,然后上传json文件,下载地址: https://grafana.com/grafana/dashboards/763/revisions
转载自杨奇龙博客
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2021-07-29 ES elasticsearch利用url查询
2021-07-29 ES elasticsearch ingest如何使用及painless脚本
2021-07-29 ES elasticsearch创建模板template