javascript
带Prometheus的Spring Boot和测微表第4部分:基础项目
在以前的文章中,我們介紹了Spring Micrometer和InfluxDB。 所以你要問我為什么普羅米修斯。
原因是Prometheus在InfluxDB的拉模型與推模型上進行操作。
這意味著,如果將千分尺與InfluxDB一起使用,則在將結果推送到數據庫中時肯定會有一些開銷,并且使InfluxDB數據庫始終可用于處理所有請求是一個額外的痛苦點。
那么,如果不是推送數據而是使用其他工具從應用程序中提取數據怎么辦?
這是使用Prometheus可以獲得的東西之一。 通過使用普羅米修斯,您可以從應用程序中請求數據,而不必接收數據。
因此,我們要做的是使用與第一個教程完全相同的項目。
所需的唯一更改應在applicaiton.yaml以及pom.xml上
我們將從pom.xml開始,并為prometheus添加千分尺二進制。
<? xml version = "1.0" encoding = "UTF-8" ?> < project xmlns = " http://maven.apache.org/POM/4.0.0 " xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation = " http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd " > < modelVersion >4.0.0</ modelVersion > < parent > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-starter-parent</ artifactId > < version >2.2.4.RELEASE</ version > </ parent > < groupId >com.gkatzioura</ groupId > < artifactId >spring-prometheus-micrometer</ artifactId > < version >1.0-SNAPSHOT</ version > < properties > < micrometer.version >1.3.2</ micrometer.version > </ properties > < build > < defaultGoal >spring-boot:run</ defaultGoal > < plugins > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-compiler-plugin</ artifactId > < configuration > < source >8</ source > < target >8</ target > </ configuration > </ plugin > < plugin > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-maven-plugin</ artifactId > </ plugin > </ plugins > </ build > < dependencies > < dependency > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-starter-webflux</ artifactId > </ dependency > < dependency > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-starter-actuator</ artifactId > </ dependency > < dependency > < groupId >io.micrometer</ groupId > < artifactId >micrometer-core</ artifactId > < version >${micrometer.version}</ version > </ dependency > < dependency > < groupId >io.micrometer</ groupId > < artifactId >micrometer-registry-prometheus</ artifactId > < version >${micrometer.version}</ version > </ dependency > < dependency > < groupId >org.projectlombok</ groupId > < artifactId >lombok</ artifactId > < version >1.18.12</ version > < scope >provided</ scope > </ dependency > </ dependencies > </ project >然后,我們將添加啟用prometheus的application.yaml。
管理:
端點:
網絡: 接觸: 包括:普羅米修斯
現在,我們準備運行該應用程序。
> mvn spring-boot:run如果我們嘗試訪問執(zhí)行器,我們將看到普羅米修斯端點。
> curl http: //localhost:8080/actuator { "_links" : { "self" : { "href" : " http://localhost:8080/actuator " , "templated" : false }, "prometheus" : { "href" : " http://localhost:8080/actuator/prometheus " , "templated" : false } } } 這個“ http:// localhost:8080 / actuator / prometheus&#8221 ; 是我們的prometheus服務器用來提取數據的端點。
因此,我們的prometheus服務器需要配置為訪問該端點公開的這些數據。
在下一個博客中,我們將部署Prometheus并查看一些指標。
翻譯自: https://www.javacodegeeks.com/2020/05/spring-boot-and-micrometer-with-prometheus-part-4-the-base-project.html
總結
以上是生活随笔為你收集整理的带Prometheus的Spring Boot和测微表第4部分:基础项目的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 虚拟服务器ddos攻击(虚拟服务器ddo
- 下一篇: gradle idea java ssm