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 面板正常出图
相关推荐
南梦浅1 小时前
【无标题】
prometheus
zhanghongbin017 小时前
Grafana 可视化:开箱即用的监控面板
grafana
2301_旺仔9 小时前
【prometheus】监控linux/windows
linux·windows·prometheus
BullSmall1 天前
Prometheus 如何配置监控 SSL 证书即将过期
网络协议·ssl·prometheus
国产化创客1 天前
ESP32 (ESPectre)+Grafana构建专业级CSI监控面板
物联网·grafana·信息与通信·智能硬件
BullSmall1 天前
Prometheus 可以监控docker 部署的Nginx 吗?
nginx·docker·prometheus
鬼先生_sir2 天前
Spring Cloud 微服务监控实战:SkyWalking + Prometheus+Grafana 全栈解决方案
运维·spring cloud·grafana·prometheus·skywalking
SkyWalking中文站3 天前
使用 TraceQL 查询 SkyWalking 和 Zipkin 链路追踪数据并在 Grafana 中可视化
运维·grafana·监控
zs宝来了3 天前
Prometheus 监控体系原理:Pull 模式与 TSDB 时序数据库
prometheus·时序数据库·监控·tsdb·pull模式
何中应4 天前
Alertmanager设置邮件通知
运维·自动化·prometheus