Pushgateway的使⽤

一、Pushgateway 二进制安装(不用 Docker、不用联网)

复制代码
cd /usr/local
wget https://github.com/prometheus/pushgateway/releases/download/v1.5.1/pushgateway-1.5.1.linux-amd64.tar.gz
tar zxvf pushgateway-1.5.1.linux-amd64.tar.gz
mv pushgateway-1.5.1.linux-amd64 pushgateway
cd pushgateway

二、后台启动 Pushgateway(端口 9091)

复制代码
nohup ./pushgateway --web.listen-address=":9091" --persistence.file="pushgateway.data" >/dev/null 2>&1 &

三、验证是否启动成功

复制代码
curl 127.0.0.1:9091/metrics

出现指标 = 成功。


四、把 Pushgateway 加入 prometheus.yml

编辑你找到的配置文件:

复制代码
vi /etc/prometheus/prometheus.yml

scrape_configs 下面添加:

复制代码
- job_name: 'pushgateway'
    static_configs:
      - targets: ['192.168.52.130:9091']
    honor_labels: true

五、重启 Prometheus

复制代码
systemctl restart prometheus

浏览器访问 IP:9091 验证pushgateway⻚⾯即可


六、推送数据示例

示例 1:最简单推送指标

复制代码
echo "test_metric 100" | curl --data-binary @- http://192.168.52.130:9091/metrics/job/test_job

示例 2:带标签推送

复制代码
echo "test_metric{instance=\"server-130\",job=\"push_test\"} 88" | curl --data-binary @- http://192.168.52.130:9091/metrics/job/push_test/instance/server-130

示例 3:删除数据

复制代码
curl -X DELETE http://192.168.52.130:9091/metrics/job/push_test/instance/server-130

七、Grafana 出图(可视化)

  1. 打开 Grafana:http://192.168.52.130:3000
  2. 导入面板:11434(Pushgateway 官方面板)
  3. 数据源选择 Prometheus
  4. 立刻出现:
    • 推送速率
    • 推送时间
    • 任务状态
    • 自定义指标图表

八、完成验证

  1. Prometheus targets 里出现 pushgateway (UP)
  2. 能执行推送 / 删除命令
  3. Grafana 面板正常出图
相关推荐
ElevenS_it1889 小时前
Zabbix+Prometheus+云监控告警统一接入实战:用Webhook+事件总线搭建多源告警归一化平台
kubernetes·zabbix·prometheus
成为你的宁宁20 小时前
【基于 Docker-compose 部署 Prometheus 监控系统实战教程 】
docker·容器·prometheus
成为你的宁宁20 小时前
【Prometheus+Grafana 监控平台二进制安装配置(图文实操详解)】
grafana·prometheus
蜀道山老天师1 天前
实操|Prometheus Pushgateway 部署、推送与数据管理全流程
运维·服务器·云原生·prometheus
蜀道山老天师2 天前
Docker Compose实战案例:一键部署WordPress+Prometheus监控平台
运维·docker·容器·prometheus
川石课堂软件测试2 天前
接口测试常见面试题及答案
python·网络协议·mysql·华为·单元测试·prometheus·harmonyos
海兰3 天前
在 Grafana 中驾驭 ES|QL:Elasticsearch 管道查询实战指南
大数据·elasticsearch·grafana
蜀道山老天师4 天前
从零搭建 Prometheus 监控 MySQL:含二进制安装、授权、exporter 配置全流程
运维·数据库·mysql·adb·云原生·prometheus
蜀道山老天师4 天前
Prometheus监控Hadoop集群(实操完整版,含避坑指南)
大数据·linux·运维·hadoop·云原生·prometheus
虎头金猫5 天前
Beszel 轻量服务器监控:多台服务器状态统一看,搭起来比 Prometheus 省事太多
linux·运维·服务器·分布式·kafka·开源·prometheus