diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/asciidoc/endpoints/prometheus.adoc b/spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/asciidoc/endpoints/prometheus.adoc index f79085a588..4ecc936708 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/asciidoc/endpoints/prometheus.adoc +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/asciidoc/endpoints/prometheus.adoc @@ -6,15 +6,15 @@ The `prometheus` endpoint provides Spring Boot application's metrics in the form [[prometheus-retrieving]] -== Retrieving the Metrics +== Retrieving All Metrics -To retrieve the metrics, make a `GET` request to `/actuator/prometheus`, as shown in the following curl-based example: +To retrieve all metrics, make a `GET` request to `/actuator/prometheus`, as shown in the following curl-based example: -include::{snippets}/prometheus/curl-request.adoc[] +include::{snippets}/prometheus/all/curl-request.adoc[] The resulting response is similar to the following: -include::{snippets}/prometheus/http-response.adoc[] +include::{snippets}/prometheus/all/http-response.adoc[] @@ -25,4 +25,18 @@ The endpoint uses query parameters to limit the samples that it returns. The following table shows the supported query parameters: [cols="2,4"] -include::{snippets}/prometheus/request-parameters.adoc[] +include::{snippets}/prometheus/names/request-parameters.adoc[] + + + +[[prometheus-retrieving-names]] +== Retrieving Filtered Metrics + +To retrieve metrics matching specific names, make a `GET` request to `/actuator/prometheus` with the `includedNames` query parameter, as shown in the following curl-based example: + +include::{snippets}/prometheus/names/curl-request.adoc[] + +The resulting response is similar to the following: + +include::{snippets}/prometheus/names/http-response.adoc[] + diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/PrometheusScrapeEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/PrometheusScrapeEndpointDocumentationTests.java index a1e1e36b03..9e7c338d7c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/PrometheusScrapeEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/PrometheusScrapeEndpointDocumentationTests.java @@ -43,7 +43,7 @@ class PrometheusScrapeEndpointDocumentationTests extends MockMvcEndpointDocument @Test void prometheus() throws Exception { - this.mockMvc.perform(get("/actuator/prometheus")).andExpect(status().isOk()).andDo(document("prometheus")); + this.mockMvc.perform(get("/actuator/prometheus")).andExpect(status().isOk()).andDo(document("prometheus/all")); } @Test @@ -52,7 +52,7 @@ class PrometheusScrapeEndpointDocumentationTests extends MockMvcEndpointDocument .perform(get("/actuator/prometheus").param("includedNames", "jvm_memory_used_bytes,jvm_memory_committed_bytes")) .andExpect(status().isOk()) - .andDo(document("prometheus", requestParameters(parameterWithName("includedNames") + .andDo(document("prometheus/names", requestParameters(parameterWithName("includedNames") .description("Restricts the samples to those that match the names. Optional.").optional()))); }