From: Gibheer Date: Tue, 11 Sep 2018 18:48:13 +0000 (+0200) Subject: add more variables to dnsdist carbon keys X-Git-Tag: auth-4.2.0-alpha1~49^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=813b0ba930ddb7c191aeb4e55580c4b1decb3ecd;p=thirdparty%2Fpdns.git add more variables to dnsdist carbon keys dnsdist provides a couple metrics through the carbon system, which were not variable enough to be used in larger environments. With this commit two more variables are introduced, namespace and instance, to make it easier to group metrics in different groups. --- diff --git a/pdns/dnsdist-carbon.cc b/pdns/dnsdist-carbon.cc index 860657d586..0e879ae6a0 100644 --- a/pdns/dnsdist-carbon.cc +++ b/pdns/dnsdist-carbon.cc @@ -54,6 +54,10 @@ try for (const auto& conf : *localCarbon) { const auto& server = conf.server; + std::string namespace_name = conf.namespace_name; + if(namespace_name.empty()) { + namespace_name="dnsdist"; + } std::string hostname = conf.ourname; if(hostname.empty()) { char tmp[80]; @@ -64,6 +68,10 @@ try hostname=tmp; boost::replace_all(hostname, ".", "_"); } + std::string instance_name = conf.instance_name; + if(instance_name.empty()) { + instance_name="main"; + } try { Socket s(server.sin4.sin_family, SOCK_STREAM); @@ -72,7 +80,7 @@ try ostringstream str; time_t now=time(0); for(const auto& e : g_stats.entries) { - str<<"dnsdist."<(&e.second)) str<<(*val)->load(); else if (const auto& dval = boost::get(&e.second)) @@ -85,7 +93,7 @@ try for(const auto& state : *states) { string serverName = state->name.empty() ? (state->remote.toString() + ":" + std::to_string(state->remote.getPort())) : state->getName(); boost::replace_all(serverName, ".", "_"); - const string base = "dnsdist." + hostname + ".main.servers." + serverName + "."; + const string base = instance_name + "." + hostname + "." + instance_name + ".servers." + serverName + "."; str<queries.load() << " " << now << "\r\n"; str<reuseds.load() << " " << now << "\r\n"; str<availability != DownstreamState::Availability::Down ? state->latencyUsec/1000.0 : 0) << " " << now << "\r\n"; @@ -98,7 +106,7 @@ try string frontName = front->local.toString() + ":" + std::to_string(front->local.getPort()) + (front->udpFD >= 0 ? "_udp" : "_tcp"); boost::replace_all(frontName, ".", "_"); - const string base = "dnsdist." + hostname + ".main.frontends." + frontName + "."; + const string base = namespace_name + "." + hostname + "." + instance_name + ".frontends." + frontName + "."; str<queries.load() << " " << now << "\r\n"; } auto localPools = g_pools.getLocal(); @@ -108,7 +116,7 @@ try if (poolName.empty()) { poolName = "_default_"; } - const string base = "dnsdist." + hostname + ".main.pools." + poolName + "."; + const string base = namespace_name + "." + hostname + "." + instance_name + ".pools." + poolName + "."; const std::shared_ptr pool = entry.second; str<countServers(false) << " " << now << "\r\n"; str<countServers(true) << " " << now << "\r\n"; diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index c66e1f217b..a875b9d6b7 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -874,7 +874,9 @@ void removeServerFromPool(pools_t& pools, const string& poolName, std::shared_pt struct CarbonConfig { ComboAddress server; + std::string namespace_name; std::string ourname; + std::string instance_name; unsigned int interval; };