一、环境:

1、prometheus服务器ip:192.168.0.208

2、node-exporter客户机ip:192.168.0.202

二、测试设计考虑:

  pushgateway类似一台信息收集中转机,其部署位置不受任何限制。本次测试,考虑把pushgateway部署在node-exporter客户机上,在prometheus服务器上编制信息收集和推送程序。

信息数据流程:

  1、prometheus服务器作为信息数据采集点,通过采集和推送程序向pushgateway端推送所采集的信息数据。

  2、prometheus服务器作为prometheus服务端,从pushgateway端拉取所需信息数据用于处理和展示。

二、配置过程

1、pushgateway服务端的安装

(1)pushgateway的image下载和安装

[root@DL ~]# docker search pushgateway      #查询可用pushgateway镜像

NAME DESCRIPTION STARS OFFICIAL AUTOMATED
prom/pushgateway The Prometheus Pushgateway allows ephemeral … 45 [OK]

[root@DL ~]# docker pull prom/pushgateway

(2)pushgateway服务的运行:

[root@DL ~]# docker run -d --name=pg -p 9091:9091 prom/pushgateway

2、prometheus服务器的配置

(1)prometheus服务器对pushgateway的监控配置

[root@ELK prometheus]# vi prometheus.yml

...

- job_name: 'pushgateway'

# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

static_configs:
- targets: ['192.168.0.202:9091']

配置完成后需要重启一下prometheus服务:docker restart prometheus

(2)数据采集和推送程序的编制

以采集netstat命令中处于wait状态的连接数为例:

[root@ELK prometheus]# vi node-exporter-shell.sh
#!/bin/bash
instance_name=`hostname -f | cut -d'.' -f1` #本机机器名 变量 用于之后的标签

if [[ $instanc_name == "localhost" ]];then #要求机器名不能是localhost,不然标签就没有区分了
echo "Must FQDN hostname"
exit 1
fi

# For waiting connections

label="count_netstat_wait_connections" #定义一个新的key
count_netstat_wait_connections=`netstat -an | grep -i wait | wc -l` #定义一个新的数值netstat中wait的数量

echo "$label:$count_netstat_wait_connections"
echo "$label $count_netstat_wait_connections" | curl --data-binary @- http://192.168.0.202:9091/metrics/job/pushgateway/instance/$instance_name   #推送键值对到pushgateway服务端

(3)数据采集程序的定时运行设置

[root@ELK prometheus]# crontab -e
* * * * * sleep 10;cd /root/prometheus; ./node-exporter-shell.sh    #设置每10秒采集和推送一次数据

三、测试

1、web访问:http://192.168.0.202:9091/ 可看到pushgateway的实时push状态

2、web访问:http://192.168.0.202:9091/metrics 可看到采集数据的键值对

# TYPE count_netstat_wait_connections untyped
count_netstat_wait_connections{instance="ELK",job="pushgateway"} 0 数据采集和推送程序来源:B站大米运维课堂

prometheus配置pushgateway功能测试的更多相关文章

  1. 基于Prometheus的Pushgateway实战

    一.Pushgateway 简介 Pushgateway 是 Prometheus 生态中一个重要工具,使用它的原因主要是: Prometheus 采用 pull 模式,可能由于不在一个子网或者防火墙 ...

  2. prometheus 配置介绍

    prometheus 配置介绍 prometheus 配置分global.alerting.rule_files.scrape_configs 1.global(全局配置) scrape_interv ...

  3. prometheus配置

    本文主要记录下测试环境积累的prometheus配置信息,主要是k8s基本节点的配置和cadvisor的配置,方便以后使用做为参考 global: scrape_interval: 30s scrap ...

  4. Prometheus 配置采集目标

    Prometheus 配置采集目标 1.根据配置的任务(job)以http/s周期性的收刮(scrape/pull)2.指定目标(target)上的指标(metric).目标(target)3.可以以 ...

  5. 实用干货丨如何使用Prometheus配置自定义告警规则

    前 言 Prometheus是一个用于监控和告警的开源系统.一开始由Soundcloud开发,后来在2016年,它迁移到CNCF并且称为Kubernetes之后最流行的项目之一.从整个Linux服务器 ...

  6. 神坑!为什么prometheus的pushgateway不能对上报的counter进行累加?

    部署了一个prometheus的pushgateway,然后两次对其发送counter类型的数据: #第一次发送 curl -X POST -d '# TYPE my_first_metric_ahf ...

  7. prometheus 配置容器 cadvisor监控节点

    安装cadvisor docker run \ --volume=/:/roofs:ro \ --volume=/var/run:/var/run:rw \ --volume=/sys:/sys:ro ...

  8. prometheus配置简介

    参考网页:https://my.oschina.net/wangyunlong/blog/3060776 global: scrape_interval:             15s evalua ...

  9. prometheus配置详情

    https://prometheus.io/docs/prometheus/latest/configuration/configuration/ 下面监控宿主机和容器的内存,CPU,磁盘等状态 gr ...

随机推荐

  1. Programming Languages_04 Deferred Substitution

    Deferred Substitution 在执行出现with时,利用"substitution",每次with的出现,它都绕着整个body置换.这一方式是由F1WAE到env再到 ...

  2. python学习之 %s %d 以及%变量名的含义

    %age是对前面age变量的引用,%d是将这个变量名为age的值加到其中,但是如果变量值为字符串类型,则这里应该写成%s 也就是说当变量值为数值类型,而且必须是整型类型 应该使用%d 当变量值为字符串 ...

  3. GUI_DOWNLOAD 下载乱码

    状况: 开发者打开正常,跨公司或跨企业打开异常. 跨App上传格式异常. 解决上述问题步骤: 1.用浏览器或可改变文件编码格式切换的软件打开文件(其他app上传正常文档格式,或跨公司打开正常文件)查看 ...

  4. 【HBase】集群搭建/安装部署

    目录 第一步:下载对应的HBase安装包 第二步:上传压缩包并解压 第三步:修改配置文件 第四步:安装包分发到另外两台机器 第五步:三台机器创建软连接 第六步:三台机器添加环境变量 第七步:启动HBa ...

  5. Day_11【集合】扩展案例2_使用普通for循环获取集合中索引为3的元素并打印,统计集合中包含字符串"def"的数量,删除集合中的所有字符串",将集合中每个元素中的小写字母变成大写字母def",

    分析以下需求,并用代码实现 1.定义ArrayList集合,存入多个字符串"abc" "def" "efg" "def" ...

  6. 1、Fiddler基础

    1.抓取https请求 前言 fiddler是一个很好的抓包工具,默认是抓http请求的,对于pc上的https请求,会提示网页不安全,这时候需要在浏览器上安装证书. 一.网页不安全 1.用fiddl ...

  7. lodash入门

    简介 Lodash是一个著名的javascript原生库,不需要引入其他第三方依赖.是一个意在提高开发者效率,提高JS原生方法性能的JS库.简单的说就是,很多方法lodash已经帮你写好了,直接调用就 ...

  8. JS的函数和对象三

    复习 判断是否含有某个属性 对象.属性名 === undefined 对象.hasOwnProperty('属性名') '属性名' in 对象 方法  { say:function(){  this ...

  9. HTML5新特性 websocket(重点)--多对多聊天室

    一.html5新特性  websocket(重点)--多对多聊天室 HTTP:超文本传输协议 HTTP作用:传输网页中资源(html;css;js;image;video;..) HTTP是浏览器搬运 ...

  10. Spring 依赖注入(DI)简介

    依赖注入的英文表示为dependency injection,缩写为DI. Spring框架的核心功能之一就是通过依赖注入的方式来管理Bean之间的依赖关系. 当编写一个复杂的 Java 应用程序时, ...