]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth api: add includerings option to statistics endpoint 8784/head
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 5 Feb 2020 16:19:05 +0000 (17:19 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 5 Feb 2020 21:40:08 +0000 (22:40 +0100)
docs/http-api/swagger/authoritative-api-swagger.yaml
pdns/ws-api.cc

index ab0cbdf90359c2d34b61b13bf473aae4272bf6f2..be8ca834a2a4827e2b5f403aeae81833a98f411e 100644 (file)
@@ -412,7 +412,12 @@ paths:
           description: |
             When set to the name of a specific statistic, only this value is returned.
             If no statistic with that name exists, the response has a 422 status and an error message.
-
+        - name: includerings
+          in: query
+          required: false
+          type: boolean
+          default: true
+          description: '“true” (default) or “false”, whether to include the Ring items, which can contain thousands of log messages or queried domains. Setting this to ”false” may make the response a lot smaller.'
       responses:
         '200':
           description: List of Statistic Items
index 54dde00791283a1525a55aec8e4e94d5f73db71d..64c87efa33a189e48a521689d62773a72c07be45 100644 (file)
@@ -248,25 +248,28 @@ void apiServerStatistics(HttpRequest* req, HttpResponse* resp) {
   }
 
 #ifndef RECURSOR
-  for(const auto& ringName : S.listRings()) {
-    Json::array values;
-    const auto& ring = S.getRing(ringName);
-    for(const auto& item : ring) {
-      if (item.second == 0)
-        continue;
-
-      values.push_back(Json::object {
-        { "name", item.first },
-        { "value", std::to_string(item.second) },
+  if (!req->getvars.count("includerings") ||
+       req->getvars["includerings"] != "false") {
+    for(const auto& ringName : S.listRings()) {
+      Json::array values;
+      const auto& ring = S.getRing(ringName);
+      for(const auto& item : ring) {
+        if (item.second == 0)
+          continue;
+
+        values.push_back(Json::object {
+          { "name", item.first },
+          { "value", std::to_string(item.second) },
+        });
+      }
+
+      doc.push_back(Json::object {
+        { "type", "RingStatisticItem" },
+        { "name", ringName },
+        { "size", std::to_string(S.getRingSize(ringName)) },
+        { "value", values },
       });
     }
-
-    doc.push_back(Json::object {
-      { "type", "RingStatisticItem" },
-      { "name", ringName },
-      { "size", std::to_string(S.getRingSize(ringName)) },
-      { "value", values },
-    });
   }
 #endif