Skip to content

Commit da5e8d7

Browse files
committed
Polish "Support filtered scrape for Prometheus"
See gh-21545
1 parent cd1baf1 commit da5e8d7

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/docs/asciidoc/endpoints/prometheus.adoc

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ The `prometheus` endpoint provides Spring Boot application's metrics in the form
66

77

88
[[prometheus-retrieving]]
9-
== Retrieving the Metrics
9+
== Retrieving All Metrics
1010

11-
To retrieve the metrics, make a `GET` request to `/actuator/prometheus`, as shown in the following curl-based example:
11+
To retrieve all metrics, make a `GET` request to `/actuator/prometheus`, as shown in the following curl-based example:
1212

13-
include::{snippets}/prometheus/curl-request.adoc[]
13+
include::{snippets}/prometheus/all/curl-request.adoc[]
1414

1515
The resulting response is similar to the following:
1616

17-
include::{snippets}/prometheus/http-response.adoc[]
17+
include::{snippets}/prometheus/all/http-response.adoc[]
1818

1919

2020

@@ -25,4 +25,18 @@ The endpoint uses query parameters to limit the samples that it returns.
2525
The following table shows the supported query parameters:
2626

2727
[cols="2,4"]
28-
include::{snippets}/prometheus/request-parameters.adoc[]
28+
include::{snippets}/prometheus/names/request-parameters.adoc[]
29+
30+
31+
32+
[[prometheus-retrieving-names]]
33+
== Retrieving Filtered Metrics
34+
35+
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:
36+
37+
include::{snippets}/prometheus/names/curl-request.adoc[]
38+
39+
The resulting response is similar to the following:
40+
41+
include::{snippets}/prometheus/names/http-response.adoc[]
42+

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/PrometheusScrapeEndpointDocumentationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PrometheusScrapeEndpointDocumentationTests extends MockMvcEndpointDocument
4343

4444
@Test
4545
void prometheus() throws Exception {
46-
this.mockMvc.perform(get("/actuator/prometheus")).andExpect(status().isOk()).andDo(document("prometheus"));
46+
this.mockMvc.perform(get("/actuator/prometheus")).andExpect(status().isOk()).andDo(document("prometheus/all"));
4747
}
4848

4949
@Test
@@ -52,7 +52,7 @@ void filteredPrometheus() throws Exception {
5252
.perform(get("/actuator/prometheus").param("includedNames",
5353
"jvm_memory_used_bytes,jvm_memory_committed_bytes"))
5454
.andExpect(status().isOk())
55-
.andDo(document("prometheus", requestParameters(parameterWithName("includedNames")
55+
.andDo(document("prometheus/names", requestParameters(parameterWithName("includedNames")
5656
.description("Restricts the samples to those that match the names. Optional.").optional())));
5757
}
5858

0 commit comments

Comments
 (0)