07-prometheus的自定义监控-pushgateway工具组件

本文介绍了如何部署和配置Pushgateway,使其与Prometheus集成,用于收集和展示自定义节点和服务的监控数据。步骤包括下载安装、配置systemd启动、Prometheus抓取数据以及监控服务向Pushgateway发送数据的方法。
摘要由CSDN通过智能技术生成

一、概述

        pushgateway用于自定义监控节点、节点中服务的工具,用户可以通过自定义的命令获取数据,并将数据推送给pushgateway中;

        prometheus服务,从pushgateway中获取监控数据;

二、部署pushgateway

        我们可以“随便”找一台机器,作为pushgatway的服务端,用来接收数据;

        本次学习,为了方便,我们使用

1,软件包下载地址

pushgateway下载地址:

wget https://github.com/prometheus/pushgateway/releases/download/v1.6.1/pushgateway-1.6.1.linux-amd64.tar.gz

本次学习,为了方便,给大家准备了软件包,在百度云盘

链接:https://pan.baidu.com/s/1QFwCNrkIFJMZ-uIjiqfNog?pwd=21ui 
提取码:21ui

2,上传解压软件包

[root@prometheus-server32 ~]# tar xf pushgateway-1.6.1.linux-amd64.tar.gz -C /usr/local/bin/ pushgateway-1.6.1.linux-amd64/pushgateway --strip-components=1

3,编辑配置systenctl启动文件

[root@prometheus-server32 ~]# cat > /etc/systemd/system/pushgatway.service <<EOF
> [Unit]
> Description=Pushgateway
> After=network.target

> [Service]
> ExecStart=/usr/local/bin/pushgateway  \
>   --web.listen-address=:9091 \
>   --persistence.file=/prometheus/data/pushgatway.log \
>   --persistence.interval=5m \
>   --log.level=info \
>   --log.format=json

> [Install]
> WantedBy=multi-user.target
> EOF

4,创建日志目录

[root@prometheus-server32 ~]# mkdir -pv /prometheus/data/

5,重新加载并启动

systemctl daemon-reload
systemctl enable --now pushgatway

6,浏览器访问webui

查看端口是否启动成功

三、配置prometheus抓取pushgateway数据

[root@prometheus-server31 ~]# vim /prometheus/softwares/prometheus-2.37.8.linux-amd64/prometheus.yml 

global:
  scrape_interval: 3s
  evaluation_interval: 15s
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
scrape_configs:
  - job_name: "prometheus-pushgateway"
    #如果pushgateway组件的标签,和prometheus服务的标签冲突了,如何解决?
    #1,false(默认),将标签加上前缀“exporter_”,不覆盖;
    #2,true,覆盖原来的标签;
    honor_labels: true
    static_configs:
    - targets: ["10.0.0.32:9091"]

[root@prometheus-server31 ~]# curl -X POST http://10.0.0.31:9090/-/reload

浏览器查看,prometheus抓取pushgatway数据联通了,但是还没有数据;

四、被监控服务推送数据到pushgateway

[root@prometheus-node41 ~]# echo "user_num 22" | curl --data-binary @-  http://10.0.0.32:9091/metrics/job/xinjizhiwa_user/instance/10.0.0.41

参数说明

echo "key  value" | curl --data-binary @-  http://pushgatway的ip:端口号/metrics/job/自定义job名称/instance/被监控节点的ip地址

pushgateway浏览器查看是否推送成功

prometheus浏览器查看是否抓取到数据

至此,配置完成;自定义监控成功;

至此,pushgatway自定义监控,学习完毕。

  • 29
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心机の之蛙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值