From: Remi Gacogne Date: Wed, 2 Oct 2019 08:49:12 +0000 (+0200) Subject: dnsdist: Deduplicate DoH frontend names in prometheus X-Git-Tag: dnsdist-1.4.0-rc4~49^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f24bcf933cd44fd4ffcc824ab65dc32f7f9141f0;p=pdns dnsdist: Deduplicate DoH frontend names in prometheus --- diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 5fd44725c..e081e007b 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -611,8 +611,15 @@ static void connectionThread(int sock, ComboAddress remote) output << "# TYPE " << frontsbase << "doh_version_status_responses " << "counter" << "\n"; #ifdef HAVE_DNS_OVER_HTTPS + std::map dohFrontendDuplicates; for(const auto& doh : g_dohlocals) { - const std::string addrlabel = boost::str(boost::format("address=\"%1%\" ") % doh->d_local.toStringWithPort()); + string frontName = doh->d_local.toStringWithPort(); + auto dupPair = frontendDuplicates.insert({frontName, 1}); + if (!dupPair.second) { + frontName = frontName + "_" + std::to_string(dupPair.first->second); + ++(dupPair.first->second); + } + const std::string addrlabel = boost::str(boost::format("address=\"%1%\"") % frontName); const std::string label = "{" + addrlabel + "} "; output << frontsbase << "http_connects" << label << doh->d_httpconnects << "\n";