安装,启动,配置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

posted @   苹果芒  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示