From f24bcf933cd44fd4ffcc824ab65dc32f7f9141f0 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 2 Oct 2019 10:49:12 +0200 Subject: [PATCH] dnsdist: Deduplicate DoH frontend names in prometheus --- pdns/dnsdist-web.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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"; -- 2.40.0