Pushgateway的安装和使用

CentOS7中Prometheus PushGateway的使用 Pushgateway是Prometheus的一个组件,prometheus server默认是通过Exporter主动获取数据(默认采取pull拉取数据),Pushgateway则是通过exporter主动方式推送数据到Pushgateway再由prometheus主动去拉取 Pushgateway数据,用户可以写一些自定义的监控脚本把需要监控的数据发送给Pushgateway。 阅读详情

介绍

pushgateway是Prometheus下的一个组件,用来当做采集对象和Prometheus的代理,Prometheus会定时的从gateway上面pull数据。
由于服务部署在容器中,服务的ip会经常的变化,导致Prometheus无法直接拉取到每个target的数据。
问题:
多个服务的数据,推送到pushgateway,如果push挂了,影响比较大

安装

从github上面 下载 ,已经编译好的二进制文件包。

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

tar -zxvf pushgateway-1.0.0.linux-amd64.tar.gz

mv pushgateway-1.0.0.linux-amd64 pushgateway-1.0.0

此时已经下载,安装完毕,进入到文件夹下执行就可以启动pushgateway了

[root@root pushgateway-1.0.0]# ll
总用量 16136
-rw-r--r-- 1 3434 3434    11357 10月 16 04:10 LICENSE
-rw-r--r-- 1 3434 3434      487 10月 16 04:10 NOTICE
-rwxr-xr-x 1 3434 3434 16505766 10月 16 03:58 pushgateway*
[root@root pushgateway-1.0.0]# ./pushgateway 
level=info ts=2019-12-17T06:56:17.315Z caller=main.go:81 msg="starting pushgateway" version="(version=1.0.0, branch=HEAD, revision=cc61f46971f5eb7a5be64e80c2ee03857ddbb41a)"
level=info ts=2019-12-17T06:56:17.315Z caller=main.go:82 build_context="(go=go1.13.1, user=root@58be538fc30e, date=20191015-19:58:18)"
level=info ts=2019-12-17T06:56:17.317Z caller=main.go:142 listen_address=:9091

访问 localhost:9091,出现一下界面为安装成功。
在这里插入图片描述

使用

client

TODO

http

  1. 提交一条数据到 {job=‘some_job’}
    echo "some_metric 3.14" | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/some_job
    在这里插入图片描述
    可以看到有个 UNTYPED 。因为没有提供了类型信息,所以some_metric将类型的无类型。
    因为我们只写了job的名称,所以可以看到instance那一列为 空字符串

  2. 下面我们加上instance的值
    echo "some_metrics 3.14" | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/some_job/instance/some_instance
    在这里插入图片描述
    可以看到pushgateway页面上产生了两个group,pgw是以job和instance分组的。用来更细力度的区分。

  3. 可以添加更多的标签,但是只会以job和instance区分
    官方的例子如下:

     cat <<EOF | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/some_job/instance/some_instance
      # TYPE some_metric counter
      some_metric{label="val1"} 42
      # TYPE another_metric gauge
      # HELP another_metric Just an example.
      another_metric 2398.283
      EOF
    

    看起来太复杂,可以这么简单写
    echo "some_metrics{tag=\"test\"} 3.14" | curl --data-binary @- http://127.0.0.1:9091/metrics/job/some_job/instance/some_instance

    可以看到,这次并没有新增一个group,而且在同一个group下也没用多出来,而是把上一个覆盖了。

  4. 删除某个组下某实例的所有数据
    curl -XDELETE http://pushgateway.example.org:9091/metrics/job/some_job/instance/some_instance

  5. 删除某个组下的所有数据
    curl -X DELETE http://pushgateway.example.org:9091/metrics/job/some_job

  6. 删除所有,需要开启 --web.enable-admin-api
    curl -X PUT http://pushgateway.example.org:9091/api/v1/admin/wipe

QA

  1. prometheus 的配置
    因为 Prometheus 配置 pushgateway 的时候,指定 job 和 instance, 但是它只表示 pushgateway 实例,不能真正表达收集数据的含义。所以在 prometheus 中配置 pushgateway 的时候,需要添加 honor_labels: true 参数, 从而避免收集数据被push本身的 job 和 instance 被覆盖。不加 honor_labels: true ,会取gateway的job和instance,设置了的话会取push过来的数据,job必填,instance没有就为 “” 空字符串
- job_name: pushgetway	
  honor_labels: true
  honor_timestamps: true
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets:
    - 127.0.0.1:9091
  1. pushgateway 的启动参数,快速启动下执行 ./pushgateway就可以启动一个实例。但是有时候我们需要定制化一些参数,此时就可以通过 ./pushgateway -h查看。
    效果如下:
[root@root pushgateway-1.0.0]# ./pushgateway  -h
usage: pushgateway [<flags>]

The Pushgateway

Flags:
  -h, --help                     Show context-sensitive help (also try --help-long and --help-man).
  	  #指定服务端口
      --web.listen-address=":9091"    Address to listen on for the web interface, API, and telemetry.
      #指定暴露出去的接口
      --web.telemetry-path="/metrics"   	Path under which to expose metrics.
      --web.external-url=        The URL under which the Pushgateway is externally reachable.
      --web.route-prefix=""      Prefix for the internal routes of web endpoints. Defaults to the path of --web.external-url.
      --web.enable-lifecycle     Enable shutdown via HTTP request.
      --web.enable-admin-api     Enable API endpoints for admin control actions.
      #持久化存储的地址,否则重启后采集的指标就没有了
      --persistence.file=""      File to persist metrics. If empty, metrics are only kept in memory.
      #持久化存储的间隔时间
      --persistence.interval=5m  The minimum interval at which to write out the persistence file.
      --log.level=info           Only log messages with the given severity or above. One of: [debug, info, warn, error]
      --log.format=logfmt        Output format of log messages. One of: [logfmt, json]
      --version                  Show application version.
  1. 为了防止 pushgateway 重启或意外挂掉,导致数据丢失,我们可以通过 -persistence.file 和 -persistence.interval 参数将数据持久化下来。
解决pushgateway数据多次推送会覆盖的问题 多个server,往同一台pushgateway推送数据时,采用同一个job名称,会发现始终只能留下一个server的数据,其他的会被覆盖使用语言 python通过抓包发现,所有数据均已推送到9091端口,所以排除是某个server推送的问题 相当于推送到了 metrics/job/job_name推送的指标按组进行管理,由任意数量标签的分组键标识,一般有Job跟instance,推送时候只指定Job的话,会误将几个server推送的数据当成同一组数据,出现覆盖的情况所以应该在分组标识中加入该批数据的唯 阅读详情

相关推荐

【prometheus】Pushgateway安装和使用

Pushgateway是prometheus的一个组件,prometheus server默认是通过exporter主动获取数据(默认采取pull拉取数据),pushgateway则是通过被动方式推送数据到prometheus server,用户可以写一些自定义的监控脚本把需要监控的数据发送给pushgateway, 然后pushgateway再把数据发送给Prometheus server。

m0_74825526的博客 1612

Prometheus监控实战系列十四:Pushgateway

Pushgateway为Prometheus整体监控方案的功能组件之一,并做为一个独立的工具存在。它主要用于Prometheus无法直接拿到监控指标的场景,如监控源位于防火墙之后,Prometheus无法穿透防火墙;目标服务没有可抓取监控数据的端点等多种情况。在类似场景中,可通过部署Pushgateway的方式解决问题。当部署该组件后,监控源通过主动发送监控数据到Pushgateway,再由Prometheus定时获取信息,实现资源的状态监控。

青梅煮酒 2227

pushgateway的安装与使用

pushgateway的安装使用

MssGuo的博客 3070

Prometheus:pushgateway使用

pushgateway的简单使用

m0_60125201的博客 2082

Pushgateway的场景使用

Pushgateway为Prometheus整体监控方案的功能组件之一,并做为一个独立的工具存在。它主要用于Prometheus无法直接拿到监控指标的场景,如监控源位于防火墙之后,Prometheus无法穿透防火墙;目标服务没有可抓取监控数据的端点等多种情况。在类似场景中,可通过部署Pushgateway的方式解决问题。当部署该组件后,监控源通过主动发送监控数据到Pushgateway,再由Prometheus定时获取信息,实现资源的状态监控。

一个行走江湖的人 2019

3D Slicer:从入门到精通(二)——入门指南

本篇文章包含开始使用3D Slicer所需的信息,包括如何安装和快速开始使用基本功能,以及在哪里找到更多信息。

walt3433的博客 2万+

Pushgateway 安装和使用

Pushgateway 安装和使用 安装 二进制安装 你可以到下载页面,选择对应的版本, 以 v0.4.0 为例子, 使用 wget 下载 pushgateway cd ~/Download https://github.com/prometheus/pushgateway/releases/download/v0.4.0/pushgateway-0.4.0.linux-amd64.ta...

秋天的博客 1万+

Windows 10/11 下用 Docker 一键部署 CVAT 标注工具(附 WSL2 配置指南)

本文详细指导如何在Windows 10/11系统上,通过配置WSL2和Docker Desktop,实现CVAT标注工具的一键部署。内容涵盖从环境准备、Docker安装、CVAT服务启动到性能优化与安全配置的全流程,为计算机视觉开发者提供稳定高效的本地标注平台解决方案。

weixin_28839601的博客 471

Pushgateway的安装与使用

我们在使用Prometheus进行监控应用时,常常需要一些设备的指标进行监控,我们常用的方式为一些exporter进行监控。但是一些应用并没有exporter,这时我们就需要使用Pushgateway进行拉取数据,最后推送到Prometheus上。

m0_71239320的博客 2748

Verilog中用于时序验证的系统任务[setup][hold][skew][width][recovery][removal]【STA静态时序分析】

下列时序检查语句错误的是() A. $setup(posedge clk, data, tSU) B. $hold(posedge clk, data, tHLD) C. $setuphold(posedge clk, data, tSU, tHLD) 答案:A 解析: 在时序检查函数中,$setup 函数比较特殊,格式是: $setup(data_event, reference_event, limit); 其他常见的检查是: $......(reference_...

DengFengLai123的博客 1万+

【图像去噪】论文复现:超分思想助力荧光显微图像自监督去噪!N2SR的Pytorch源码复现,图文详细教程跑通源码,框架结构原理示意图与代码对应,注释详细,补充三个实用功能代码!

论文题目:Noise2SR: Learning to Denoise from Super-Resolved Single Noisy Fluorescence Image —— Noise2SR:从超分辨率单噪声荧光图像中学习去噪【图像去噪】论文精读:Noise2SR: Learning to Denoise from Super-Resolved Single Noisy Fluorescence Image(N2SR)N2SR框架结构和原理都比较简单,创新点是加入超分,有很多类似的自监督框架;

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 641

Pushgateway安装部署和使用

源码地址:https://github.com/prometheus/pushgateway 下载安装包:https://github.com/prometheus/pushgateway/releases/download/v1.0.0/pushgateway-1.0.0.linux-amd64.tar.gz 解压文件 tar -zxvf pushgateway-1.0.0.linux-amd64.tar.gz 修改文件名 mv pushgateway-1.0.0.linux-amd64 pushgate

习惯了想你的博客 2792

Geogebra中级篇016—矩阵(Matrices)

在GeoGebra中,矩阵是一种强大的工具,广泛应用于线性代数、几何变换和数据处理等领域。通过矩阵,我们可以轻松实现复杂的计算和图形变换,如旋转、平移和缩放等操作。不仅如此,GeoGebra的矩阵功能还支持多种运算,如加法、乘法、求逆等,使得用户能够高效地处理线性方程组和向量空间问题。在本文中,我们将深入探讨GeoGebra中的矩阵功能,详细介绍如何创建矩阵、执行常见的矩阵运算,并通过实例展示这些操作在数学和工程应用中的实际价值。这篇文章将为你提供关于GeoGebra矩阵操作的全面指南。

八荒启-交互动画的博客 2595
上一篇: Linux find 常用语法
下一篇: Nginx安装及使用nginx-vts-exporter监控Nginx状态信息
习惯了想你
博客等级 码龄15年 12粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值