第十讲:企业级监控数据采集脚本开发实践

  第十讲内容

  • pushgateway 的介绍

  • pushgateway 的安装和运⾏和配置

  • ⾃定义编写脚本的⽅法 发送pushgateway 采集

  • 使⽤pushgateway的优缺点

  

  (⼀) pushgateway 的介绍

  pushgateway 是另⼀种采⽤被动推送的⽅式(⽽不是exporter 主动获取)获取监控数据的prometheus 插件 在上篇中 我们对pushgateway已经做过介绍 它是可以单独运⾏在 任何节点上的插件(并不⼀定要在被监 控客户端) 然后 通过⽤户⾃定义开发脚本 把需要监控的数据 发送给 pushgateway  然后pushgateway 再把数据 推送给prometheus server

  (⼆)pushgatway 的安装和运⾏和配置

  下载地址:https://prometheus.io/download/#pushgateway

   解压设置systemctl运行

cd /usr/local
tar -xf pushgateway-1.2.0.linux-amd64.tar.gz 
mv pushgateway-1.2.0.linux-amd64 pushgateway

   设置systemctl文件

# cat /usr/lib/systemd/system/pushgateway.service 
[Unit]
Description=Prometheus Node Exporter
After=network.target

[Service]
ExecStart=/usr/local/pushgateway/pushgateway
User=nobody

[Install]
WantedBy=multi-user.target

   启动

systemctl daemon-reload
systemctl start pushgateway
systemctl enable pushgateway

   关于pushgateway的配置 主要指的是 在prometheus sever端的配 置

 job_name: 'pushgateway'
    static_configs:
    - targets: ['localhost:9091','localhost:9092']

 

   这⾥我们发现了没有, localhost:9091/9092  使⽤的 pushgateway开启了两个
  在prometheus_server 本机上 为什么开启两个 最后⼀个段落给⼤家解释

  (三)⾃定义编写脚本的⽅法 发送pushgateway 采集

  接下来 进⼊重头戏了  pushgateway 本⾝是没有任何抓取监控数据的功能的 它只是被 动的等待推送过来

猜你喜欢

转载自www.cnblogs.com/minseo/p/13373584.html
今日推荐