Linux安装Prometheus


一、简介

1.架构图

在这里插入图片描述

2.核心概念

在这里插入图片描述

二、安装配置和使用

1.下载二进制包并解压

官方地址:https://github.com/prometheus/prometheus/tags

tar xvf prometheus-2.14.0.linux-amd64.tar.gz
mv prometheus-2.14.0.linux-amd64 /usr/local/bin/prometheus

配置systemd管理

cat > /usr/lib/systemd/system/prometheus.service << EOF
[Unit]
Description=https://prometheus.io

[Service]
Restart=on-failure
ExecStart=/usr/local/bin/prometheus/prometheus --config.file=/usr/local/bin/prometheus/prometheus.yml

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus

2.WEB访问(默认监控自身)

访问地址:http://ip:9090
在这里插入图片描述

3.查看当前抓取的数据

http://IP:9090/metrics
在这里插入图片描述

4.查找数据,示例

访问地址:http://ip:9090
在这里插入图片描述
在这里插入图片描述
可以看到统计的数据
在这里插入图片描述
图形化展示
在这里插入图片描述
至此,Prometheus部署完成

三、docker的方式部署

1.安装docker

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum install docker-ce-18.06.1.ce-3.el7 -y
systemctl enable docker
systemctl start docker
docker -v

2.拉取镜像启动容器

docker配置镜像加速器
需提前准备好prometheus.yml文件,可以先从容器里面拷贝下来

mkdir -p /data/prometheus/conf
cp prometheus.yml /data/prometheus/conf
docker run -d --name prometheus --restart=unless-stopped \
-v /data/prometheus/conf:/etc/prometheus \
-v /etc/localtime:/etc/localtime \
-p 9090:9090  prom/prometheus

访问http://ip:9090

四、配置支持热加载

启动时添加参数–web.enable-lifecycle,如

./prometheus --web.enable-lifecycle

热加载的两种方式

方式一:发送HUP信号给Prometheus进程

kill -HUP PID

方式二:通过HTTP请求

curl -X POST http://localhost:9090/-/reload	#只接收POST请求

四、配置文件讲解

在这里插入图片描述

1.global全局配置

scrape_interval		采集数据周期,默认1分钟
scrape_timeout		采集超时时间,默认10秒
evaluation_interval	告警评估周期,默认1分钟
external_labels		外部标签,很少用

2.rule_files指定监控告警规则

参考:https://www.jianshu.com/p/fb5c82de935d
在这里插入图片描述

metrics_path		默认为/metrics
honor_labels		默认标签值,默认不覆盖
scheme:				请求的协议,默认http
params:				http携带的参数
basic_auth			基础认证

3.scrape_configs采集配置

4.alerting配置告警

5.remote_write远程存储写

6.remote_read远程存储读

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值