]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Adjust Content-Type header for Prometheus endpoint to include version 15501/head
authorWouter de Vries <wouter@cloudflare.com>
Tue, 21 Jan 2025 14:18:57 +0000 (15:18 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 30 Apr 2025 10:04:01 +0000 (12:04 +0200)
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/

(cherry picked from commit f572f31ecd8d76793f1f5864ab740f6f7f7e2b84)

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

index 000579e4b603b4eb84938e8231117a3d1f4df2f5..225c06647fb50ba7c1d9085e43192244b5a7b819 100644 (file)
@@ -913,7 +913,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";
 }
 #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 af2cbfee3ea25517e16594abd1100ffdb7e69f1b..823458447c2b020698e66278467251622cb9ee8d 100644 (file)
@@ -562,7 +562,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 9c82d7dafa0f31b0fd4441e5269ec26d6dc39e5e..6f0e387ff60e72e2420dfc4a51c02516a6f16790 100644 (file)
@@ -2664,7 +2664,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;
 }