pushgateway安装使用
PushGateway使用说明
Prometheus
采用定时Pull
模式,可能由于子网络或者防火墙的原因,不能直接拉取各个Target
的指标数据,此时可以采用各个Target
往PushGateway
上Push
数据,然后Prometheus
去PushGateway
上定时pull
- 其次在监控各个业务数据时,需要将各个不同的业务数据进行统一汇总,此时也可以采用
PushGateway
来统一收集,然后Prometheus
来统一拉取 Prometheus
每次从PushGateway
拉取的数据,并不是拉取周期内用户推送上来的所有数据,而是最后一次Push
到PushGateway
上的数据- 指标值只能是数字类型,非数字类型报错
- 指标值支持最大长度为
16
位,超过16
位后默认置为0
安装
# 默认不持久化数据
docker run -d -p 9091:9091 prom/PushGateway # 指定持久化文件和保留时间
docker run -d -p 9091:9091 prom/pushgateway "-persistence.file=pg_file –persistence.interval=5m"
测试
# 单条推送
echo "test_metric 123456" | curl --data-binary @- http://192.168.41.128:9091/metrics/job/test_job# 多条推送
cat <<EOF | curl --data-binary @- http://192.168.41.128:9091/metrics/job/test_job/instance/test_instance
# TYPE test_metrics counter
test_metrics{label="app1",name="demo"} 100.00
# TYPE another_test_metrics gauge
# HELP another_test_metrics Just an example.
another_test_metrics 123.45
EOF# 通过文件
vim pg.txt
# TYPE http_request_total counter
# HELP http_request_total get interface request count with different code.
http_request_total{code="200",interface="/v1/save"} 276
http_request_total{code="404",interface="/v1/delete"} 0
http_request_total{code="500",interface="/v1/save"} 1
# TYPE http_request_time gauge
# HELP http_request_time get core interface http request time.
http_request_time{code="200",interface="/v1/core"} 0.122curl -XPOST --data-binary @pg.txt http://192.168.41.128:9091/metrics/job/app/instance/app-192.168.41.128
删除指标,参考官方
# {job="some_job",instance="some_instance"}
curl -X DELETE http://192.168.41.128:9091/metrics/job/some_job/instance/some_instance# {job="some_job"}
curl -X DELETE http://192.168.41.128:9091/metrics/job/some_job# 删除所有, 需要开启--web.enable-admin-api
curl -X PUT http://192.168.41.128:9091/api/v1/admin/wipe
通过SDK
上传:
<dependency><groupId>io.prometheus</groupId><artifactId>simpleclient_pushgateway</artifactId><version>0.7.0</version>
</dependency>
public static void main(String[] args) {try{String url = "192.168.41.128:9091";CollectorRegistry registry = new CollectorRegistry();Gauge guage = Gauge.build("my_custom_metric", "This is my custom metric.").create();guage.set(23.12);guage.register(registry);PushGateway pg = new PushGateway(url);Map<String, String> groupingKey = new HashMap<String, String>();groupingKey.put("instance", "my_instance");pg.pushAdd(registry, "my_job", groupingKey);} catch (Exception e){e.printStackTrace();}
}
public static void main(String[] args) {try{String url = "172.30.12.167:9091";CollectorRegistry registry = new CollectorRegistry();Gauge guage = Gauge.build("my_custom_metric", "This is my custom metric.").labelNames("app", "date").create();String date = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss").format(new Date());guage.labels("my-pushgateway-test-0", date).set(25);guage.labels("my-pushgateway-test-1", date).dec();guage.labels("my-pushgateway-test-2", date).dec(2);guage.labels("my-pushgateway-test-3", date).inc();guage.labels("my-pushgateway-test-4", date).inc(5);guage.register(registry);PushGateway pg = new PushGateway(url);Map<String, String> groupingKey = new HashMap<String, String>();groupingKey.put("instance", "my_instance");pg.pushAdd(registry, "my_job", groupingKey);} catch (Exception e){e.printStackTrace();}
}
查看
- pushgateway UI - http://192.168.41.128:9091
参考链接
- PROMETHEUS 使用 PUSHGATEWAY 进行数据上报采集
- 官方说明
pushgateway安装使用相关推荐
- prometheus+grafana+pushgateway+node-exporter+consul搭建监控系统
目录 一.总览 二.安装prometheus + grafana 三. 安装一个exporter 四.pushgateway安装 五. service discovery之consul 六.alert ...
- 二十七、prometheus部署安装配置告警
1.部署前简介 本次监控部署应用到的相关软件如下 prometheus 数据采集和存储 提供PromQL语法查询 alertmanager 警告管理 进行报警 node_exporter 收集主机的基 ...
- Prometheus 使用 PushGateway 进行数据上报采集
文章目录 1.PushGateway 介绍 2.环境.软件准备 3.PushGateway 安装配置 3.1.二进制包安装 3.2.Docker 安装 4.API 方式 Push 数据到 PushGa ...
- 【Kubernetes 企业项目实战】03、基于 Alertmanager 发送报警到多个接收方(下)
目录 一.promethues 采集 tomcat 监控数据 1.1 制作 tomcat 镜像 1.2 基于上面的镜像创建一个 tomcat 实例 1.3 采集数据 二.promethues 采集 r ...
- prometheus详解
二进制方式部署prometheus server https://www.cnblogs.com/knmax/p/9297213.html prometheus使用教程 https://www.jia ...
- 树莓派监控系统服务器,在树莓派3上搭建监控系统
目录: 之前用过tsar做监控,但没有基于浏览器的图表展示,而且tsar收集数据很频繁,容易写坏SD卡.后来一直用Xively SaaS服务,但因为服务在国外,访问速度一直不尽人意.直到今天早上读到I ...
- 【Docker】Docker 安装node-exporter prometheus pushgateway 页面显示Down
1.背景 prometheus配置如下 (base) lcc@lcc grafana-storage$ pwd /Users/lcc/soft/prometheus/grafana-storage $ ...
- 6.prometheus数据上报方式-pushgateway
6.prometheus数据上报方式-pushgateway 6.1.pushgateway下载.安装.启动 6.2.prometheus上配置target 6.3.push数据到pushgatewa ...
- 1.Prometheus快速入门,Prometheus+node_exporter安装
1.Prometheus快速入门 1.1.基本原理 2.Prometheus+node_exporter安装 2.1.环境准备:虚拟出机器 2.2.安装运行prometheus和node_export ...
最新文章
- PowerBI从SCCM数据库中分析数据和KPI展现
- windows server 2008 iis 添加ssl证书
- 淘宝服务端高并发分布式架构的十四次演进之路
- 每一个工程师都要学的安全测试,老板再也不用担心服务器被黑
- Angular Material 攻略 04 Icon
- 聊聊内卷之下,直博和读完硕士再读博该怎么选择?
- thinkphp mysql 密码加密_thinkphp微信开发(消息加密解密)
- 【C语言】找到兼职了心情紧张!
- HTML5开源RPG游戏引擎lufylegendRPG 1.0.0发布
- c语言有结构体的200行代码,C语言——结构体(示例代码)
- 前端常用PS技巧总结之将图片上的LOGO(水印)去掉
- 泛函分析 笔者一学期整理 感谢朱老师
- 公众号 接收规则 消息_微信公众号教程(11)公众账号接收非文字消息 上
- python爬取高德地图数据_你的未来有我导航----教你如何爬取高德地图
- SHA-256哈希函数实现
- java读取word文档的复杂表格_poi读取word表格 java POI 如何读取word的表格中的表格...
- 漫话:什么是 https ?这应该是全网把 https 讲的最好的一篇文章了
- Owndoor开门应用APP安卓苹果
- 机器学习讲座总结-读图时代的识图技术-车库咖啡
- Kanzi基础---Kanzi基本概念
热门文章
- Java游戏 斗地主
- 本科函授计算机管理毕业论文,浅谈成人本专科函授生《计算机实用基础》教学,毕业论文 - 论文助手...
- 【笔记整理 - C语言基础】
- 2018.10.24-dtij-2636-262144(game)
- CVPR 2020代码开源的论文最全合集
- revit版本linux,revit系列号2021版本的是什么?在哪里可以下载revit2021?
- 程序员应当更有机会创富
- matlab bwlable代码,matlab的bwlabel
- 软件架构设计学习总结(3):QQ空间技术架构之详解
- android瀑布流列表两边跳,Android Fragment + RecyclerView瀑布流布局