javascript
带Prometheus的Spring Boot和测微表第4部分:基础项目
在以前的文章中,我們介紹了Spring Micrometer和InfluxDB。 所以你要問(wèn)我為什么普羅米修斯。
原因是Prometheus在InfluxDB的拉模型與推模型上進(jìn)行操作。
這意味著,如果將千分尺與InfluxDB一起使用,則在將結(jié)果推送到數(shù)據(jù)庫(kù)中時(shí)肯定會(huì)有一些開(kāi)銷(xiāo),并且使InfluxDB數(shù)據(jù)庫(kù)始終可用于處理所有請(qǐng)求是一個(gè)額外的痛苦點(diǎn)。
那么,如果不是推送數(shù)據(jù)而是使用其他工具從應(yīng)用程序中提取數(shù)據(jù)怎么辦?
這是使用Prometheus可以獲得的東西之一。 通過(guò)使用普羅米修斯,您可以從應(yīng)用程序中請(qǐng)求數(shù)據(jù),而不必接收數(shù)據(jù)。
因此,我們要做的是使用與第一個(gè)教程完全相同的項(xiàng)目。
所需的唯一更改應(yīng)在applicaiton.yaml以及pom.xml上
我們將從pom.xml開(kāi)始,并為prometheus添加千分尺二進(jìn)制。
<? 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。
管理:
端點(diǎn):
網(wǎng)絡(luò): 接觸: 包括:普羅米修斯
現(xiàn)在,我們準(zhǔn)備運(yùn)行該應(yīng)用程序。
> mvn spring-boot:run如果我們嘗試訪問(wèn)執(zhí)行器,我們將看到普羅米修斯端點(diǎn)。
> curl http: //localhost:8080/actuator { "_links" : { "self" : { "href" : " http://localhost:8080/actuator " , "templated" : false }, "prometheus" : { "href" : " http://localhost:8080/actuator/prometheus " , "templated" : false } } } 這個(gè)“ http:// localhost:8080 / actuator / prometheus&#8221 ; 是我們的prometheus服務(wù)器用來(lái)提取數(shù)據(jù)的端點(diǎn)。
因此,我們的prometheus服務(wù)器需要配置為訪問(wèn)該端點(diǎn)公開(kāi)的這些數(shù)據(jù)。
在下一個(gè)博客中,我們將部署Prometheus并查看一些指標(biāo)。
翻譯自: https://www.javacodegeeks.com/2020/05/spring-boot-and-micrometer-with-prometheus-part-4-the-base-project.html
總結(jié)
以上是生活随笔為你收集整理的带Prometheus的Spring Boot和测微表第4部分:基础项目的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 虚拟服务器ddos攻击(虚拟服务器ddo
- 下一篇: 使用Zuul和Spring Boot创建