filter = makeNameFilter(request.getParameterValues("name[]"));
+ if (filter != null) {
+ return registry.scrape(filter, request);
+ } else {
+ return registry.scrape(request);
+ }
+ }
+
private boolean writeDebugResponse(MetricSnapshots snapshots, PrometheusHttpExchange exchange)
throws IOException {
String debugParam = exchange.getRequest().getParameter("debug");
@@ -157,7 +157,8 @@ private boolean writeDebugResponse(MetricSnapshots snapshots, PrometheusHttpExch
body.write(
("debug="
+ debugParam
- + ": Unsupported query parameter. Valid values are 'openmetrics', 'text', and 'prometheus-protobuf'.")
+ + ": Unsupported query parameter. Valid values are 'openmetrics', "
+ + "'text', and 'prometheus-protobuf'.")
.getBytes(StandardCharsets.UTF_8));
break;
}
diff --git a/prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/DefaultHandler.java b/prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/DefaultHandler.java
index eeb2f70f6..506da12bc 100644
--- a/prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/DefaultHandler.java
+++ b/prometheus-metrics-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/DefaultHandler.java
@@ -21,15 +21,19 @@ public DefaultHandler() {
+ "Metrics Path
\n"
+ "The metrics path is /metrics.\n"
+ "Name Filter
\n"
- + "If you want to scrape only specific metrics, use the name[] parameter like this:\n"
+ + "If you want to scrape only specific metrics, "
+ + "use the name[] parameter like this:\n"
+ "\n"
+ "You can also use multiple name[] parameters to query multiple metrics:\n"
+ "\n"
- + "The name[] parameter can be used by the Prometheus server for scraping. Add the following snippet to your scrape job configuration in prometheus.yaml:\n"
+ + "The name[] parameter can be used by the Prometheus server for scraping. "
+ + "Add the following snippet to your scrape job configuration in "
+ + "prometheus.yaml:\n"
+ "\n"
+ "params:\n"
+ " name[]:\n"
@@ -38,16 +42,28 @@ public DefaultHandler() {
+ "
\n"
+ "Debug Parameter
\n"
+ "The Prometheus Java metrics library supports multiple exposition formats.\n"
- + "The Prometheus server sends the Accept header to indicate which format it accepts.\n"
- + "By default, the Prometheus server accepts OpenMetrics text format, unless the Prometheus server is started with feature flag --enable-feature=native-histograms,\n"
+ + "The Prometheus server sends the Accept header "
+ + "to indicate which format it accepts.\n"
+ + "By default, the Prometheus server accepts OpenMetrics text format, "
+ + "unless the Prometheus server is started with feature flag "
+ + "--enable-feature=native-histograms,\n"
+ "in which case the default is Prometheus protobuf.\n"
- + "The Prometheus Java metrics library supports a debug query parameter for viewing the different formats in a Web browser:\n"
+ + "The Prometheus Java metrics library supports a debug query parameter "
+ + "for viewing the different formats in a Web browser:\n"
+ "\n"
- + "Note that the debug parameter is only for viewing different formats in a Web browser, it should not be used by the Prometheus server for scraping. The Prometheus server uses the Accept header for indicating which format it accepts.\n"
+ + "Note that the debug parameter is only for viewing different formats in a "
+ + "Web browser, it should not be used by the Prometheus server for scraping. "
+ + "The Prometheus server uses the Accept "
+ + "header for indicating which format it accepts.\n"
+ "