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

news/2024/5/19 0:30:57 标签: prometheus, 运维

一、概述

        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自定义监控,学习完毕。


http://www.niftyadmin.cn/n/5409030.html

相关文章

node.js中path.join() 和 path.resolve()

《Node.js》path.resolve与path.join的区别与作用_js path.resolve-CSDN博客

STM32FreeRTOS消息队列(STM32Cube高效开发)

文章目录 一、队列&#xff08;一&#xff09;简介&#xff08;二&#xff09;FreeRTOS队列特点1、入队阻塞&#xff1a;队列满了&#xff0c;此时无法继续写入数据2、出队阻塞&#xff1a;队列为空&#xff0c;此时无法读出数据3、入队阻塞解除&#xff0c;有多个任务等待时&a…

ClickHouse存储引擎之ReplacingMergeTree引擎

一、ReplacingMergeTree作用 ClickHouse中最常用也是最基础的表引擎为MergeTree,在它的功能上添加特定功能就构成了MergeTree系列引擎。MergeTree支持主键,但主键主要用来缩小查询范围,且不具备唯一性约束,可以正常写入相同主键的数据。但在一些情况下,可能需要表中没有主…

在线部署ubuntu20.04服务器,安装jdk、mysql、redis、nginx、minio

查看服务器版本为20.04 lsb_release -a服务器初始账号密码 sxd / 123456 首先,更改自身密码都输入123456 sudo passwd 创建最高权限root账号&#xff0c;密码为 123456 su root 更新源列表 sudo apt-get update 安装 openssh-server和vim&#xff0c;途中输入y sudo ap…

QT使用官方VLC以及Ffmpeg库的方法

概述 在使用QT开发基于VLC或者Ffmpeg库的播放器播放本地视频或者RTSP流时需要获取VLC或者FFPEG库&#xff0c;对于有一定技术能力的可以通过编译源码获得&#xff0c;当然也可以通过下载官方编译好的库文件。 VLC官方库下载 VLC 64bit库文件&#xff1a; VLC编译好的库文件、…

Apache POI处理Miscrosoft Office 各种文件格式的开源项目

介绍: 应用场景 maven 坐标 <dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.16</version></dependency><dependency><groupId>org.apache.poi</groupId><artifa…

Spring Boot、Nacos配置文件properties、yml、yaml的优先级

在标准的 SpringBoot 应用中&#xff0c;本地配置加载顺序如下&#xff1a; bootstrap.yamlbootstrap.propertiesbootstrap-{profile}.yamlbootstrap-{profile}.propertiesapplication.yamlapplication.propertiesapplication-{profile}.yamlapplication-{profile}.properties…

Linux系统的服务/进程

系统守护进程&#xff08;服务&#xff09; •服务就是运行在网络服务器上监听用户请求的进程 •服务是通过端口号来区分的 常见的服务及其对应的端口 1.ftp&#xff1a;21 FTP指的是文件传输协议&#xff0c;它是用于在计算机网络上进行文件传输的标准网络协议。通过FTP&am…