diff --git a/README.md b/README.md index 8946d26..d5a8778 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,12 @@ Run E2E testing: make build-image test-e2e ``` +Run with Maven command: + +```shell +mvn spring-boot:run +``` + ## OpenAPI definition You can visit it via: http://localhost:8080/v3/api-docs @@ -17,3 +23,6 @@ You can visit it via: http://localhost:8080/graphiql?path=/graphql ## tRPC The [tRPC](https://github.com/trpc-group/trpc-java) endpoint is: `http://localhost:9090` + +## Metrics +You can visit the metrics endpoint: `/actuator/prometheus` diff --git a/e2e/test-suite.yaml b/e2e/test-suite.yaml index 6ee672f..cf33d94 100644 --- a/e2e/test-suite.yaml +++ b/e2e/test-suite.yaml @@ -94,3 +94,8 @@ items: expect: bodyFieldsExpect: message: rick +- name: prometheus + request: + api: /actuator/prometheus + header: + Authorization: "{{ .param.auth }}" diff --git a/pom.xml b/pom.xml index ded614c..0e66390 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,15 @@ 1.1.0 + + org.springframework.boot + spring-boot-starter-actuator + + + io.micrometer + micrometer-registry-prometheus + + org.springframework.boot spring-boot-starter-test diff --git a/src/main/java/io/github/devopsws/demo/DemoApplication.java b/src/main/java/io/github/devopsws/demo/DemoApplication.java index 76845b8..50a769b 100644 --- a/src/main/java/io/github/devopsws/demo/DemoApplication.java +++ b/src/main/java/io/github/devopsws/demo/DemoApplication.java @@ -1,6 +1,7 @@ package io.github.devopsws.demo; import com.tencent.trpc.spring.boot.starters.annotation.EnableTRpc; + import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3e690f7..62d3b6d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -19,3 +19,13 @@ trpc: ip: 0.0.0.0 # Listen ip port: 9090 # Listen port network: tcp # Network type, tcp or udp + +# https://spring.academy/guides/spring-spring-prometheus +management: + endpoints: + web: + exposure: + include: health, metrics, prometheus + metrics: + tags: + application: ${spring.application.name}