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: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8368%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Deduplicate DoH frontend names in prometheus --- diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 5fd44725c9..e081e007b2 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";