Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 在Spring Boot中将度量推送到Prometheus Pushgateway_Spring Boot_Prometheus_Prometheus Pushgateway - Fatal编程技术网

Spring boot 在Spring Boot中将度量推送到Prometheus Pushgateway

Spring boot 在Spring Boot中将度量推送到Prometheus Pushgateway,spring-boot,prometheus,prometheus-pushgateway,Spring Boot,Prometheus,Prometheus Pushgateway,我希望通过Spring引导应用程序中的Pushgateway将度量(例如HTTP请求的处理时间或当前堆大小)推送到Prometheus 我很挣扎,因为有很多文档,要么来自Spring Metrics,要么来自Prometheus,但它们都没有解决我的具体问题 最简单的方法是在RestController类上使用@Timed注释,如下所述: 但是,我看不到,我可以在哪里为pushgateway配置一个URL,并问自己@Timed注释是否只是将度量导出到/prometheus端点,在那里它们应该被提

我希望通过Spring引导应用程序中的Pushgateway将度量(例如HTTP请求的处理时间或当前堆大小)推送到Prometheus

我很挣扎,因为有很多文档,要么来自Spring Metrics,要么来自Prometheus,但它们都没有解决我的具体问题

最简单的方法是在RestController类上使用
@Timed
注释,如下所述: 但是,我看不到,我可以在哪里为pushgateway配置一个URL,并问自己
@Timed
注释是否只是将度量导出到
/prometheus
端点,在那里它们应该被提取出来

然而,普罗米修斯指南告诉我使用
simpleclient\u pushgateway
库:

最后,还有另一个名为
simpleclient\u spring\u boot
的simpleclient,这是将普罗米修斯集成到spring boot中的第三种方法

你能告诉我,我怎样才能做到

A) 从HTTP请求的首选基于注释的方法推送度量

B) 每x秒一次JVM度量的一些方法

C) 到可配置的(在
application.yml
文件中)pushgateway


非常感谢

这是一种错误的方法,pushgateway不是针对每个实例的指标,如堆大小或请求计时()


您要做的是使用
simpleclient\u spring\u boot
来公开一个
/metrics
端点,普罗米修斯会直接刮取该端点

抱歉,我应该说明为什么我需要pushgateway:-)我们的应用程序部署到Cloud Foundry。根据当前响应请求的实例,使用Prometheus轮询它们将产生不同的值。这就是为什么我喜欢将每个实例的指标推送到pushgateway,并在Grafana中加以区分。这仍然不是解决问题的推荐方法。我相信使用Cloud Foundry的方法是进行一些服务发现,然后添加一个HTTP头来与正确的实例进行对话。@brian brazil-你能解释一下为什么这不是正确的方法吗?假设有多个Sprint引导服务,它们充当多个工作人员。工人数量可根据系统负载进行配置(docker scale)。每个工作进程不公开HTTP端口,只处理一些作业处理。这仍然是错误的做法吗?