]> granicus.if.org Git - pdns/commitdiff
dnsdist: Skip TCP metrics for UDP frontends over prometheus
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 26 Sep 2019 15:02:48 +0000 (17:02 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 26 Sep 2019 15:02:48 +0000 (17:02 +0200)
pdns/dnsdist-web.cc
pdns/dnsdist.hh

index 2ed1ab7f0e9815289dc762b0def94d5ffcf429a8..75497c5e7ae638adf4050e61badf363e7591e621 100644 (file)
@@ -564,16 +564,18 @@ static void connectionThread(int sock, ComboAddress remote)
             % frontName % proto);
 
           output << frontsbase << "queries" << label << front->queries.load() << "\n";
-          output << frontsbase << "tcpdiedreadingquery" << label << front->tcpDiedReadingQuery.load() << "\n";
-          output << frontsbase << "tcpdiedsendingresponse" << label << front->tcpDiedSendingResponse.load() << "\n";
-          output << frontsbase << "tcpgaveup" << label << front->tcpGaveUp.load() << "\n";
-          output << frontsbase << "tcpclientimeouts" << label << front->tcpClientTimeouts.load() << "\n";
-          output << frontsbase << "tcpdownstreamtimeouts" << label << front->tcpDownstreamTimeouts.load() << "\n";
-          output << frontsbase << "tcpcurrentconnections" << label << front->tcpCurrentConnections.load() << "\n";
-          output << frontsbase << "tcpavgqueriesperconnection" << label << front->tcpAvgQueriesPerConnection.load() << "\n";
-          output << frontsbase << "tcpavgconnectionduration" << label << front->tcpAvgConnectionDuration.load() << "\n";
-          output << frontsbase << "tlsnewsessions" << label << front->tlsNewSessions.load() << "\n";
-          output << frontsbase << "tlsresumptions" << label << front->tlsResumptions.load() << "\n";
+          if (front->isTCP()) {
+            output << frontsbase << "tcpdiedreadingquery" << label << front->tcpDiedReadingQuery.load() << "\n";
+            output << frontsbase << "tcpdiedsendingresponse" << label << front->tcpDiedSendingResponse.load() << "\n";
+            output << frontsbase << "tcpgaveup" << label << front->tcpGaveUp.load() << "\n";
+            output << frontsbase << "tcpclientimeouts" << label << front->tcpClientTimeouts.load() << "\n";
+            output << frontsbase << "tcpdownstreamtimeouts" << label << front->tcpDownstreamTimeouts.load() << "\n";
+            output << frontsbase << "tcpcurrentconnections" << label << front->tcpCurrentConnections.load() << "\n";
+            output << frontsbase << "tcpavgqueriesperconnection" << label << front->tcpAvgQueriesPerConnection.load() << "\n";
+            output << frontsbase << "tcpavgconnectionduration" << label << front->tcpAvgConnectionDuration.load() << "\n";
+            output << frontsbase << "tlsnewsessions" << label << front->tlsNewSessions.load() << "\n";
+            output << frontsbase << "tlsresumptions" << label << front->tlsResumptions.load() << "\n";
+          }
         }
 
         output << "# HELP " << frontsbase << "http_connects " << "Number of DoH TCP connections established to this frontend" << "\n";
index f9489349dd1361a697ab2310342b5188827667b5..ab5bf90aad8e424f41cea0d047b4990f52a0d30b 100644 (file)
@@ -704,6 +704,16 @@ struct ClientState
     return udpFD != -1 ? udpFD : tcpFD;
   }
 
+  bool isUDP() const
+  {
+    return udpFD != -1;
+  }
+
+  bool isTCP() const
+  {
+    return udpFD == -1;
+  }
+
   std::string getType() const
   {
     std::string result = udpFD != -1 ? "UDP" : "TCP";