From: Remi Gacogne Date: Thu, 26 Sep 2019 15:02:48 +0000 (+0200) Subject: dnsdist: Skip TCP metrics for UDP frontends over prometheus X-Git-Tag: dnsdist-1.4.0-rc3^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a2ca389139e425b4f4af3ecc6febad8be8bd156;p=pdns dnsdist: Skip TCP metrics for UDP frontends over prometheus --- diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 2ed1ab7f0..75497c5e7 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -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"; diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index f9489349d..ab5bf90aa 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -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";