安装,启动,配置prometheus
要在Grafana中安装和配置Prometheus,通常需要以下步骤:
安装mongodb介绍:https://www.cnblogs.com/pingguomang/p/18719624
1. 安装Prometheus
首先,你需要在服务器上安装Prometheus。
在Linux上安装Prometheus:
1.下载Prometheus:
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
2.解压文件:
tar xvfz prometheus-2.30.3.linux-amd64.tar.gz
3.进入解压后的目录:
cd prometheus-2.30.3.linux-amd64
4.启动Prometheus:
./prometheus --config.file=prometheus.yml
默认情况下,Prometheus会在http://localhost:9090
上运行。
2.后端启动prometheus的方式:
在Linux系统中,Prometheus可以通过多种方式以后台(后端)模式启动。以下是几种常见的方法:
2.1. 使用 nohup
命令
nohup
命令可以让进程在后台运行,即使终端关闭也不会中断。
1.启动Prometheus:
nohup ./prometheus --config.file=prometheus.yml > prometheus.log 2>&1 &
2.查看日志:
你可以通过查看prometheus.log
文件来检查Prometheus的输出:
tail -f prometheus.log
3.停止Prometheus:
你可以通过ps
命令找到Prometheus的进程ID并终止它:
ps aux | grep prometheus
kill <PID>
3.配置prometheus datasource
1.点击data source数据源,搜索prometheus:
2.配置prometheus:
4.使用 Prometheus ,通过 MongoDB 的 Exporter来收集 MongoDB 的监控数据
1.下载mogodb_export的代码,然后启动镜像
#方案1: 使用go安装
git clone https://github.com/percona/mongodb_exporter
cd mongodb_exporter
go build #需要提前安装go的环境
./mongodb_exporter --mongodb.uri=mongodb://ip:27017
#方案2: 使用docker安装
git clone https://github.com/percona/mongodb_exporter
cd mongodb_exporter
docker run -d -p 9216:9216 percona/mongodb_exporter:0.20 --mongodb.uri=mongodb://ip:27017
--mongodb.uri指定要监控的mongodb,有用户名和密码要填写,没有的就不填写;
安装完成访问:http://安装宿主机ip:9216
2. mongodb_exporter整合进Prometheus
1) 修改配置
只需要在prometheus.yml上添加如下框
cd /home1/user1/prometheus/prometheus-2.30.3.linux-amd64
vim prometheus.yml
2) 重启prometheus
#1. kill原来的进程
ps aux | grep prometheus
kill <PID>
#2. 启动prometheus
./prometheus --config.file=prometheus.yml
3) 检查
访问http://172.28.64.10:9090/targets,能看到数据源就表示成功了。
5.配置grafana对mogodb数据的展示
参考1:https://blog.csdn.net/weixin_34364135/article/details/94245072
参考2:https://blog.51cto.com/u_16175474/13212551
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)