一、环境:

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. GIL-Guilds(黑白灰染色)

    传送门门门门门咩咩咩咩咩咩咩咩咩咩咩咩 \(这题真是扯谈!!!\) \(灰色很高级是吧,但是题目没要你把颜色全部用上去啊!!!\) \(黑色或者白色只有一个条件,但灰色需要和所有三种颜色都相邻.这么难 ...

  2. SpringBoot:整合Shiro

    目录 1.Shiro简介 1.1.什么是Shiro? 1.2.有哪些功能 1.3.Shiro架构(外部) 1.4.Shiro架构(内部) 2.HelloWorld 3.Shiro整合Spring Bo ...

  3. restful 架构风格的curd(增删改查)

    restful架构 概念:REST指的是一组架构约束条件和原则,如果一个架构符合REST的约束条件和原则,就称之为RESTful架构. restful不是一个专门的技术,他是一个规范.规范就是写写代码 ...

  4. SpringCloud 踩坑之 注册中心绑定端口一直是8080

    今天在启动注册中心服务时,突然端口一直是8080,找了好久一直没找到原因,先看看我有问题的配置 spring: application: name: eureka-server profiles: d ...

  5. Day_09【常用API】扩展案例7_验证QQ号是否正确

    需求说明 请用户输入一个"QQ号码",我们来判断这个QQ号码是否正确 要求:使用方法来完成判断功能 验证规则: 1)必须是5-12位数字: 2)首位不能是0: package co ...

  6. Ubuntu 配置/etc/fstab参数实现开机自动挂载硬盘

    文章目录 前言 fstab 参数含义 实现步骤 1 查看硬盘信息,并找到需要进行挂载的硬盘 2 sudo mkfs.ext4 /dev/sdc 3 sudo mkdir /home/diska 4 查 ...

  7. Spring Boot 入门(十三):集成Hasor的Dataway模块,干掉后台,自动配置接口

    终于出湖北了,封闭2个月,家里没电脑,感觉好久没自主撸代码啊啊啊啊啊啊啊啊啊啊啊啊啊. 连接上篇文章Spring Boot 入门(十二):报表导出,对比poi.jxl和esayExcel的效率,继续从 ...

  8. python爬虫-直播吧

    概述 这是一个我很喜欢的小网站,想了解这个网站先从爬虫开始,爬取直播吧所有的栏目及内容,再存入数据库.先写个简单点的,后期再不断的优化下. 准备阶段 直播吧网址https://www.zhibo8.c ...

  9. Gradle 多环境、多渠道打包

    最近项目从eclipse迁移到AS上,主要是为了使用gradle这个插件进行apk打包.毕竟程序员还是要与时俱进的.首先介绍下项目主要需求: 1.使用百度统计,需要对个平台的信息进行统计 2..api ...

  10. springmvc 校验--JSR

    1.使用JSR规范是简单使用的,如果使用hibernate校验则需要在工程中添加hibernate-validate.jar,以及其他依赖的jar包. 2,在mvc配置文件中使用<mvc:ann ...