一、介绍
prometheus采集方式:
1.prometheus pull方式采集服务指标
2.服务push指标到pushgateway服务,prometheus再去pull pushgateway服务指标
注:与pull方式不同的是,push方式到pushgateway, 然后prometheus在拉取pushgateway数据的时候获取的是最后一次推送的数据。所以一般设置推送时间小于拉取时间
二、步骤
1.方式1:api+二进制文档
官网地址:
https://github.com/prometheus/pushgateway
例:
echo "some_metric 3.14" | curl --data-binary @- http://pushgateway.example.org:9091/metrics/job/some_job
方式二:官网sdk: java\python\go 等
以java为例子
官网地址:
https://github.com/prometheus/client_java
例:
pom.xml
<!-- The client -->
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>