]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Adjust Content-Type header for Prometheus endpoint to include version 15072/head
authorWouter de Vries <wouter@cloudflare.com>
Tue, 21 Jan 2025 14:18:57 +0000 (15:18 +0100)
committerWouter de Vries <wouter@cloudflare.com>
Tue, 21 Jan 2025 14:25:37 +0000 (15:25 +0100)
Prometheus v3 will, by default, be more strict about the content-types
returned from scrape endpoints. With the current value (just
`text/plain`), it would fail to scrape.

In this commit the value is changed from `text/plain` to `text/plain;
version=0.0.4`.

See also [1] and [2]
[1] https://prometheus.io/docs/instrumenting/exposition_formats/
[2] https://prometheus.io/docs/prometheus/3.0/migration/

pdns/dnsdistdist/dnsdist-web.cc
pdns/recursordist/docs/http-api/prometheus.rst
pdns/recursordist/ws-recursor.cc
pdns/ws-auth.cc

index 253c00d3bb2d2f6c84b81dabf7cdbf027010d4ae..94db95c31ae1850f0f1048da3cb4e553fe0842d1 100644 (file)
@@ -918,7 +918,7 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp)
   output << "dnsdist_info{version=\"" << VERSION << "\"} " << "1" << "\n";
 
   resp.body = output.str();
-  resp.headers["Content-Type"] = "text/plain";
+  resp.headers["Content-Type"] = "text/plain; version=0.0.4";
   // clang-format on
 }
 #endif /* DISABLE_PROMETHEUS */
index 1fd9fd859e95868f0c081974c239187905aeb4b1..41407c2d50dbc36754cb73316908a4e21cc57d83 100644 (file)
@@ -18,7 +18,7 @@ Prometheus Data Endpoint
     HTTP/1.1 200 OK
     Connection: close
     Content-Length: 19203
-    Content-Type: text/plain
+    Content-Type: text/plain; version=0.0.4
     Server: PowerDNS/0.0.16480.0.g876dd46192
 
     # HELP pdns_recursor_all_outqueries Number of outgoing UDP queries since starting
index 36569d29c25e5c7199b51e91b1f30dcd81c6ce94..8e548ecdc413ac0a1c651317d4d5a8f5248a3fbc 100644 (file)
@@ -564,7 +564,7 @@ static void prometheusMetrics(HttpRequest* /* req */, HttpResponse* resp)
          << "\n";
 
   resp->body = output.str();
-  resp->headers["Content-Type"] = "text/plain";
+  resp->headers["Content-Type"] = "text/plain; version=0.0.4";
   resp->status = 200;
 }
 
index e0713e623ce3e084678fa3cbac5cea5d838a56e4..7fb9c6fe3822145b488c9b9baf0be39d103d54ac 100644 (file)
@@ -2667,7 +2667,7 @@ static void prometheusMetrics(HttpRequest* /* req */, HttpResponse* resp)
          << "\n";
 
   resp->body = output.str();
-  resp->headers["Content-Type"] = "text/plain";
+  resp->headers["Content-Type"] = "text/plain; version=0.0.4";
   resp->status = 200;
 }