Prometheus UI,用于spring boot应用程序的Grafana设置
我正在使用SpringBoot2.0,并在POM中添加了以下依赖项Prometheus UI,用于spring boot应用程序的Grafana设置,spring,spring-boot,prometheus,spring-boot-actuator,micrometer,Spring,Spring Boot,Prometheus,Spring Boot Actuator,Micrometer,我正在使用SpringBoot2.0,并在POM中添加了以下依赖项 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
在普罗米修斯用户界面中,我接下来要做的是什么,最终目标是将普罗米修斯集成到格拉法纳
PS:我在谷歌上做了一次搜索,尝试添加prometheus.yml和@EnablePrometheusEndpoint之类的注释,但由于所有的文章都是旧的,所以没有任何效果
编辑:如果spring boot jar托管在不同的主机(Azure/AWS)上,并且prometheus服务器位于不同的主机上,那么如何配置prometheus.yml(metrics\u path,targets)。如果您使用的是spring boot 2和Millomer,则不需要添加额外的依赖项,添加
测微计注册表prometheus
时,将导入它们。如果您能够看到localhost/manage/prometheus上的指标,那么您在spring引导端的配置就可以了。无需再进行任何配置
要查看普罗米修斯的指标,您需要:
UP
-(假设Prometheus在本地主机上运行)停机
,则存在配置或网络问题在windows上使用prometheus和grafana配置Spring引导api应用程序
org.springframework.boot
“您将获得所有指标
下载并安装Prometheus服务器
然后解压缩zip并运行prometheus exe
为此,您需要通过添加新作业来修改prometheus.yml文件(更改yml文件后不要忘记重新启动prometheus)
注意:使用prometheus配置spring应用程序
scrape_configs:
- job_name: 'SpringBootApplicationName
metrics_path: ‘actuator-prometheus'
static_configs:
- targets: [‘IPADDRESS:springBootApplicationPort]
刮取_配置:
-作业名称:“SpringBootApplicationName”
度量路径:“促动器普罗米修斯”
静态\u配置:
-目标:['IPADDRESS:springBootApplicationPort]
配置完成后,转到Prometheus UI,检查目标是否为UP
-(假设Prometheus在本地主机上运行)
转到“”并选择一个指标并粘贴-然后单击执行。例如,您可以选择一个CPU和HTTP指标,如“HTTP\u服务器\u请求\u秒数\u最大值”
以下步骤很简单,其他地方有很多文档:
下一步是从以下位置安装Grafana-
然后解压缩压缩文件并运行grafana-server.exe并检查浏览器“”
现在以默认用户名“admin”和密码“admin”登录,然后进入设置选择deshboard并创建数据源,然后选择prometheus并键入类似prometheus的url-”
然后转到graph并单击edit并选择datasource,然后键入度量查询,如“http\u服务器\u请求\u秒数\u最大值”
9.开始绘制度量标准
感谢Yarix的明确解释。现在我有另一个问题。我的微服务托管在Azure中。因此,我配置了metrics_path:,scheme:“https”,目标:['localhost:9090']。当我访问我的作业时,因为我看到的最终URL是错误的,如何解决这个问题microservice和prometheus需要在同一台主机上吗?度量路径是错误的,您应该只写“/manage/prometheus”或“/prometheus”,这取决于您如何配置spring引导。普罗米修斯服务器在哪里运行?也在蔚蓝?在应用程序的同一台机器上?目标应该是['yourSpringBootServer:port']Prometheus服务器正在我的本地计算机上运行。/manage/prometheus的metrics\u路径不起作用,因为主机不是我的本地。它不起作用,因为您的目标是错误的。目标应该是mywebapp.azure.com。另外,请确保您可以从本地计算机访问mywebapp.azure.com/manage/prometheus。它不起作用。它表示mywebapp.azure.com不是有效的主机名
scrape_configs:
- job_name: 'mySpringBoot'
metrics_path: '/manage/prometheus'
static_configs:
- targets: ['springBootHost:springBootPort']
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
scrape_configs:
- job_name: 'SpringBootApplicationName
metrics_path: ‘actuator-prometheus'
static_configs:
- targets: [‘IPADDRESS:springBootApplicationPort]