Skip to content

Commit

Permalink
Merge pull request #14557 from omoerbeek/rec-rpz-stats-always
Browse files Browse the repository at this point in the history
rec: always include all stats for RPZs in Prometheus data (previously zero stats would be skipped)
  • Loading branch information
omoerbeek authored Aug 23, 2024
2 parents af28b7b + d006282 commit c631b10
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pdns/recursordist/rec-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,10 @@ static void recursorThread()
checkFrameStreamExport(luaconfsLocal, luaconfsLocal->frameStreamExportConfig, t_frameStreamServersInfo);
checkFrameStreamExport(luaconfsLocal, luaconfsLocal->nodFrameStreamExportConfig, t_nodFrameStreamServersInfo);
#endif
for (const auto& rpz : luaconfsLocal->rpzs) {
string name = rpz.polName.empty() ? (rpz.primaries.empty() ? "rpzFile" : rpz.name) : rpz.polName;
t_Counters.at(rec::PolicyNameHits::policyName).counts[name] = 0;
}
}

t_fdm = unique_ptr<FDMultiplexer>(getMultiplexer(log));
Expand Down Expand Up @@ -3439,11 +3443,19 @@ void startLuaConfigDelayedThreads(const vector<RPZTrackerParams>& rpzs, uint64_t
}
}

static void* pleaseInitPolCounts(const string& name)
{
if (t_Counters.at(rec::PolicyNameHits::policyName).counts.count(name) == 0) {
t_Counters.at(rec::PolicyNameHits::policyName).counts[name] = 0;
}
return nullptr;
}

static void activateRPZFile(const RPZTrackerParams& params, LuaConfigItems& lci, shared_ptr<DNSFilterEngine::Zone>& zone)
{
auto log = lci.d_slog->withValues("file", Logging::Loggable(params.name));

zone->setName(params.polName);
zone->setName(params.polName.empty() ? "rpzFile" : params.polName);
try {
SLOG(g_log << Logger::Warning << "Loading RPZ from file '" << params.name << "'" << endl,
log->info(Logr::Info, "Loading RPZ from file"));
Expand Down Expand Up @@ -3519,10 +3531,11 @@ static void activateRPZs(LuaConfigItems& lci)
else {
DNSName domain(params.name);
zone->setDomain(domain);
zone->setName(params.polName);
zone->setName(params.polName.empty() ? params.name : params.polName);
params.zoneIdx = lci.dfe.addZone(zone);
activateRPZPrimary(params, lci, zone, domain);
}
broadcastFunction([name = zone->getName()] { return pleaseInitPolCounts(name); });
}
}

Expand Down

0 comments on commit c631b10

Please sign in to comment.