From: Remi Gacogne Date: Mon, 15 Dec 2025 10:41:29 +0000 (+0100) Subject: dnsdist: Better conventions for structured logging keys X-Git-Tag: rec-5.4.0-beta1~33^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e5545822757f5c02ae520d48a6904ebf0f6fad1;p=thirdparty%2Fpdns.git dnsdist: Better conventions for structured logging keys Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnscrypt.cc b/pdns/dnsdistdist/dnscrypt.cc index 4dc670c5d5..95892c14ec 100644 --- a/pdns/dnsdistdist/dnscrypt.cc +++ b/pdns/dnsdistdist/dnscrypt.cc @@ -496,7 +496,7 @@ void DNSCryptQuery::getDecrypted(bool tcp, PacketBuffer& packet) #ifdef DNSCRYPT_STRICT_PADDING_LENGTH if (tcp && ((packet.size() - sizeof(DNSCryptQueryHeader)) % DNSCRYPT_PADDED_BLOCK_SIZE) != 0) { VERBOSESLOG(infolog("Dropping encrypted query with invalid size of %d (should be a multiple of %d)", (packet.size() - sizeof(DNSCryptQueryHeader)), DNSCRYPT_PADDED_BLOCK_SIZE), - dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted query with invalid size (should be a multiple of " DNSCRYPT_PADDED_BLOCK_SIZE, "size", Logging::Loggable(packet.size() - sizeof(DNSCryptQueryHeader)))); + dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted query with invalid size (should be a multiple of " DNSCRYPT_PADDED_BLOCK_SIZE, "dns.question.size", Logging::Loggable(packet.size() - sizeof(DNSCryptQueryHeader)))); return; } #endif @@ -562,7 +562,7 @@ void DNSCryptQuery::getDecrypted(bool tcp, PacketBuffer& packet) uint16_t pos = decryptedQueryLen; if (pos >= packet.size()) { VERBOSESLOG(infolog("Dropping encrypted query we can't decrypt (invalid position)"), - dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted we couldn't decrypt because of an invalid position", "position", Logging::Loggable(pos), "size", Logging::Loggable(packet.size()))); + dnsdist::logging::getTopLogger()->info("Dropping DNSCrypt-encrypted we couldn't decrypt because of an invalid position", "position", Logging::Loggable(pos), "dns.question.size", Logging::Loggable(packet.size()))); return; } diff --git a/pdns/dnsdistdist/dnsdist-actions-factory.cc b/pdns/dnsdistdist/dnsdist-actions-factory.cc index 290b29021c..111673ac00 100644 --- a/pdns/dnsdistdist/dnsdist-actions-factory.cc +++ b/pdns/dnsdistdist/dnsdist-actions-factory.cc @@ -1122,7 +1122,7 @@ public: if (!d_verboseOnly || dnsdist::configuration::getCurrentRuntimeConfiguration().d_verbose) { if (d_includeTimestamp) { SLOG(infolog("[%u.%u] Packet from %s for %s %s with id %d", static_cast(dnsquestion->getQueryRealTime().tv_sec), static_cast(dnsquestion->getQueryRealTime().tv_nsec), dnsquestion->ids.origRemote.toStringWithPort(), dnsquestion->ids.qname.toString(), QType(dnsquestion->ids.qtype).toString(), dnsquestion->getHeader()->id), - dnsquestion->getLogger()->info(Logr::Info, "Logging packet", "query-real-time-sec", Logging::Loggable(dnsquestion->getQueryRealTime().tv_sec), "query-real-time-nsec", Logging::Loggable(dnsquestion->getQueryRealTime().tv_nsec))); + dnsquestion->getLogger()->info(Logr::Info, "Logging packet", "dns.question.real_time_sec", Logging::Loggable(dnsquestion->getQueryRealTime().tv_sec), "dns.question.real_time_nsec", Logging::Loggable(dnsquestion->getQueryRealTime().tv_nsec))); } else { SLOG(infolog("Packet from %s for %s %s with id %d", dnsquestion->ids.origRemote.toStringWithPort(), dnsquestion->ids.qname.toString(), QType(dnsquestion->ids.qtype).toString(), dnsquestion->getHeader()->id), @@ -1177,7 +1177,7 @@ public: if (!reopenLogFile()) { int savederrno = errno; SLOG(warnlog("Unable to open file '%s' for logging: %s", d_fname, stringerror(savederrno)), - dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "file-name", Logging::Loggable(d_fname))); + dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "filename", Logging::Loggable(d_fname))); } } @@ -1239,7 +1239,7 @@ public: if (!d_verboseOnly || dnsdist::configuration::getCurrentRuntimeConfiguration().d_verbose) { if (d_includeTimestamp) { SLOG(infolog("[%u.%u] Answer to %s for %s %s (%s) with id %u", static_cast(response->getQueryRealTime().tv_sec), static_cast(response->getQueryRealTime().tv_nsec), response->ids.origRemote.toStringWithPort(), response->ids.qname.toString(), QType(response->ids.qtype).toString(), RCode::to_s(response->getHeader()->rcode), response->getHeader()->id), - response->getLogger()->info(Logr::Info, "Logging response packet", "query-real-time-sec", Logging::Loggable(response->getQueryRealTime().tv_sec), "query-real-time-nsec", Logging::Loggable(response->getQueryRealTime().tv_nsec))); + response->getLogger()->info(Logr::Info, "Logging response packet", "dns.question.real_time_sec", Logging::Loggable(response->getQueryRealTime().tv_sec), "dns.question.real_time_nsec", Logging::Loggable(response->getQueryRealTime().tv_nsec))); } else { SLOG(infolog("Answer to %s for %s %s (%s) with id %u", response->ids.origRemote.toStringWithPort(), response->ids.qname.toString(), QType(response->ids.qtype).toString(), RCode::to_s(response->getHeader()->rcode), response->getHeader()->id), @@ -1271,7 +1271,7 @@ public: if (!reopenLogFile()) { int savederrno = errno; SLOG(warnlog("Unable to open file '%s' for logging: %s", d_fname, stringerror(savederrno)), - dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "file-name", Logging::Loggable(d_fname))); + dnsdist::logging::getTopLogger()->error(Logr::Warning, savederrno, "Unable to open file for logging", "filename", Logging::Loggable(d_fname))); } } @@ -1524,17 +1524,17 @@ static void remoteLoggerQueueData(RemoteLoggerInterface& remoteLogger, const std break; case RemoteLoggerInterface::Result::PipeFull: { VERBOSESLOG(infolog("%s: %s", remoteLogger.name(), RemoteLoggerInterface::toErrorString(ret)), - dnsdist::logging::getTopLogger()->error(Logr::Info, RemoteLoggerInterface::toErrorString(ret), "Remote logger pipe full event", "remote-logger-name", Logging::Loggable(remoteLogger.name()))); + dnsdist::logging::getTopLogger()->error(Logr::Info, RemoteLoggerInterface::toErrorString(ret), "Remote logger pipe full event", "remote_logger_name", Logging::Loggable(remoteLogger.name()))); break; } case RemoteLoggerInterface::Result::TooLarge: { SLOG(warnlog("%s: %s", remoteLogger.name(), RemoteLoggerInterface::toErrorString(ret)), - dnsdist::logging::getTopLogger()->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger too large event", "remote-logger-name", Logging::Loggable(remoteLogger.name()))); + dnsdist::logging::getTopLogger()->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger too large event", "remote_logger_name", Logging::Loggable(remoteLogger.name()))); break; } case RemoteLoggerInterface::Result::OtherError: SLOG(warnlog("%s: %s", remoteLogger.name(), RemoteLoggerInterface::toErrorString(ret)), - dnsdist::logging::getTopLogger()->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger error event", "remote-logger-name", Logging::Loggable(remoteLogger.name()))); + dnsdist::logging::getTopLogger()->error(Logr::Warning, RemoteLoggerInterface::toErrorString(ret), "Remote logger error event", "remote_logger_name", Logging::Loggable(remoteLogger.name()))); } } diff --git a/pdns/dnsdistdist/dnsdist-async.cc b/pdns/dnsdistdist/dnsdist-async.cc index 65241b5f99..9cf8f9a8a3 100644 --- a/pdns/dnsdistdist/dnsdist-async.cc +++ b/pdns/dnsdistdist/dnsdist-async.cc @@ -136,7 +136,7 @@ void AsynchronousHolder::mainThread(std::shared_ptr data) expiredEvents.pop_front(); if (!data->d_failOpen) { VERBOSESLOG(infolog("Asynchronous query %d has expired at %d.%d, notifying the sender", queryID, now.tv_sec, now.tv_usec), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous query has expired, notifying the sender", "query-id", Logging::Loggable(queryID))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous query has expired, notifying the sender", "dns.question.id", Logging::Loggable(queryID))); auto sender = query->getTCPQuerySender(); if (sender) { TCPResponse tresponse(std::move(query->query)); @@ -145,7 +145,7 @@ void AsynchronousHolder::mainThread(std::shared_ptr data) } else { VERBOSESLOG(infolog("Asynchronous query %d has expired at %d.%d, resuming", queryID, now.tv_sec, now.tv_usec), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous query has expired, resuming", "query-id", Logging::Loggable(queryID))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous query has expired, resuming", "dns.question.id", Logging::Loggable(queryID))); resumeQuery(std::move(query)); } } @@ -186,7 +186,7 @@ std::unique_ptr AsynchronousHolder::get(uint16_t asyncID, ui timeval now{}; gettimeofday(&now, nullptr); VERBOSESLOG(infolog("Asynchronous object %d not found at %d.%d", queryID, now.tv_sec, now.tv_usec), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous object not found", "async-id", Logging::Loggable(asyncID), "query-id", Logging::Loggable(queryID))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Asynchronous object not found", "dnsdist.async.id", Logging::Loggable(asyncID), "dns.question.id", Logging::Loggable(queryID))); return nullptr; } @@ -360,7 +360,7 @@ bool suspendQuery(DNSQuestion& dnsQuestion, uint16_t asyncID, uint16_t queryID, normalizeTV(ttd); VERBOSESLOG(infolog("Suspending asynchronous query %d at %d.%d until %d.%d", queryID, now.tv_sec, now.tv_usec, ttd.tv_sec, ttd.tv_usec), - dnsQuestion.getLogger()->info(Logr::Info, "Suspending asynchronous query", "until-sec", Logging::Loggable(ttd.tv_sec), "until-usec", Logging::Loggable(ttd.tv_usec))); + dnsQuestion.getLogger()->info(Logr::Info, "Suspending asynchronous query", "dnsdist.async.until_sec", Logging::Loggable(ttd.tv_sec), "dnsdist.async.until_usec", Logging::Loggable(ttd.tv_usec))); auto query = getInternalQueryFromDQ(dnsQuestion, false); g_asyncHolder->push(asyncID, queryID, ttd, std::move(query)); @@ -381,7 +381,7 @@ bool suspendResponse(DNSResponse& dnsResponse, uint16_t asyncID, uint16_t queryI normalizeTV(ttd); VERBOSESLOG(infolog("Suspending asynchronous response %d at %d.%d until %d.%d", queryID, now.tv_sec, now.tv_usec, ttd.tv_sec, ttd.tv_usec), - dnsResponse.getLogger()->info(Logr::Info, "Suspending asynchronous response", "until-sec", Logging::Loggable(ttd.tv_sec), "until-usec", Logging::Loggable(ttd.tv_usec))); + dnsResponse.getLogger()->info(Logr::Info, "Suspending asynchronous response", "dnsdist.async.until_sec", Logging::Loggable(ttd.tv_sec), "dnsdist.async.until_usec", Logging::Loggable(ttd.tv_usec))); auto query = getInternalQueryFromDQ(dnsResponse, true); query->d_isResponse = true; query->downstream = dnsResponse.d_downstream; diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index 48ce881ec8..705a331399 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -130,7 +130,7 @@ bool DownstreamState::reconnect(bool initialAttempt) if (res != 0) { int saved = errno; SLOG(infolog("Error setting up the interface on backend socket '%s': %s", d_config.remote.toStringWithPort(), stringerror(saved)), - getLogger()->error(Logr::Info, saved, "Error setting up the interface on backend socket", "source-interface", Logging::Loggable(d_config.sourceItfName))); + getLogger()->error(Logr::Info, saved, "Error setting up the interface on backend socket", "source.interface", Logging::Loggable(d_config.sourceItfName))); } } #endif @@ -161,7 +161,7 @@ bool DownstreamState::reconnect(bool initialAttempt) if (initialAttempt || dnsdist::configuration::getCurrentRuntimeConfiguration().d_verbose) { if (!IsAnyAddress(d_config.sourceAddr) || !d_config.sourceItfName.empty()) { SLOG(infolog("Error connecting to new server with address %s (source address: %s, source interface: %s): %s", d_config.remote.toStringWithPort(), IsAnyAddress(d_config.sourceAddr) ? "not set" : d_config.sourceAddr.toString(), d_config.sourceItfName.empty() ? "not set" : d_config.sourceItfName, error.what()), - getLogger()->error(Logr::Info, error.what(), "Error connecting to server", "source-address", Logging::Loggable(d_config.sourceAddr), "source-interface", Logging::Loggable(d_config.sourceItfName))); + getLogger()->error(Logr::Info, error.what(), "Error connecting to server", "source.address", Logging::Loggable(d_config.sourceAddr), "source.interface", Logging::Loggable(d_config.sourceItfName))); } else { @@ -260,7 +260,7 @@ void DownstreamState::hash() { const auto hashPerturbation = dnsdist::configuration::getImmutableConfiguration().d_hashPerturbation; VERBOSESLOG(infolog("Computing hashes for id=%s and weight=%d, hash_perturbation=%d", *d_config.id, d_config.d_weight, hashPerturbation), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Computing hashes for backend", "id", Logging::Loggable(*d_config.id), "weight", Logging::Loggable(d_config.d_weight), "hash-perturbation", Logging::Loggable(hashPerturbation))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Computing hashes for backend", "backend.id", Logging::Loggable(*d_config.id), "backend.weight", Logging::Loggable(d_config.d_weight), "backend.hash_perturbation", Logging::Loggable(hashPerturbation))); auto weight = d_config.d_weight; auto idStr = boost::str(boost::format("%s") % *d_config.id); @@ -291,7 +291,7 @@ void DownstreamState::setWeight(int newWeight) { if (newWeight < 1) { SLOG(errlog("Error setting server's weight: downstream weight value must be greater than 0."), - getLogger()->info(Logr::Error, "Error setting server's weight: downstream weight value must be greater than 0", "weight", Logging::Loggable(newWeight))); + getLogger()->info(Logr::Error, "Error setting server's weight: downstream weight value must be greater than 0", "backend.weight", Logging::Loggable(newWeight))); return ; } @@ -460,7 +460,7 @@ void DownstreamState::handleUDPTimeout(IDState& ids) SLOG(infolog("Had a downstream timeout from %s (%s) for query for %s|%s from %s", d_config.remote.toStringWithPort(), getName(), ids.internal.qname.toLogString(), QType(ids.internal.qtype).toString(), ids.internal.origRemote.toStringWithPort()), - getLogger()->info(Logr::Info, "Had a downstream timeout", "qname", Logging::Loggable(ids.internal.qname), "qtype", Logging::Loggable(QType(ids.internal.qtype)), "query-id", Logging::Loggable(ids.internal.origID), "address", Logging::Loggable(ids.internal.origRemote))); + getLogger()->info(Logr::Info, "Had a downstream timeout", "dns.question.name", Logging::Loggable(ids.internal.qname), "dns.question.type", Logging::Loggable(QType(ids.internal.qtype)), "dns.question.id", Logging::Loggable(ids.internal.origID), "client.address", Logging::Loggable(ids.internal.origRemote))); const auto& chains = dnsdist::configuration::getCurrentRuntimeConfiguration().d_ruleChains; const auto& timeoutRespRules = dnsdist::rules::getResponseRuleChain(chains, dnsdist::rules::ResponseRuleChain::TimeoutResponseRules); @@ -729,7 +729,7 @@ bool DownstreamState::healthCheckRequired(std::optional currentTime) if (current >= maxFailureRate) { lastResults.clear(); VERBOSESLOG(infolog("Backend %s reached the lazy health-check threshold (%f%% out of %f%%, looking at sample of %d items with %d failures), moving to Potential Failure state", getNameWithAddr(), current, maxFailureRate, totalCount, failures), - getLogger()->info(Logr::Info, "Backend reached the lazy health-check threshold, moving to Potential failure state", "current-failure-rate", Logging::Loggable(current), "max-failure-rate", Logging::Loggable(maxFailureRate), "samples", Logging::Loggable(totalCount), "failures-count", Logging::Loggable(failures))); + getLogger()->info(Logr::Info, "Backend reached the lazy health-check threshold, moving to Potential failure state", "backend.health_check.current_failure_rate", Logging::Loggable(current), "backend.health_check.max_failure_rate", Logging::Loggable(maxFailureRate), "backend.health_check.samples", Logging::Loggable(totalCount), "backend.health_check.failures_count", Logging::Loggable(failures))); stats->d_status = LazyHealthCheckStats::LazyStatus::PotentialFailure; consecutiveSuccessfulChecks = 0; /* we update the next check time here because the check might time out, @@ -771,7 +771,7 @@ void DownstreamState::updateNextLazyHealthCheck(LazyHealthCheckStats& stats, boo determine if the backend is really down */ stats.d_nextCheck = now + d_config.checkInterval; VERBOSESLOG(infolog("Backend %s is in potential failure state, next check in %d seconds", getNameWithAddr(), d_config.checkInterval.load()), - getLogger()->info(Logr::Info, "Backend is in potential failure state", "next-check", Logging::Loggable(d_config.checkInterval.load()))); + getLogger()->info(Logr::Info, "Backend is in potential failure state", "backend.health_check.next_check", Logging::Loggable(d_config.checkInterval.load()))); } else if (consecutiveSuccessfulChecks > 0) { /* we are in 'Failed' state, but just had one (or more) successful check, @@ -780,7 +780,7 @@ void DownstreamState::updateNextLazyHealthCheck(LazyHealthCheckStats& stats, boo stats.d_nextCheck = now + d_config.d_lazyHealthCheckFailedInterval; if (!checkScheduled) { VERBOSESLOG(infolog("Backend %s is in failed state but had %d consecutive successful checks, next check in %d seconds", getNameWithAddr(), std::to_string(consecutiveSuccessfulChecks), d_config.d_lazyHealthCheckFailedInterval), - getLogger()->info(Logr::Info, "Backend is in failed state but had a successful check", "consecutive-successful-checks", Logging::Loggable(std::to_string(consecutiveSuccessfulChecks)), "next-check", Logging::Loggable(d_config.d_lazyHealthCheckFailedInterval))); + getLogger()->info(Logr::Info, "Backend is in failed state but had a successful check", "backend.health_check.consecutive_successful_checks", Logging::Loggable(std::to_string(consecutiveSuccessfulChecks)), "backend.health_check.next_check", Logging::Loggable(d_config.d_lazyHealthCheckFailedInterval))); } } else { @@ -805,13 +805,13 @@ void DownstreamState::updateNextLazyHealthCheck(LazyHealthCheckStats& stats, boo stats.d_nextCheck = now + backOff; VERBOSESLOG(infolog("Backend %s is in failed state and has failed %d consecutive checks, next check in %d seconds", getNameWithAddr(), failedTests, backOff), - getLogger()->info(Logr::Info, "Backend is in failed state and has failed its last check", "consecutive-failed-checks", Logging::Loggable(failedTests), "next-check", Logging::Loggable(backOff))); + getLogger()->info(Logr::Info, "Backend is in failed state and has failed its last check", "backend.health_check.consecutive_failed_checks", Logging::Loggable(failedTests), "backend.health_check.next_check", Logging::Loggable(backOff))); } } else { stats.d_nextCheck = now + d_config.d_lazyHealthCheckFailedInterval; VERBOSESLOG(infolog("Backend %s is in %s state, next check in %d seconds", getNameWithAddr(), (stats.d_status == DownstreamState::LazyHealthCheckStats::LazyStatus::PotentialFailure ? "potential failure" : "failed"), d_config.d_lazyHealthCheckFailedInterval), - getLogger()->info(Logr::Info, "Scheduling the next lazy check for this backend", "state", Logging::Loggable(stats.d_status == DownstreamState::LazyHealthCheckStats::LazyStatus::PotentialFailure ? "potential failure" : "failed"), "next-check", Logging::Loggable(d_config.d_lazyHealthCheckFailedInterval))); + getLogger()->info(Logr::Info, "Scheduling the next lazy check for this backend", "state", Logging::Loggable(stats.d_status == DownstreamState::LazyHealthCheckStats::LazyStatus::PotentialFailure ? "potential failure" : "failed"), "backend.health_check.next_check", Logging::Loggable(d_config.d_lazyHealthCheckFailedInterval))); } } @@ -826,7 +826,7 @@ void DownstreamState::submitHealthCheckResult(bool initial, bool newResult) about the minimum number of failed/successful health-checks */ if (!IsAnyAddress(d_config.remote)) { SLOG(infolog("Marking downstream %s as '%s'", getNameWithAddr(), newResult ? "up" : "down"), - getLogger()->info(Logr::Info, "Setting initial status for backend", "status", Logging::Loggable(newResult ? "up" : "down"))); + getLogger()->info(Logr::Info, "Setting initial status for backend", "backend.health_check.status", Logging::Loggable(newResult ? "up" : "down"))); } setUpStatus(newResult); if (newResult == false) { @@ -868,7 +868,7 @@ void DownstreamState::submitHealthCheckResult(bool initial, bool newResult) if (d_config.d_healthCheckMode == DownstreamState::HealthCheckMode::Lazy) { auto stats = d_lazyHealthCheckStats.lock(); VERBOSESLOG(infolog("Backend %s had %d successful checks, moving to Healthy", getNameWithAddr(), std::to_string(consecutiveSuccessfulChecks)), - getLogger()->info(Logr::Info, "Backend had a successful check, moving to Healthy", "consecutive-successful-checks", Logging::Loggable(std::to_string(consecutiveSuccessfulChecks)))); + getLogger()->info(Logr::Info, "Backend had a successful check, moving to Healthy", "backend.health_check.consecutive_successful_checks", Logging::Loggable(std::to_string(consecutiveSuccessfulChecks)))); stats->d_status = LazyHealthCheckStats::LazyStatus::Healthy; stats->d_lastResults.clear(); } @@ -904,7 +904,7 @@ void DownstreamState::submitHealthCheckResult(bool initial, bool newResult) /* we are actually moving to a new state */ if (!IsAnyAddress(d_config.remote)) { SLOG(infolog("Marking downstream %s as '%s'", getNameWithAddr(), newState ? "up" : "down"), - getLogger()->info(Logr::Info, "Updating status for backend", "status", Logging::Loggable(newState ? "up" : "down"))); + getLogger()->info(Logr::Info, "Updating status for backend", "backend.health_check.status", Logging::Loggable(newState ? "up" : "down"))); } if (newState && !isTCPOnly() && (!connected || d_config.reconnectOnUp)) { @@ -948,7 +948,7 @@ void DownstreamState::registerXsk(std::vector>& xsks) if (addresses.size() > 1) { SLOG(warnlog("More than one address configured on interface %s, picking the first one (%s) for XSK. Set the 'source' parameter on 'newServer' if you want to use a different address.", ifName, addresses.at(0).toString()), - getLogger()->info(Logr::Warning, "More than one address configured on this interface, picking the first one for XSK. Set the 'source' parameter on 'newServer' if you want to use a different address.", "interface", Logging::Loggable(ifName), "address", Logging::Loggable(addresses.at(0).toString()))); + getLogger()->info(Logr::Warning, "More than one address configured on this interface, picking the first one for XSK. Set the 'source' parameter on 'newServer' if you want to use a different address.", "source.interface", Logging::Loggable(ifName), "backend.address", Logging::Loggable(addresses.at(0).toString()))); } d_config.sourceAddr = addresses.at(0); } @@ -1008,7 +1008,7 @@ bool DownstreamState::parseSourceParameter(const std::string& source, Downstream } SLOG(warnlog("Dismissing source %s because '%s' is not a valid interface name", source, config.sourceItfName), - dnsdist::logging::getTopLogger()->info(Logr::Warning, "Dismissing source because the interface name is not valid", "backend-name", Logging::Loggable(config.name), "backend-address", Logging::Loggable(config.remote), "source", Logging::Loggable(source), "source-interface", Logging::Loggable(config.sourceItfName))); + dnsdist::logging::getTopLogger()->info(Logr::Warning, "Dismissing source because the interface name is not valid", "backend.name", Logging::Loggable(config.name), "backend.address", Logging::Loggable(config.remote), "source.address", Logging::Loggable(source), "source.interface", Logging::Loggable(config.sourceItfName))); return false; } @@ -1043,7 +1043,7 @@ unsigned int DownstreamState::getQPSLimit() const [[nodiscard]] std::shared_ptr DownstreamState::getLogger() const { - return dnsdist::logging::getTopLogger()->withName("backend")->withValues("backend-name", Logging::Loggable(getName()), "backend-address", Logging::Loggable(d_config.remote), "backend-proto", Logging::Loggable(getProtocol())); + return dnsdist::logging::getTopLogger()->withName("backend")->withValues("backend.name", Logging::Loggable(getName()), "backend.address", Logging::Loggable(d_config.remote), "backend.protocol", Logging::Loggable(getProtocol())); } size_t ServerPool::countServers(bool upOnly) const diff --git a/pdns/dnsdistdist/dnsdist-carbon.cc b/pdns/dnsdistdist/dnsdist-carbon.cc index 72d894b898..0364eeea19 100644 --- a/pdns/dnsdistdist/dnsdist-carbon.cc +++ b/pdns/dnsdistdist/dnsdist-carbon.cc @@ -307,7 +307,7 @@ static void carbonHandler(const Carbon::Endpoint& endpoint) { setThreadName("dnsdist/carbon"); const auto ourName = endpoint.getOurName(); - auto logger = dnsdist::logging::getTopLogger()->withName("carbon-exporter")->withValues("address", Logging::Loggable(endpoint.server), "our-name", Logging::Loggable(ourName)); + auto logger = dnsdist::logging::getTopLogger()->withName("carbon-exporter")->withValues("server.address", Logging::Loggable(endpoint.server), "dnsdist.carbon.our_name", Logging::Loggable(ourName)); const auto intervalUSec = endpoint.interval * 1000 * 1000; /* maximum interval between two attempts is 10 minutes */ @@ -328,7 +328,7 @@ static void carbonHandler(const Carbon::Endpoint& endpoint) } else { VERBOSESLOG(infolog("Carbon export for %s took longer (%s us) than the configured interval (%d us)", endpoint.server.toStringWithPort(), elapsedUSec, intervalUSec), - logger->info("Carbon export took longer than the configured interval", "elapsed-usec", Logging::Loggable(elapsedUSec), "interval-usec", Logging::Loggable(intervalUSec))); + logger->info("Carbon export took longer than the configured interval", "dnsdist.carbon.elapsed_usec", Logging::Loggable(elapsedUSec), "dnsdist.carbon.interval_usec", Logging::Loggable(intervalUSec))); } consecutiveFailures = 0; } @@ -338,7 +338,7 @@ static void carbonHandler(const Carbon::Endpoint& endpoint) consecutiveFailures++; } VERBOSESLOG(infolog("Run for %s - %s failed, next attempt in %d", endpoint.server.toStringWithPort(), endpoint.getOurName(), backOff), - logger->info("Carbon export failed", "next-attempt-seconds", Logging::Loggable(backOff))); + logger->info("Carbon export failed", "dnsdist.carbon.next_attempt_seconds", Logging::Loggable(backOff))); std::this_thread::sleep_for(std::chrono::seconds(backOff)); } } while (true); diff --git a/pdns/dnsdistdist/dnsdist-concurrent-connections.cc b/pdns/dnsdistdist/dnsdist-concurrent-connections.cc index cc8e4b34be..935c4fa8d9 100644 --- a/pdns/dnsdistdist/dnsdist-concurrent-connections.cc +++ b/pdns/dnsdistdist/dnsdist-concurrent-connections.cc @@ -188,18 +188,18 @@ IncomingConcurrentTCPConnectionsManager::NewConnectionResult IncomingConcurrentT auto checkConnectionAllowed = [now, from, maxConnsPerClient, threshold, tcpRate, tlsNewRate, tlsResumedRate, interval, isTLS, &immutable](const ClientEntry& entry) { if (entry.d_bannedUntil != 0 && entry.d_bannedUntil >= now) { VERBOSESLOG(infolog("Refusing TCP connection from %s: banned", from.toStringWithPort()), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("banned"), "address", Logging::Loggable(from))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("banned"), "client.address", Logging::Loggable(from))); return NewConnectionResult::Denied; } if (maxConnsPerClient > 0 && entry.d_concurrentConnections >= maxConnsPerClient) { VERBOSESLOG(infolog("Refusing TCP connection from %s: too many connections", from.toStringWithPort()), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("too many connections"), "address", Logging::Loggable(from))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Refusing TCP connection", "reason", Logging::Loggable("too many connections"), "client.address", Logging::Loggable(from))); return NewConnectionResult::Denied; } if (!checkTCPConnectionsRate(entry.d_activity, now, tcpRate, tlsNewRate, tlsResumedRate, interval, isTLS)) { entry.d_bannedUntil = now + immutable.d_tcpBanDurationForExceedingTCPTLSRate; VERBOSESLOG(infolog("Banning TCP connections from %s for %d seconds: too many new TCP/TLS connections per second", from.toStringWithPort(), immutable.d_tcpBanDurationForExceedingTCPTLSRate), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Banning TCP connections from this client", "reason", Logging::Loggable("too many new TCP/TLS connections per second"), "address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(immutable.d_tcpBanDurationForExceedingTCPTLSRate))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Banning TCP connections from this client", "reason", Logging::Loggable("too many new TCP/TLS connections per second"), "client.address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(immutable.d_tcpBanDurationForExceedingTCPTLSRate))); return NewConnectionResult::Denied; } @@ -212,7 +212,7 @@ IncomingConcurrentTCPConnectionsManager::NewConnectionResult IncomingConcurrentT return NewConnectionResult::Allowed; } VERBOSESLOG(infolog("Restricting TCP connection from %s: nearly reaching the maximum number of concurrent TCP connections", from.toStringWithPort()), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Restricting TCP connections from this client", "reason", Logging::Loggable("nearly reaching the maximum number of concurrent TCP connections"), "address", Logging::Loggable(from))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Restricting TCP connections from this client", "reason", Logging::Loggable("nearly reaching the maximum number of concurrent TCP connections"), "client.address", Logging::Loggable(from))); return NewConnectionResult::Restricted; }; @@ -278,7 +278,7 @@ void IncomingConcurrentTCPConnectionsManager::banClientFor(const ComboAddress& f }); } VERBOSESLOG(infolog("Banned TCP client %s for %d seconds", from.toStringWithPort(), seconds), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Banned TCP connections from this client", "address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(seconds))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Banned TCP connections from this client", "client.address", Logging::Loggable(from), "duration-seconds", Logging::Loggable(seconds))); } static void editEntryIfPresent(const ComboAddress& from, const std::function& callback) diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index 9142b3cb38..7de5b5d06f 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -305,7 +305,7 @@ static bool validateTLSConfiguration(const Context& context, const dnsdist::rust } catch (const std::runtime_error& e) { SLOG(errlog("Ignoring %s frontend: '%s'", bind.protocol, e.what()), - context.logger->error(Logr::Error, e.what(), "Ignoring frontend because of an invalid TLS configuration", "protocol", Logging::Loggable(std::string(bind.protocol)))); + context.logger->error(Logr::Error, e.what(), "Ignoring frontend because of an invalid TLS configuration", "frontend.protocol", Logging::Loggable(std::string(bind.protocol)))); return false; } #endif /* HAVE_LIBSSL */ @@ -369,13 +369,13 @@ static bool handleTLSConfiguration(const Context& context, const dnsdist::rust:: if (frontend->d_library == "nghttp2") { #ifndef HAVE_NGHTTP2 SLOG(errlog("DOH bind %s is configured to use nghttp2 but the library is not available", bind.listen_address), - context.logger->error(Logr::Error, "DoH frontend is configured to use nhgttp2 but the library is not available", "listen-address", Logging::Loggable(bind.listen_address))); + context.logger->error(Logr::Error, "DoH frontend is configured to use nhgttp2 but the library is not available", "frontend.address", Logging::Loggable(bind.listen_address))); return false; #endif /* HAVE_NGHTTP2 */ } else { SLOG(errlog("DOH bind %s is configured to use an unknown library ('%s')", bind.listen_address, frontend->d_library), - context.logger->error(Logr::Error, "DoH frontend is configured to use an unknown library", "listen-address", Logging::Loggable(bind.listen_address), "library", Logging::Loggable(frontend->d_library))); + context.logger->error(Logr::Error, "DoH frontend is configured to use an unknown library", "frontend.address", Logging::Loggable(bind.listen_address), "library", Logging::Loggable(frontend->d_library))); return false; } @@ -414,12 +414,12 @@ static bool handleTLSConfiguration(const Context& context, const dnsdist::rust:: if (!tlsConfig.d_certKeyPairs.empty()) { tlsContext->d_addr = ComboAddress(std::string(bind.listen_address), 443); SLOG(infolog("DNS over HTTPS configured"), - context.logger->info(Logr::Info, "DNS over HTTPS frontend configured", "listening-address", Logging::Loggable(tlsContext->d_addr))); + context.logger->info(Logr::Info, "DNS over HTTPS frontend configured", "frontend.address", Logging::Loggable(tlsContext->d_addr))); } else { tlsContext->d_addr = ComboAddress(std::string(bind.listen_address), 80); SLOG(infolog("No certificate provided for DoH endpoint %s, running in DNS over HTTP mode instead of DNS over HTTPS", tlsContext->d_addr.toStringWithPort()), - context.logger->info(Logr::Info, "No certificate provided for DoH frontend, running in DNS over HTTP mode instead of DNS over HTTPS", "listening-address", Logging::Loggable(tlsContext->d_addr))); + context.logger->info(Logr::Info, "No certificate provided for DoH frontend, running in DNS over HTTP mode instead of DNS over HTTPS", "frontend.address", Logging::Loggable(tlsContext->d_addr))); } tlsContext->d_proxyProtocolOutsideTLS = bind.tls.proxy_protocol_outside_tls; @@ -430,7 +430,7 @@ static bool handleTLSConfiguration(const Context& context, const dnsdist::rust:: #endif /* defined(HAVE_DNS_OVER_HTTPS) */ else if (protocol != "do53") { SLOG(errlog("Bind %s is configured to use an unknown protocol ('%s')", bind.listen_address, protocol), - context.logger->info(Logr::Error, "Frontend is configured to use an unknown protocol", "listening-address", Logging::Loggable(bind.listen_address), "protocol", Logging::Loggable(protocol))); + context.logger->info(Logr::Error, "Frontend is configured to use an unknown protocol", "frontend.address", Logging::Loggable(bind.listen_address), "frontend.protocol", Logging::Loggable(protocol))); return false; } @@ -502,7 +502,7 @@ static std::shared_ptr createBackendFromConfiguration(const Con } else if (!hcConf.lazy.mode.empty()) { SLOG(warnlog("Ignoring unknown value '%s' for 'lazy.mode' on backend %s", hcConf.lazy.mode, std::string(config.address)), - context.logger->info(Logr::Warning, "Ignoring unknown value for 'lazy.mode' on backend", "backend-address", Logging::Loggable("config.address"), "value", Logging::Loggable(hcConf.lazy.mode))); + context.logger->info(Logr::Warning, "Ignoring unknown value for 'lazy.mode' on backend", "backend.address", Logging::Loggable(config.address), "backend.health_check.mode", Logging::Loggable(hcConf.lazy.mode))); } backendConfig.d_upgradeToLazyHealthChecks = config.auto_upgrade.use_lazy_health_check; @@ -541,7 +541,7 @@ static std::shared_ptr createBackendFromConfiguration(const Con } catch (const std::exception&) { SLOG(errlog("Error creating new server: downstream subject_address value must be a valid IP address"), - context.logger->info(Logr::Error, "Error creating new backend server: downstream subject_address value must be a valid IP address", "backend-address", Logging::Loggable(config.address), "value", Logging::Loggable(tlsConf.subject_address))); + context.logger->info(Logr::Error, "Error creating new backend server: downstream subject_address value must be a valid IP address", "backend.address", Logging::Loggable(config.address), "tls.subject_address", Logging::Loggable(tlsConf.subject_address))); } } if (backendConfig.d_tlsParams.d_validateCertificates && backendConfig.d_tlsSubjectName.empty()) { @@ -586,7 +586,7 @@ static std::shared_ptr createBackendFromConfiguration(const Con if (!configCheck) { downstream->registerXsk(*xskMap); SLOG(infolog("Added downstream server %s via XSK in %s mode", std::string(config.address), xskMap->at(0)->getXDPMode()), - context.logger->info(Logr::Info, "Added backend server using XSK", "listening-address", Logging::Loggable(config.address), "xsk-mode", Logging::Loggable(xskMap->at(0)->getXDPMode()))); + context.logger->info(Logr::Info, "Added backend server using XSK", "backend.address", Logging::Loggable(config.address), "xsk_mode", Logging::Loggable(xskMap->at(0)->getXDPMode()))); } } #endif /* defined(HAVE_XSK) */ @@ -756,7 +756,7 @@ static void handleAdditionalAddressesForFrontend(const Context& context, const s } catch (const PDNSException& e) { SLOG(errlog("Unable to parse additional address %s for %s bind: %s", std::string(addr), protocol, e.reason), - context.logger->error(Logr::Error, e.reason, "Unable to parse additional address for frontend", "address", Logging::Loggable(addr), "protocol", Logging::Loggable(protocol))); + context.logger->error(Logr::Error, e.reason, "Unable to parse additional address for frontend", "frontend.address", Logging::Loggable(addr), "frontend.protocol", Logging::Loggable(protocol))); } } } @@ -845,7 +845,7 @@ static void loadBinds(const Context& context, const ::rust::VecxskInfoResponder = XskWorker::create(XskWorker::Type::OutgoingOnly, xsk->sharedEmptyFrameOffset); xsk->addWorker(state->xskInfoResponder); VERBOSESLOG(infolog("Enabling XSK in %s mode for incoming UDP packets to %s", xsk->getXDPMode(), listeningAddress.toStringWithPort()), - context.logger->info(Logr::Info, "Enabling XSK for incoming UDP packet", "listening-address", Logging::Loggable(listeningAddress), "xsk-mode", Logging::Loggable(xsk->getXDPMode()))); + context.logger->info(Logr::Info, "Enabling XSK for incoming UDP packet", "frontend.address", Logging::Loggable(listeningAddress), "xsk_mode", Logging::Loggable(xsk->getXDPMode()))); } #endif /* defined(HAVE_XSK) */ config.d_frontends.emplace_back(std::move(state)); @@ -944,11 +944,11 @@ static void handleOpenSSLSettings(const Context& context, const dnsdist::rust::s auto [success, error] = libssl_load_engine(std::string(engine.name), !engine.default_string.empty() ? std::optional(engine.default_string) : std::nullopt); if (!success) { SLOG(warnlog("Error while trying to load TLS engine '%s': %s", std::string(engine.name), error), - context.logger->error(Logr::Warning, "Error while trying to load TLS engine", "engine", Logging::Loggable(engine.name), "error", Logging::Loggable(error))); + context.logger->error(Logr::Warning, error, "Error while trying to load TLS engine", "tls.engine", Logging::Loggable(engine.name))); } #else SLOG(warnlog("Ignoring TLS engine '%s' because OpenSSL engine support is not compiled in", std::string(engine.name)), - context.logger->info(Logr::Warning, "Ignoring TLS engine because OpenSSL engine support is not compiled in", "engine", Logging::Loggable(engine.name))); + context.logger->info(Logr::Warning, "Ignoring TLS engine because OpenSSL engine support is not compiled in", "tls.engine", Logging::Loggable(engine.name))); #endif /* HAVE_LIBSSL && !HAVE_TLS_PROVIDERS */ } @@ -957,11 +957,11 @@ static void handleOpenSSLSettings(const Context& context, const dnsdist::rust::s auto [success, error] = libssl_load_provider(std::string(provider)); if (!success) { SLOG(warnlog("Error while trying to load TLS provider '%s': %s", std::string(provider), error), - context.logger->error(Logr::Warning, error, "Error while trying to load TLS provider", "provider", Logging::Loggable(provider))); + context.logger->error(Logr::Warning, error, "Error while trying to load TLS provider", "tls.provider", Logging::Loggable(provider))); } #else SLOG(warnlog("Ignoring TLS provider '%s' because OpenSSL provider support is not compiled in", std::string(provider)), - context.logger->info(Logr::Warning, "Ignoring TLS provider because OpenSSL provider support is not compiled in", "provider", Logging::Loggable(provider))); + context.logger->info(Logr::Warning, "Ignoring TLS provider because OpenSSL provider support is not compiled in", "tls.provider", Logging::Loggable(provider))); #endif /* HAVE_LIBSSL && OPENSSL_VERSION_MAJOR >= 3 && HAVE_TLS_PROVIDERS */ } } @@ -1115,7 +1115,7 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo // Rust code would be quite cumbersome so for now let's settle for this s_inConfigCheckMode.store(configCheck); s_inClientMode.store(isClient); - auto logger = dnsdist::logging::getTopLogger()->withName("yaml-configuration")->withValues("configuration-file", Logging::Loggable(fileName), "client-mode", Logging::Loggable(isClient), "configuration-check", Logging::Loggable(configCheck)); + auto logger = dnsdist::logging::getTopLogger()->withName("yaml-configuration")->withValues("dnsdist.configuration.file", Logging::Loggable(fileName), "dnsdist.configuration.client_mode", Logging::Loggable(isClient), "dnsdist.configuration.check", Logging::Loggable(configCheck)); Context context{ .logger = logger, }; @@ -1263,7 +1263,7 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo auto [poolIt, inserted] = config.d_pools.emplace(std::string(pool.name), ServerPool()); if (inserted) { VERBOSESLOG(infolog("Creating pool %s", pool.name), - context.logger->info(Logr::Info, "Creating pool", "pool-name", Logging::Loggable(pool.name))); + context.logger->info(Logr::Info, "Creating pool", "pool.name", Logging::Loggable(pool.name))); } if (!pool.packet_cache.empty()) { @@ -1290,15 +1290,15 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo } catch (const ::rust::Error& exp) { SLOG(errlog("Error while parsing YAML file %s: %s", fileName, exp.what()), - logger->error(Logr::Error, exp.what(), "Error while parsing YAML file", "configuration-file", Logging::Loggable(fileName))); + logger->error(Logr::Error, exp.what(), "Error while parsing YAML file", "dnsdist.configuration.file", Logging::Loggable(fileName))); } catch (const PDNSException& exp) { SLOG(errlog("Error while processing YAML configuration from file %s: %s", fileName, exp.reason), - logger->error(Logr::Error, exp.reason, "Error while processing YAML file", "configuration-file", Logging::Loggable(fileName))); + logger->error(Logr::Error, exp.reason, "Error while processing YAML file", "dnsdist.configuration.file", Logging::Loggable(fileName))); } catch (const std::exception& exp) { SLOG(errlog("Error while processing YAML configuration from file %s: %s", fileName, exp.what()), - logger->error(Logr::Error, exp.what(), "Error while processing YAML file", "configuration-file", Logging::Loggable(fileName))); + logger->error(Logr::Error, exp.what(), "Error while processing YAML file", "dnsdist.configuration.file", Logging::Loggable(fileName))); } return false; #else diff --git a/pdns/dnsdistdist/dnsdist-console.cc b/pdns/dnsdistdist/dnsdist-console.cc index ae980493bc..9034bb3c57 100644 --- a/pdns/dnsdistdist/dnsdist-console.cc +++ b/pdns/dnsdistdist/dnsdist-console.cc @@ -640,7 +640,7 @@ void controlThread(Socket&& acceptFD) { setThreadName("dnsdist/control"); const ComboAddress local = dnsdist::configuration::getCurrentRuntimeConfiguration().d_consoleServerAddress; - auto logger = dnsdist::logging::getTopLogger()->withName("console-server")->withValues("listening-address", Logging::Loggable(local)); + auto logger = dnsdist::logging::getTopLogger()->withName("console-server")->withValues("network.local.address", Logging::Loggable(local)); try { s_connManager.setMaxConcurrentConnections(dnsdist::configuration::getImmutableConfiguration().d_consoleMaxConcurrentConnections); @@ -660,20 +660,20 @@ void controlThread(Socket&& acceptFD) FDWrapper socket(sock); if (!dnsdist::crypto::authenticated::isValidKey(consoleKey)) { VERBOSESLOG(infolog("Control connection from %s dropped because we don't have a valid key configured, please configure one using setKey()", client.toStringWithPort()), - logger->info(Logr::Info, "Control connection dropped because we don't have a valid key configured, please configure one using setKey()", "address", Logging::Loggable(client))); + logger->info(Logr::Info, "Control connection dropped because we don't have a valid key configured, please configure one using setKey()", "client.address", Logging::Loggable(client))); continue; } const auto& runtimeConfig = dnsdist::configuration::getCurrentRuntimeConfiguration(); if (!runtimeConfig.d_consoleACL.match(client)) { VERBOSESLOG(infolog("Control connection from %s dropped because of ACL", client.toStringWithPort()), - logger->info(Logr::Info, "Control connection dropped because of ACL", "address", Logging::Loggable(client))); + logger->info(Logr::Info, "Control connection dropped because of ACL", "client.address", Logging::Loggable(client))); continue; } try { ConsoleConnection conn(client, std::move(socket)); - auto connLogger = dnsdist::logging::getTopLogger()->withName("console-connection")->withValues("address", Logging::Loggable(client)); + auto connLogger = dnsdist::logging::getTopLogger()->withName("console-connection")->withValues("client.address", Logging::Loggable(client)); if (runtimeConfig.d_logConsoleConnections) { SLOG(warnlog("Got control connection from %s", client.toStringWithPort()), connLogger->info(Logr::Info, "Control connection opened")); @@ -684,7 +684,7 @@ void controlThread(Socket&& acceptFD) } catch (const std::exception& e) { SLOG(infolog("Control connection died: %s", e.what()), - logger->error(Logr::Info, e.what(), "Control connection died", "address", Logging::Loggable(client))); + logger->error(Logr::Info, e.what(), "Control connection died", "client.address", Logging::Loggable(client))); } } } diff --git a/pdns/dnsdistdist/dnsdist-dnsquestion.cc b/pdns/dnsdistdist/dnsdist-dnsquestion.cc index d91b3fe6b7..c9cb05c70c 100644 --- a/pdns/dnsdistdist/dnsdist-dnsquestion.cc +++ b/pdns/dnsdistdist/dnsdist-dnsquestion.cc @@ -66,7 +66,7 @@ std::shared_ptr DNSQuestion::getThisLogger() const return d_logger; } auto logger = dnsdist::logging::getTopLogger(); - logger = logger->withValues("qname", Logging::Loggable(ids.qname), "qtype", Logging::Loggable(QType(ids.qtype)), "qclass", Logging::Loggable(QClass(ids.qclass)), "source", Logging::Loggable(ids.origRemote), "destination", Logging::Loggable(ids.origDest), "proto", Logging::Loggable(ids.protocol), "id", Logging::Loggable(ids.origID), "flags", Logging::Loggable(ids.origFlags)); + logger = logger->withValues("dns.question.name", Logging::Loggable(ids.qname), "dns.question.type", Logging::Loggable(QType(ids.qtype)), "dns.question.class", Logging::Loggable(QClass(ids.qclass)), "source.address", Logging::Loggable(ids.origRemote), "destination.address", Logging::Loggable(ids.origDest), "proto", Logging::Loggable(ids.protocol), "dns.question.id", Logging::Loggable(ids.origID), "dns.question.flags", Logging::Loggable(ids.origFlags)); return logger; } @@ -78,13 +78,13 @@ std::shared_ptr DNSResponse::getThisLogger() const auto logger = DNSQuestion::getThisLogger(); if (data.size() >= sizeof(dnsheader)) { const auto header = getHeader(); - logger = logger->withValues("rcode", Logging::Loggable(RCode::to_s(header->rcode))); + logger = logger->withValues("dns.response.rcode", Logging::Loggable(RCode::to_s(header->rcode))); } if (d_downstream) { - logger = logger->withValues("backend-protocol", Logging::Loggable(d_downstream->getProtocol()), "backend-name", Logging::Loggable(d_downstream->getName()), "backend-address", Logging::Loggable(d_downstream->d_config.remote)); + logger = logger->withValues("backend.protocol", Logging::Loggable(d_downstream->getProtocol()), "backend.name", Logging::Loggable(d_downstream->getName()), "backend.address", Logging::Loggable(d_downstream->d_config.remote)); } const double udiff = ids.queryRealTime.udiff(); - logger = logger->withValues("latency-us", Logging::Loggable(udiff), "response-size", Logging::Loggable(data.size())); + logger = logger->withValues("dns.response.latency-us", Logging::Loggable(udiff), "dns.response.size", Logging::Loggable(data.size())); return logger; } diff --git a/pdns/dnsdistdist/dnsdist-lua.cc b/pdns/dnsdistdist/dnsdist-lua.cc index 7e2e760ca2..48e92df934 100644 --- a/pdns/dnsdistdist/dnsdist-lua.cc +++ b/pdns/dnsdistdist/dnsdist-lua.cc @@ -3237,11 +3237,11 @@ void loadLuaConfigurationFile(LuaContext& luaCtx, const std::string& config, boo throw std::runtime_error("Unable to read configuration file from " + config); } SLOG(warnlog("Unable to read configuration from '%s'", config), - dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Error, "Unable to read configuration from file", "configuration-file", Logging::Loggable(config))); + dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Error, "Unable to read configuration from file", "dnsdist.configuration.file", Logging::Loggable(config))); } else { VERBOSESLOG(infolog("Read configuration from '%s'", config), - dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Info, "Read configuration from file", "configuration-file", Logging::Loggable(config))); + dnsdist::logging::getTopLogger()->withName("lua-configuration")->info(Logr::Info, "Read configuration from file", "dnsdist.configuration.file", Logging::Loggable(config))); } luaCtx.executeCode(ifs); diff --git a/pdns/dnsdistdist/dnsdist-web.cc b/pdns/dnsdistdist/dnsdist-web.cc index 9eb6fc1c6e..5d8e100fdc 100644 --- a/pdns/dnsdistdist/dnsdist-web.cc +++ b/pdns/dnsdistdist/dnsdist-web.cc @@ -180,7 +180,7 @@ public: if (!s_connManager.registerConnection()) { throw std::runtime_error("Too many concurrent web client connections"); } - d_logger = logger.withValues("address", Logging::Loggable(client)); + d_logger = logger.withValues("client.address", Logging::Loggable(client)); } WebClientConnection(WebClientConnection&& rhs) noexcept : d_logger(std::move(rhs.d_logger)), d_client(rhs.d_client), d_socket(std::move(rhs.d_socket)) @@ -239,13 +239,13 @@ static bool apiWriteConfigFile(const string& filebasename, const string& content const auto& runtimeConfig = dnsdist::configuration::getCurrentRuntimeConfiguration(); if (!runtimeConfig.d_apiReadWrite) { SLOG(warnlog("Not writing content to %s since the API is read-only", filebasename), - logger.info(Logr::Warning, "Not writing content to file since the API is read-only", "file", Logging::Loggable(filebasename))); + logger.info(Logr::Warning, "Not writing content to file since the API is read-only", "filename", Logging::Loggable(filebasename))); return false; } if (runtimeConfig.d_apiConfigDirectory.empty()) { VERBOSESLOG(infolog("Not writing content to %s since the API configuration directory is not set", filebasename), - logger.info(Logr::Info, "Not writing content to file since the API configuration directory is not set", "file", Logging::Loggable(filebasename))); + logger.info(Logr::Info, "Not writing content to file since the API configuration directory is not set", "filename", Logging::Loggable(filebasename))); return false; } @@ -255,7 +255,7 @@ static bool apiWriteConfigFile(const string& filebasename, const string& content if (!ofconf) { int saved = errno; SLOG(errlog("Could not open configuration fragment file '%s' for writing: %s", filename, stringerror(saved)), - logger.error(Logr::Error, saved, "Could not open configuration fragment file for writing", "file", Logging::Loggable(filebasename))); + logger.error(Logr::Error, saved, "Could not open configuration fragment file for writing", "filename", Logging::Loggable(filebasename))); return false; } @@ -526,14 +526,14 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp, MetricDefinition metricDetails; if (!s_metricDefinitions.getMetricDetails(metricName, metricDetails)) { VERBOSESLOG(infolog("Do not have metric details for %s", metricName), - logger.info(Logr::Info, "Missing details for this metric", "metric-name", Logging::Loggable(metricName))); + logger.info(Logr::Info, "Missing details for this metric", "dnsdist.metric.name", Logging::Loggable(metricName))); continue; } const std::string prometheusTypeName = s_metricDefinitions.getPrometheusStringMetricType(metricDetails.prometheusType); if (prometheusTypeName.empty()) { VERBOSESLOG(infolog("Unknown Prometheus type for %s", metricName), - logger.info(Logr::Info, "Unknown Prometheus type", "metric-name", Logging::Loggable(metricName))); + logger.info(Logr::Info, "Unknown Prometheus type", "dnsdist.metric.name", Logging::Loggable(metricName))); continue; } @@ -1935,7 +1935,7 @@ static void connectionThread(WebClientConnection&& conn) auto header = req.headers.find("authorization"); if (header != req.headers.end()) { VERBOSESLOG(infolog("HTTP Request \"%s\" from %s: Web Authentication failed", req.url.path, conn.getClient().toStringWithPort()), - conn.getLogger().info(Logr::Info, "Web authentication failed for HTTP Request", "url", Logging::Loggable( req.url.path))); + conn.getLogger().info(Logr::Info, "Web authentication failed for HTTP Request", "url", Logging::Loggable(req.url.path))); } resp.status = 401; resp.body = "

Unauthorized

"; @@ -1995,7 +1995,7 @@ void setMaxConcurrentConnections(size_t max) void WebserverThread(ComboAddress listeningAddress, Socket sock) { setThreadName("dnsdist/webserv"); - auto serverLogger = dnsdist::logging::getTopLogger()->withName("webserver")->withValues("listening-address", Logging::Loggable(listeningAddress)); + auto serverLogger = dnsdist::logging::getTopLogger()->withName("webserver")->withValues("network.local.address", Logging::Loggable(listeningAddress)); SLOG(infolog("Webserver launched on %s", listeningAddress.toStringWithPort()), serverLogger->info(Logr::Info, "Webserver launched")); @@ -2015,7 +2015,7 @@ void WebserverThread(ComboAddress listeningAddress, Socket sock) if (!isClientAllowedByACL(remote)) { VERBOSESLOG(infolog("Connection to webserver from client %s is not allowed, closing", remote.toStringWithPort()), - serverLogger->info(Logr::Info, "Connection to webserver is not allowed by ACL, closing", "address", Logging::Loggable(remote))); + serverLogger->info(Logr::Info, "Connection to webserver is not allowed by ACL, closing", "client.address", Logging::Loggable(remote))); close(fileDesc); continue; } diff --git a/pdns/dnsdistdist/dnsdist-xsk.cc b/pdns/dnsdistdist/dnsdist-xsk.cc index cbe41dd706..9531226f74 100644 --- a/pdns/dnsdistdist/dnsdist-xsk.cc +++ b/pdns/dnsdistdist/dnsdist-xsk.cc @@ -39,7 +39,7 @@ void XskResponderThread(std::shared_ptr dss, std::shared_ptrwithName("xsk-response-worker")->withValues("backend-name", Logging::Loggable(dss->getName()), "backend-address", Logging::Loggable(dss->d_config.remote)); + auto logger = dnsdist::logging::getTopLogger()->withName("xsk-response-worker")->withValues("backend.name", Logging::Loggable(dss->getName()), "backend.address", Logging::Loggable(dss->d_config.remote)); auto pollfds = getPollFdsForWorker(*xskInfo); while (!dss->isStopped()) { @@ -123,7 +123,7 @@ bool XskIsQueryAcceptable(const XskPacket& packet, ClientState& clientState, boo expectProxyProtocol = expectProxyProtocolFrom(from); if (!dnsdist::configuration::getCurrentRuntimeConfiguration().d_ACL.match(from) && !expectProxyProtocol) { VERBOSESLOG(infolog("Query from %s dropped because of ACL", from.toStringWithPort()), - dnsdist::logging::getTopLogger()->info(Logr::Info, "Query dropped because of ACL", "address", Logging::Loggable(from))); + dnsdist::logging::getTopLogger()->info(Logr::Info, "Query dropped because of ACL", "client.address", Logging::Loggable(from))); ++dnsdist::metrics::g_stats.aclDrops; return false; } diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index 61542d92d9..e2e14ff52b 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -140,7 +140,7 @@ static void sendfromto(int sock, const PacketBuffer& buffer, const ComboAddress& if (ret == -1) { int error = errno; VERBOSESLOG(infolog("Error sending UDP response to %s: %s", dest.toStringWithPort(), stringerror(error)), - dnsdist::logging::getTopLogger()->withName("sendfromto")->error(error, "Error sending UDP response", "destination", Logging::Loggable(dest))); + dnsdist::logging::getTopLogger()->withName("sendfromto")->error(error, "Error sending UDP response", "destination.address", Logging::Loggable(dest))); } return; } @@ -150,7 +150,7 @@ static void sendfromto(int sock, const PacketBuffer& buffer, const ComboAddress& } catch (const std::exception& exp) { VERBOSESLOG(infolog("Error sending UDP response from %s to %s: %s", from.toStringWithPort(), dest.toStringWithPort(), exp.what()), - dnsdist::logging::getTopLogger()->withName("sendfromto")->error(exp.what(), "Error sending UDP response", "source", Logging::Loggable(from), "destination", Logging::Loggable(dest))); + dnsdist::logging::getTopLogger()->withName("sendfromto")->error(exp.what(), "Error sending UDP response", "source.address", Logging::Loggable(from), "destination.address", Logging::Loggable(dest))); } } @@ -294,7 +294,7 @@ bool responseContentMatches(const PacketBuffer& response, const DNSName& qname, catch (const std::exception& e) { if (remote && !response.empty() && static_cast(response.size()) > sizeof(dnsheader)) { VERBOSESLOG(infolog("Backend %s sent us a response with id %d that did not parse: %s", remote->d_config.remote.toStringWithPort(), ntohs(dnsHeader->id), e.what()), - dnsdist::logging::getTopLogger()->withName("udp-response-worker")->error(e.what(), "Received a DNS response from a backend that we could not parse", "address", Logging::Loggable(remote->d_config.remote), "response-id", Logging::Loggable(ntohs(dnsHeader->id)))); + dnsdist::logging::getTopLogger()->withName("udp-response-worker")->error(e.what(), "Received a DNS response from a backend that we could not parse", "backend.address", Logging::Loggable(remote->d_config.remote), "dns.query.id", Logging::Loggable(ntohs(dnsHeader->id)))); } ++dnsdist::metrics::g_stats.nonCompliantResponses; if (remote) { @@ -393,7 +393,7 @@ static bool fixUpResponse(PacketBuffer& response, const DNSName& qname, uint16_t } else { SLOG(warnlog("Error rewriting content"), - dnsdist::logging::getTopLogger()->withName("fixup-response")->info(Logr::Error, "Error rewriting response content", "qname", Logging::Loggable(qname))); + dnsdist::logging::getTopLogger()->withName("fixup-response")->info(Logr::Error, "Error rewriting response content", "dns.question.name", Logging::Loggable(qname))); } } } @@ -416,7 +416,7 @@ static bool fixUpResponse(PacketBuffer& response, const DNSName& qname, uint16_t } else { SLOG(warnlog("Error rewriting content"), - dnsdist::logging::getTopLogger()->withName("fixup-response")->info(Logr::Error, "Error rewriting response content", "qname", Logging::Loggable(qname))); + dnsdist::logging::getTopLogger()->withName("fixup-response")->info(Logr::Error, "Error rewriting response content", "dns.question.name", Logging::Loggable(qname))); } } } @@ -665,7 +665,7 @@ static void handleResponseTC4UDPClient(DNSQuestion& dnsQuestion, uint16_t udpPay { if (udpPayloadSize != 0 && response.size() > udpPayloadSize) { VERBOSESLOG(infolog("Got a response of size %d while the initial UDP payload size was %d, truncating", response.size(), udpPayloadSize), - dnsQuestion.getLogger()->withName("udp-response")->info(Logr::Info, "Got a UDP response larger than the initial UDP payload size, truncating", "size", Logging::Loggable(response.size()), "udp-payload-size", Logging::Loggable(udpPayloadSize))); + dnsQuestion.getLogger()->withName("udp-response")->info(Logr::Info, "Got a UDP response larger than the initial UDP payload size, truncating", "dns.response.size", Logging::Loggable(response.size()), "dns.query.udp_payload_size", Logging::Loggable(udpPayloadSize))); truncateTC(dnsQuestion.getMutableData(), dnsQuestion.getMaximumSize(), dnsQuestion.ids.qname.wirelength(), dnsdist::configuration::getCurrentRuntimeConfiguration().d_addEDNSToSelfGeneratedResponses); dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsQuestion.getMutableData(), [](dnsheader& header) { @@ -779,7 +779,7 @@ bool processResponderPacket(std::shared_ptr& dss, PacketBuffer& // listens on a dedicated socket, lobs answers from downstream servers to original requestors void responderThread(std::shared_ptr dss) { - auto responderLogger = dnsdist::logging::getTopLogger()->withName("udp-response")->withValues("address", Logging::Loggable(dss->d_config.remote)); + auto responderLogger = dnsdist::logging::getTopLogger()->withName("udp-response")->withValues("backend.address", Logging::Loggable(dss->d_config.remote)); try { setThreadName("dnsdist/respond"); @@ -864,7 +864,7 @@ void responderThread(std::shared_ptr dss) } catch (const std::exception& e) { VERBOSESLOG(infolog("Got an error in UDP responder thread while parsing a response from %s, id %d: %s", dss->d_config.remote.toStringWithPort(), queryId, e.what()), - responderLogger->error(e.what(), "Got an error in UDP responder thread while parsing a response", "response-id", Logging::Loggable(queryId))); + responderLogger->error(e.what(), "Got an error in UDP responder thread while parsing a response", "dns.response.id", Logging::Loggable(queryId))); } } } @@ -1155,7 +1155,7 @@ static bool applyRulesToQuery(DNSQuestion& dnsQuestion, const timespec& now) const auto& tagName = got->second.tagSettings->d_name; const auto& tagValue = got->second.tagSettings->d_value; VERBOSESLOG(infolog("Query from %s setting tag %s to %s because of dynamic block", dnsQuestion.ids.origRemote.toStringWithPort(), tagName, tagValue), - dnsQuestion.getLogger()->info("Setting tag on query because of a dynamic rule", "tag-name", Logging::Loggable(tagName), "tag-value", Logging::Loggable(tagValue))); + dnsQuestion.getLogger()->info("Setting tag on query because of a dynamic rule", "dnsdist.tag.name", Logging::Loggable(tagName), "dnsdist.tag.value", Logging::Loggable(tagValue))); updateBlockStats(); dnsQuestion.setTag(tagName, tagValue); // do not return, the whole point it to set a Tag to be able to do further processing in rules @@ -1236,7 +1236,7 @@ static bool applyRulesToQuery(DNSQuestion& dnsQuestion, const timespec& now) const auto& tagName = got->tagSettings->d_name; const auto& tagValue = got->tagSettings->d_value; VERBOSESLOG(infolog("Query from %s setting tag %s to %s because of dynamic block", dnsQuestion.ids.origRemote.toStringWithPort(), tagName, tagValue), - dnsQuestion.getLogger()->info("Setting tag on query because of a suffix-based dynamic rule", "tag-name", Logging::Loggable(tagName), "tag-value", Logging::Loggable(tagValue))); + dnsQuestion.getLogger()->info("Setting tag on query because of a suffix-based dynamic rule", "dnsdist.tag.name", Logging::Loggable(tagName), "dnsdist.tag.value", Logging::Loggable(tagValue))); updateBlockStats(); dnsQuestion.setTag(tagName, tagValue); // do not return, the whole point it to set a Tag to be able to do further processing in rules @@ -1278,7 +1278,7 @@ ssize_t udpClientSendRequestToBackend(const std::shared_ptr& ba if (result == -1) { int savederrno = errno; VERBOSESLOG(infolog("Error sending request to backend %s: %s", backend->d_config.remote.toStringWithPort(), stringerror(savederrno)), - dnsdist::logging::getTopLogger()->error(savederrno, "Error sending request to the backend", "address", Logging::Loggable(backend->d_config.remote))); + dnsdist::logging::getTopLogger()->error(savederrno, "Error sending request to the backend", "backend.address", Logging::Loggable(backend->d_config.remote))); /* This might sound silly, but on Linux send() might fail with EINVAL if the interface the socket was bound to doesn't exist anymore. @@ -1301,7 +1301,7 @@ static bool isUDPQueryAcceptable(ClientState& clientState, const struct msghdr* if ((msgh->msg_flags & MSG_TRUNC) != 0) { /* message was too large for our buffer */ VERBOSESLOG(infolog("Dropping message too large for our buffer"), - dnsdist::logging::getTopLogger()->info("Dropping query from client that is too large for our buffer", "address", Logging::Loggable(dest), "local-address", Logging::Loggable(clientState.local))); + dnsdist::logging::getTopLogger()->info("Dropping query from client that is too large for our buffer", "source.address", Logging::Loggable(dest), "destination.address", Logging::Loggable(clientState.local))); ++clientState.nonCompliantQueries; ++dnsdist::metrics::g_stats.nonCompliantQueries; return false; @@ -1310,7 +1310,7 @@ static bool isUDPQueryAcceptable(ClientState& clientState, const struct msghdr* expectProxyProtocol = clientState.d_enableProxyProtocol && expectProxyProtocolFrom(remote); if (!dnsdist::configuration::getCurrentRuntimeConfiguration().d_ACL.match(remote) && !expectProxyProtocol) { VERBOSESLOG(infolog("Query from %s dropped because of ACL", remote.toStringWithPort()), - dnsdist::logging::getTopLogger()->info("Query dropped because of ACL", "address", Logging::Loggable(dest))); + dnsdist::logging::getTopLogger()->info("Query dropped because of ACL", "source.address", Logging::Loggable(dest))); ++dnsdist::metrics::g_stats.aclDrops; return false; } @@ -1638,7 +1638,7 @@ ProcessQueryResult processQueryAfterRules(DNSQuestion& dnsQuestion, std::shared_ ++dnsdist::metrics::g_stats.noPolicy; VERBOSESLOG(infolog("%s query for %s|%s from %s, no downstream server available", servFailOnNoPolicy ? "ServFailed" : "Dropped", dnsQuestion.ids.qname.toLogString(), QType(dnsQuestion.ids.qtype).toString(), dnsQuestion.ids.origRemote.toStringWithPort()), - dnsQuestion.getLogger()->info("No downstream server available", "action", Logging::Loggable(servFailOnNoPolicy ? "ServFailed" : "Dropped"))); + dnsQuestion.getLogger()->info("No downstream server available", "dnsdist.action", Logging::Loggable(servFailOnNoPolicy ? "ServFailed" : "Dropped"))); if (servFailOnNoPolicy) { dnsdist::self_answers::removeRecordsAndSetRCode(dnsQuestion, RCode::ServFail); @@ -1727,7 +1727,7 @@ void handleServerStateChange(const string& nameWithAddr, bool newResult) } catch (const std::exception& exp) { SLOG(warnlog("Error calling the Lua hook for Server State Change: %s", exp.what()), - dnsdist::logging::getTopLogger()->error(exp.what(), "Error calling the Lua hook for backend state change", "backend", Logging::Loggable(nameWithAddr))); + dnsdist::logging::getTopLogger()->error(exp.what(), "Error calling the Lua hook for backend state change", "backend.name", Logging::Loggable(nameWithAddr))); } } @@ -1842,7 +1842,7 @@ ProcessQueryResult processQuery(DNSQuestion& dnsQuestion, std::shared_ptrerror(e.what(), "Got and error while parsing a query", "query-id", Logging::Loggable(queryId))); + dnsQuestion.getLogger()->error(e.what(), "Got and error while parsing a query", "dns.question.id", Logging::Loggable(queryId))); } return ProcessQueryResult::Drop; } @@ -1882,7 +1882,7 @@ bool assignOutgoingUDPQueryToBackend(std::shared_ptr& downstrea dnsQuestion.ids.forwardedOverUDP = true; VERBOSESLOG(infolog("Got query for %s|%s from %s%s, relayed to %s%s", dnsQuestion.ids.qname.toLogString(), QType(dnsQuestion.ids.qtype).toString(), dnsQuestion.ids.origRemote.toStringWithPort(), (doh ? " (https)" : ""), downstream->getNameWithAddr(), actuallySend ? "" : " (xsk)"), - dnsQuestion.getLogger()->info("Relayed query to backend", "backend", Logging::Loggable(downstream->getNameWithAddr()), "xsk", Logging::Loggable(actuallySend))); + dnsQuestion.getLogger()->info("Relayed query to backend", "backend.name", Logging::Loggable(downstream->getName()), "backend.address", Logging::Loggable(downstream->d_config.remote), "dnsdist.xsk", Logging::Loggable(actuallySend))); /* make a copy since we cannot touch dnsQuestion.ids after the move */ auto proxyProtocolPayloadSize = dnsQuestion.ids.d_proxyProtocolPayloadSize; @@ -2066,7 +2066,7 @@ static void processUDPQuery(ClientState& clientState, const struct msghdr* msgh, } catch (const std::exception& e) { VERBOSESLOG(infolog("Got an error in UDP question thread while parsing a query from %s, id %d: %s", ids.origRemote.toStringWithPort(), queryId, e.what()), - dnsdist::logging::getTopLogger()->error(e.what(), "Got an error in UDP question thread while parsing a query", "address", Logging::Loggable(ids.origRemote), "query-id", Logging::Loggable(queryId))); + dnsdist::logging::getTopLogger()->error(e.what(), "Got an error in UDP question thread while parsing a query", "source.address", Logging::Loggable(ids.origRemote), "dns.question.id", Logging::Loggable(queryId))); } } @@ -2192,7 +2192,7 @@ bool XskProcessQuery(ClientState& clientState, XskPacket& packet) } catch (const std::exception& e) { VERBOSESLOG(infolog("Got an error in UDP question thread while parsing a query from %s, id %d: %s", ids.origRemote.toStringWithPort(), queryId, e.what()), - dnsdist::logging::getTopLogger()->error(e.what(), "Got an error in XSK UDP question thread while parsing a query", "address", Logging::Loggable(ids.origRemote), "query-id", Logging::Loggable(queryId))); + dnsdist::logging::getTopLogger()->error(e.what(), "Got an error in XSK UDP question thread while parsing a query", "source.address", Logging::Loggable(ids.origRemote), "dns.question.id", Logging::Loggable(queryId))); } return false; } @@ -2265,7 +2265,7 @@ static void MultipleMessagesUDPClientThread(ClientState* clientState) if (msgsGot <= 0) { int savederrno = errno; VERBOSESLOG(infolog("Getting UDP messages via recvmmsg() failed with: %s", stringerror(savederrno)), - dnsdist::logging::getTopLogger()->error(savederrno, "Getting UDP messages via recvmmsg failed", "address", Logging::Loggable(clientState->local))); + dnsdist::logging::getTopLogger()->error(savederrno, "Getting UDP messages via recvmmsg failed", "frontend.address", Logging::Loggable(clientState->local))); msgsGot = 0; continue; } @@ -2300,7 +2300,7 @@ static void MultipleMessagesUDPClientThread(ClientState* clientState) if (sent < 0 || static_cast(sent) != msgsToSend) { int savederrno = errno; VERBOSESLOG(infolog("Error sending responses with sendmmsg() (%d on %u): %s", sent, msgsToSend, stringerror(savederrno)), - dnsdist::logging::getTopLogger()->error(savederrno, "Error sending responses with sendmmsg()", "address", Logging::Loggable(clientState->local), "sent", Logging::Loggable(sent), "messages-to-send", Logging::Loggable(msgsToSend))); + dnsdist::logging::getTopLogger()->error(savederrno, "Error sending responses with sendmmsg()", "address", Logging::Loggable(clientState->local), "dnsdist.sendmmsg.messages_sent", Logging::Loggable(sent), "dnsdist.sendmmsg.messages_to_send", Logging::Loggable(msgsToSend))); } } } @@ -2654,7 +2654,7 @@ static void dropGroupPrivs(gid_t gid) } else { SLOG(warnlog("Warning: Unable to set group ID to %d: %s", gid, stringerror()), - dnsdist::logging::getTopLogger()->error(Logr::Warning, stringerror(), "Warning: Unable to set group ID", "gid", Logging::Loggable(gid))); + dnsdist::logging::getTopLogger()->error(Logr::Warning, stringerror(), "Warning: Unable to set group ID", "systemd.gid", Logging::Loggable(gid))); } } } @@ -2664,7 +2664,7 @@ static void dropUserPrivs(uid_t uid) if (uid != 0) { if (setuid(uid) < 0) { SLOG(warnlog("Warning: Unable to set user ID to %d: %s", uid, stringerror()), - dnsdist::logging::getTopLogger()->error(Logr::Warning, stringerror(), "Warning: Unable to set user ID", "uid", Logging::Loggable(uid))); + dnsdist::logging::getTopLogger()->error(Logr::Warning, stringerror(), "Warning: Unable to set user ID", "system.uid", Logging::Loggable(uid))); } } } @@ -2712,7 +2712,7 @@ static void checkFileDescriptorsLimits(size_t udpBindsCount, size_t tcpBindsCoun getrlimit(RLIMIT_NOFILE, &resourceLimits); if (resourceLimits.rlim_cur <= requiredFDsCount) { SLOG(warnlog("Warning, this configuration can use more than %d file descriptors, web server and console connections not included, and the current limit is %d.", std::to_string(requiredFDsCount), std::to_string(resourceLimits.rlim_cur)), - dnsdist::logging::getTopLogger()->info(Logr::Warning, "Warning, this configuration can use more file descriptors, web server and console connections not included, than the currently configured limit", "required-file-descriptors", Logging::Loggable(requiredFDsCount), "file-descriptors-limit", Logging::Loggable(std::to_string(resourceLimits.rlim_cur)))); + dnsdist::logging::getTopLogger()->info(Logr::Warning, "Warning, this configuration can use more file descriptors, web server and console connections not included, than the currently configured limit", "system.required_file_descriptors", Logging::Loggable(requiredFDsCount), "system.file_descriptors_limit", Logging::Loggable(std::to_string(resourceLimits.rlim_cur)))); #ifdef HAVE_SYSTEMD SLOG(warnlog("You can increase this value by using LimitNOFILE= in the systemd unit file or ulimit."), dnsdist::logging::getTopLogger()->info(Logr::Warning, "You can increase this value by using LimitNOFILE= in the systemd unit file over ulimit")); @@ -2749,7 +2749,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, #else /* TCP_FASTOPEN */ if (warn) { SLOG(warnlog("TCP Fast Open has been configured on local address '%s' but is not supported", addr.toStringWithPort()), - logger->info(Logr::Warning, "TCP Fast Open has been configured but is not supported", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Warning, "TCP Fast Open has been configured but is not supported", "frontend.adddress", Logging::Loggable(addr))); } #endif /* TCP_FASTOPEN */ } @@ -2767,7 +2767,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, #ifdef IPV6_RECVPKTINFO if (addr.isIPv6() && setsockopt(socket, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one)) < 0 && !s_warned_ipv6_recvpktinfo) { SLOG(warnlog("Warning: IPV6_RECVPKTINFO setsockopt failed: %s", stringerror()), - logger->error(stringerror(), "IPV6_RECVPKTINFO setsockopt failed", "local-address", Logging::Loggable(addr))); + logger->error(stringerror(), "IPV6_RECVPKTINFO setsockopt failed", "frontend.address", Logging::Loggable(addr))); s_warned_ipv6_recvpktinfo = true; } #endif @@ -2778,7 +2778,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, if (warn) { /* no need to warn again if configured but support is not available, we already did for UDP */ SLOG(warnlog("SO_REUSEPORT has been configured on local address '%s' but is not supported", addr.toStringWithPort()), - logger->info(Logr::Warning, "SO_REUSEPORT has been configured but is not supported", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Warning, "SO_REUSEPORT has been configured but is not supported", "frontend.adddress", Logging::Loggable(addr))); } } } @@ -2791,7 +2791,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, } catch (const std::exception& e) { SLOG(warnlog("Failed to set IP_MTU_DISCOVER on QUIC server socket for local address '%s': %s", addr.toStringWithPort(), e.what()), - logger->error(Logr::Warning, e.what(), "Failed to set IP_MTU_DISCOVER on QUIC server socket", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, e.what(), "Failed to set IP_MTU_DISCOVER on QUIC server socket", "frontend.adddress", Logging::Loggable(addr))); } } else if (!tcp && !clientState.dnscryptCtx) { @@ -2803,7 +2803,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, } catch (const std::exception& e) { SLOG(warnlog("Failed to set IP_MTU_DISCOVER on UDP server socket for local address '%s': %s", addr.toStringWithPort(), e.what()), - logger->error(Logr::Warning, e.what(), "Failed to set IP_MTU_DISCOVER on UDP server socket", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, e.what(), "Failed to set IP_MTU_DISCOVER on UDP server socket", "frontend.address", Logging::Loggable(addr))); } } @@ -2814,7 +2814,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, } catch (const std::exception& e) { SLOG(warnlog(e.what()), - logger->error(Logr::Warning, e.what(), "Failed to raise send buffer size on UDP server socket", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, e.what(), "Failed to raise send buffer size on UDP server socket", "frontend.address", Logging::Loggable(addr))); } } else { @@ -2822,12 +2822,12 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, auto result = raiseSocketSendBufferToMax(socket); if (result > 0) { SLOG(infolog("Raised send buffer to %u for local address '%s'", result, addr.toStringWithPort()), - logger->info(Logr::Info, "Raised send buffer size", "local-adddress", Logging::Loggable(addr), "buffer-size", Logging::Loggable(result))); + logger->info(Logr::Info, "Raised send buffer size", "frontend.address", Logging::Loggable(addr), "network.send_buffer_size", Logging::Loggable(result))); } } catch (const std::exception& e) { SLOG(warnlog(e.what()), - logger->error(Logr::Warning, e.what(), "Failed to raise send buffer size on UDP server socket", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, e.what(), "Failed to raise send buffer size on UDP server socket", "frontend.address", Logging::Loggable(addr))); } } @@ -2837,7 +2837,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, } catch (const std::exception& e) { SLOG(warnlog(e.what()), - logger->error(Logr::Warning, e.what(), "Failed to raise receive buffer size on UDP server socket", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, e.what(), "Failed to raise receive buffer size on UDP server socket", "frontend.address", Logging::Loggable(addr))); } } else { @@ -2845,12 +2845,12 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, auto result = raiseSocketReceiveBufferToMax(socket); if (result > 0) { SLOG(infolog("Raised receive buffer to %u for local address '%s'", result, addr.toStringWithPort()), - logger->info(Logr::Info, "Raised receive buffer size", "local-adddress", Logging::Loggable(addr), "buffer-size", Logging::Loggable(result))); + logger->info(Logr::Info, "Raised receive buffer size", "frontend.address", Logging::Loggable(addr), "buffer-size", Logging::Loggable(result))); } } catch (const std::exception& e) { SLOG(warnlog(e.what()), - logger->error(Logr::Warning, e.what(), "Failed to raise receive buffer size on UDP server socket", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, e.what(), "Failed to raise receive buffer size on UDP server socket", "frontend.address", Logging::Loggable(addr))); } } } @@ -2861,12 +2861,12 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, int res = setsockopt(socket, SOL_SOCKET, SO_BINDTODEVICE, itf.c_str(), itf.length()); if (res != 0) { SLOG(warnlog("Error setting up the interface on local address '%s': %s", addr.toStringWithPort(), stringerror()), - logger->error(Logr::Warning, stringerror(), "Error setting up the interface", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, stringerror(), "Error setting up the interface", "frontend.address", Logging::Loggable(addr))); } #else if (warn) { SLOG(warnlog("An interface has been configured on local address '%s' but SO_BINDTODEVICE is not supported", addr.toStringWithPort()), - logger->error(Logr::Warning, stringerror(), "An interface has been configured but SO_BINDTODEVICE is not supported", "local-adddress", Logging::Loggable(addr))); + logger->error(Logr::Warning, stringerror(), "An interface has been configured but SO_BINDTODEVICE is not supported", "frontend.address", Logging::Loggable(addr))); } #endif } @@ -2878,7 +2878,7 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, if (!isQUIC && g_defaultBPFFilter && !g_defaultBPFFilter->isExternal()) { clientState.attachFilter(g_defaultBPFFilter, socket); VERBOSESLOG(infolog("Attaching default BPF Filter to %s frontend %s", (!tcp ? std::string("UDP") : std::string("TCP")), addr.toStringWithPort()), - logger->info(Logr::Info, "Attaching default BPF Filter to frontend", "local-adddress", Logging::Loggable(addr), "protocol", Logging::Loggable((!tcp ? std::string("UDP") : std::string("TCP"))))); + logger->info(Logr::Info, "Attaching default BPF Filter to frontend", "frontend.address", Logging::Loggable(addr), "network.transport", Logging::Loggable((!tcp ? std::string("udp") : std::string("tcp"))))); } #endif /* HAVE_EBPF */ @@ -2889,34 +2889,34 @@ static void setupLocalSocket(ClientState& clientState, const ComboAddress& addr, if (clientState.tlsFrontend != nullptr) { SLOG(infolog("Listening on %s for TLS", addr.toStringWithPort()), - logger->info(Logr::Info, "Listening on DoT frontend", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Info, "Listening on DoT frontend", "frontend.address", Logging::Loggable(addr))); } else if (clientState.dohFrontend != nullptr) { SLOG(infolog("Listening on %s for DoH", addr.toStringWithPort()), - logger->info(Logr::Info, "Listening on DoH frontend", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Info, "Listening on DoH frontend", "frontend.address", Logging::Loggable(addr))); } else if (clientState.dnscryptCtx != nullptr) { SLOG(infolog("Listening on %s for DNSCrypt", addr.toStringWithPort()), - logger->info(Logr::Info, "Listening on DNSCrypt frontend", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Info, "Listening on DNSCrypt frontend", "frontend.address", Logging::Loggable(addr))); } else { SLOG(infolog("Listening on %s", addr.toStringWithPort()), - logger->info(Logr::Info, "Listening on Do53 frontend", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Info, "Listening on Do53 frontend", "frontend.address", Logging::Loggable(addr))); } } else { if (clientState.doqFrontend != nullptr) { SLOG(infolog("Listening on %s for DoQ", addr.toStringWithPort()), - logger->info(Logr::Info, "Listening on DoQ frontend", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Info, "Listening on DoQ frontend", "frontend.address", Logging::Loggable(addr))); } else if (clientState.doh3Frontend != nullptr) { SLOG(infolog("Listening on %s for DoH3", addr.toStringWithPort()), - logger->info(Logr::Info, "Listening on DoH3 frontend", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Info, "Listening on DoH3 frontend", "frontend.address", Logging::Loggable(addr))); } #ifdef HAVE_XSK else if (clientState.xskInfo != nullptr) { SLOG(infolog("Listening on %s (XSK-enabled)", addr.toStringWithPort()), - logger->info(Logr::Info, "Listening on XSK-enabled frontend", "local-adddress", Logging::Loggable(addr))); + logger->info(Logr::Info, "Listening on XSK-enabled frontend", "frontend.address", Logging::Loggable(addr))); } #endif } @@ -2938,7 +2938,7 @@ static void setUpLocalBind(ClientState& cstate, const std::shared_ptrsetupTLS()) { SLOG(errlog("Error while setting up TLS on local address '%s', exiting", cstate.local.toStringWithPort()), - logger->info(Logr::Error, "Error while setting up TLS bind, exiting", "local-address", Logging::Loggable(cstate.local))); + logger->info(Logr::Error, "Error while setting up TLS bind, exiting", "frontend.address", Logging::Loggable(cstate.local))); _exit(EXIT_FAILURE); } } @@ -3322,7 +3322,7 @@ static void setupPools(const std::shared_ptr& logger) for (const auto& backend : currentConfig.d_backends) { if (backend->d_config.d_weight < 100) { VERBOSESLOG(infolog("Warning, the backend '%s' has a very low weight (%d), which will not yield a good distribution of queries with the 'chashed' policy. Please consider raising it to at least '100'.", backend->getName(), backend->d_config.d_weight), - logger->info(Logr::Info, "Warning, this backend has a very low weight, which will not yield a good distribution of queries with the 'chashed' policy. Please consider raising it to at least '100'", "backend", Logging::Loggable(backend->getName()), "weight", Logging::Loggable(backend->d_config.d_weight))); + logger->info(Logr::Info, "Warning, this backend has a very low weight, which will not yield a good distribution of queries with the 'chashed' policy. Please consider raising it to at least '100'", "backend.name", Logging::Loggable(backend->getName()), "backend.weight", Logging::Loggable(backend->d_config.d_weight))); } backend->hash(); @@ -3521,7 +3521,7 @@ static ListeningSockets initListeningSockets() } catch (const std::exception& exp) { SLOG(errlog("Unable to bind to control socket on %s: %s", local.toStringWithPort(), exp.what()), - dnsdist::logging::getTopLogger()->error(exp.what(), "Unable to bind to console control socket", "local-address", Logging::Loggable(local))); + dnsdist::logging::getTopLogger()->error(exp.what(), "Unable to bind to console control socket", "network.local.address", Logging::Loggable(local))); } } @@ -3534,7 +3534,7 @@ static ListeningSockets initListeningSockets() } catch (const std::exception& exp) { SLOG(errlog("Unable to bind to web server socket on %s: %s", local.toStringWithPort(), exp.what()), - dnsdist::logging::getTopLogger()->error(exp.what(), "Unable to bind to web server socket", "local-address", Logging::Loggable(local))); + dnsdist::logging::getTopLogger()->error(exp.what(), "Unable to bind to web server socket", "network.local.address", Logging::Loggable(local))); } } @@ -3562,13 +3562,13 @@ static bool loadConfigurationFromFile(const std::string& configurationFile, bool if (auto tentativeLuaConfFile = lookForTentativeConfigurationFileWithExtension(configurationFile, "lua")) { VERBOSESLOG(infolog("Loading configuration from auto-discovered Lua file %s", *tentativeLuaConfFile), - logger->info(Logr::Info, "Loading configuration from auto-discovered Lua file", "configuration-file", Logging::Loggable(*tentativeLuaConfFile))); + logger->info(Logr::Info, "Loading configuration from auto-discovered Lua file", "dnsdist.configuration.file", Logging::Loggable(*tentativeLuaConfFile))); dnsdist::configuration::lua::loadLuaConfigurationFile(*(g_lua.lock()), *tentativeLuaConfFile, configCheck); } VERBOSESLOG(infolog("Loading configuration from YAML file %s", configurationFile), - logger->info(Logr::Info, "Loading configuration from YAML file", "configuration-file", Logging::Loggable(configurationFile))); + logger->info(Logr::Info, "Loading configuration from YAML file", "dnsdist.configuration.file", Logging::Loggable(configurationFile))); if (!dnsdist::configuration::yaml::loadConfigurationFromFile(configurationFile, isClient, configCheck)) { return false; @@ -3582,18 +3582,18 @@ static bool loadConfigurationFromFile(const std::string& configurationFile, bool dnsdist::lua::setupLua(*(g_lua.lock()), isClient, configCheck); if (boost::ends_with(configurationFile, ".lua")) { VERBOSESLOG(infolog("Loading configuration from Lua file %s", configurationFile), - logger->info(Logr::Info, "Loading configuration from Lua file", "configuration-file", Logging::Loggable(configurationFile))); + logger->info(Logr::Info, "Loading configuration from Lua file", "dnsdist.configuration.file", Logging::Loggable(configurationFile))); dnsdist::configuration::lua::loadLuaConfigurationFile(*(g_lua.lock()), configurationFile, configCheck); if (auto tentativeYamlConfFile = lookForTentativeConfigurationFileWithExtension(configurationFile, "yml")) { VERBOSESLOG(infolog("Loading configuration from auto-discovered YAML file %s", *tentativeYamlConfFile), - logger->info(Logr::Info, "Loading configuration from auto-discovered YAML file", "configuration-file", Logging::Loggable(*tentativeYamlConfFile))); + logger->info(Logr::Info, "Loading configuration from auto-discovered YAML file", "dnsdist.configuration.file", Logging::Loggable(*tentativeYamlConfFile))); return dnsdist::configuration::yaml::loadConfigurationFromFile(*tentativeYamlConfFile, isClient, configCheck); } } else { VERBOSESLOG(infolog("Loading configuration from Lua file %s", configurationFile), - logger->info(Logr::Info, "Loading configuration from Lua file", "configuration-file", Logging::Loggable(configurationFile))); + logger->info(Logr::Info, "Loading configuration from Lua file", "dnsdist.configuration.file", Logging::Loggable(configurationFile))); dnsdist::configuration::lua::loadLuaConfigurationFile(*(g_lua.lock()), configurationFile, configCheck); } @@ -3695,7 +3695,7 @@ int main(int argc, char** argv) } // No exception was thrown SLOG(infolog("Configuration '%s' OK!", cmdLine.config), - setupLogger->info(Logr::Info, "Configuration OK", "configuration-file", Logging::Loggable(cmdLine.config))); + setupLogger->info(Logr::Info, "Configuration OK", "dnsdist.configuration.file", Logging::Loggable(cmdLine.config))); doExitNicely(); } @@ -3818,7 +3818,7 @@ int main(int argc, char** argv) but low enough to be useful */ if (maxTCPClientThreads >= 50U) { SLOG(warnlog("setMaxTCPClientThreads(%d) might create a large number of TCP connections to backends, and is probably not needed, please consider lowering it", maxTCPClientThreads), - setupLogger->info(Logr::Warning, "The current setMaxTCPClientThreads() value might create a large number of TCP connections to backends, and is probably not needed, please consider lowering it", "value", Logging::Loggable(maxTCPClientThreads))); + setupLogger->info(Logr::Warning, "The current setMaxTCPClientThreads() value might create a large number of TCP connections to backends, and is probably not needed, please consider lowering it", "dnsdist.max_tcp_client_threads", Logging::Loggable(maxTCPClientThreads))); } g_tcpclientthreads = std::make_unique(maxTCPClientThreads, std::vector()); #endif @@ -3878,7 +3878,7 @@ int main(int argc, char** argv) dss->submitHealthCheckResult(true, false); dss->setUpStatus(false); SLOG(warnlog("Marking downstream %s as 'down'", dss->getNameWithAddr()), - setupLogger->info(Logr::Warning, "Marking downstream backend server as 'down'", "backend-name", Logging::Loggable(dss->getName()), "address", Logging::Loggable(dss->d_config.remote))); + setupLogger->info(Logr::Warning, "Marking downstream backend server as 'down'", "backend.name", Logging::Loggable(dss->getName()), "backend.address", Logging::Loggable(dss->d_config.remote), "backend.health_check.status", Logging::Loggable("down"))); } } } diff --git a/pdns/dnsdistdist/doh3.cc b/pdns/dnsdistdist/doh3.cc index bdc544d687..153b3e73b6 100644 --- a/pdns/dnsdistdist/doh3.cc +++ b/pdns/dnsdistdist/doh3.cc @@ -514,7 +514,7 @@ static void processDOH3Query(DOH3UnitUniquePtr&& doh3Unit) if (!dnsdist::configuration::getCurrentRuntimeConfiguration().d_ACL.match(remote)) { VERBOSESLOG(infolog("Query from %s (DoH3) dropped because of ACL", remote.toStringWithPort()), - dsc->df->getLogger().info("DoH3 query dropped because of ACL", "address", Logging::Loggable(remote))); + dsc->df->getLogger().info("DoH3 query dropped because of ACL", "client.address", Logging::Loggable(remote))); ++dnsdist::metrics::g_stats.aclDrops; unit->response.clear(); @@ -651,7 +651,7 @@ static void processDOH3Query(DOH3UnitUniquePtr&& doh3Unit) catch (const std::exception& e) { if (unit) { VERBOSESLOG(infolog("Got an error in DOH3 question thread while parsing a query from %s, id %d: %s", remote.toStringWithPort(), queryId, e.what()), - unit->dsc->df->getLogger().error(Logr::Info, e.what(), "Got an error in DoH3 question thread while parsing a query", "address", Logging::Loggable(remote), "query-id", Logging::Loggable(queryId))); + unit->dsc->df->getLogger().error(Logr::Info, e.what(), "Got an error in DoH3 question thread while parsing a query", "client.address", Logging::Loggable(remote), "dns.question.id", Logging::Loggable(queryId))); unit->status_code = 500; handleImmediateResponse(std::move(unit), "DoH3 internal error"); } @@ -676,7 +676,7 @@ static void doh3_dispatch_query(DOH3ServerConfig& dsc, PacketBuffer&& query, con } catch (const std::exception& exp) { VERBOSESLOG(infolog("Had error handling DoH3 DNS packet from %s: %s", remote.toStringWithPort(), exp.what()), - dsc.df->getLogger().error(Logr::Info, exp.what(), "Had error handling DoH3 DNS packet", "address", Logging::Loggable(remote))); + dsc.df->getLogger().error(Logr::Info, exp.what(), "Had error handling DoH3 DNS packet", "client.address", Logging::Loggable(remote))); } } @@ -1009,7 +1009,7 @@ void doh3Thread(ClientState* clientState) { try { std::shared_ptr& frontend = clientState->doh3Frontend; - auto frontendLogger = dnsdist::logging::getTopLogger()->withName("doh3-frontend")->withValues("address", Logging::Loggable(clientState->local)); + auto frontendLogger = dnsdist::logging::getTopLogger()->withName("doh3-frontend")->withValues("frontend.address", Logging::Loggable(clientState->local)); frontend->d_server_config->clientState = clientState; frontend->d_server_config->df = clientState->doh3Frontend; diff --git a/pdns/dnsdistdist/doq-common.cc b/pdns/dnsdistdist/doq-common.cc index 43a3faa034..16bdfe359d 100644 --- a/pdns/dnsdistdist/doq-common.cc +++ b/pdns/dnsdistdist/doq-common.cc @@ -149,7 +149,7 @@ static void sendFromTo(Socket& sock, const ComboAddress& peer, const ComboAddres if (ret < 0) { auto error = errno; VERBOSESLOG(infolog("Error while sending QUIC datagram of size %d to %s: %s", buffer.size(), peer.toStringWithPort(), stringerror(error)), - dnsdist::logging::getTopLogger()->error(Logr::Info, error, "Error while sending QUIC datagram", "size", Logging::Loggable(buffer.size()), "destination", Logging::Loggable(peer))); + dnsdist::logging::getTopLogger()->error(Logr::Info, error, "Error while sending QUIC datagram", "datagram_size", Logging::Loggable(buffer.size()), "destination.address", Logging::Loggable(peer))); } return; } @@ -159,7 +159,7 @@ static void sendFromTo(Socket& sock, const ComboAddress& peer, const ComboAddres } catch (const std::exception& exp) { VERBOSESLOG(infolog("Error while sending QUIC datagram of size %d from %s to %s: %s", buffer.size(), local.toStringWithPort(), peer.toStringWithPort(), exp.what()), - dnsdist::logging::getTopLogger()->error(Logr::Info, exp.what(), "Error while sending QUIC datagram", "size", Logging::Loggable(buffer.size()), "source", Logging::Loggable(local), "destination", Logging::Loggable(peer))); + dnsdist::logging::getTopLogger()->error(Logr::Info, exp.what(), "Error while sending QUIC datagram", "datagram_size", Logging::Loggable(buffer.size()), "source.address", Logging::Loggable(local), "destination.address", Logging::Loggable(peer))); } } diff --git a/pdns/dnsdistdist/doq.cc b/pdns/dnsdistdist/doq.cc index ba46f52d9e..ba6177628f 100644 --- a/pdns/dnsdistdist/doq.cc +++ b/pdns/dnsdistdist/doq.cc @@ -424,7 +424,7 @@ static void processDOQQuery(DOQUnitUniquePtr&& doqUnit) if (!dnsdist::configuration::getCurrentRuntimeConfiguration().d_ACL.match(remote)) { VERBOSESLOG(infolog("Query from %s (DoQ) dropped because of ACL", remote.toStringWithPort()), - dsc->df->getLogger().info("DoQ query dropped because of ACL", "address", Logging::Loggable(remote))); + dsc->df->getLogger().info("DoQ query dropped because of ACL", "client.address", Logging::Loggable(remote))); ++dnsdist::metrics::g_stats.aclDrops; unit->response.clear(); @@ -553,7 +553,7 @@ static void processDOQQuery(DOQUnitUniquePtr&& doqUnit) catch (const std::exception& e) { if (unit) { VERBOSESLOG(infolog("Got an error in DOQ question thread while parsing a query from %s, id %d: %s", remote.toStringWithPort(), queryId, e.what()), - unit->dsc->df->getLogger().error(Logr::Info, e.what(), "Got an error in DOQ question thread while parsing a query", "address", Logging::Loggable(remote), "query-id", Logging::Loggable(queryId))); + unit->dsc->df->getLogger().error(Logr::Info, e.what(), "Got an error in DOQ question thread while parsing a query", "client.address", Logging::Loggable(remote), "dns.question.id", Logging::Loggable(queryId))); handleImmediateResponse(std::move(unit), "DoQ internal error"); } return; @@ -576,7 +576,7 @@ static void doq_dispatch_query(DOQServerConfig& dsc, PacketBuffer&& query, const } catch (const std::exception& exp) { VERBOSESLOG(infolog("Had error handling DoQ DNS packet from %s: %s", remote.toStringWithPort(), exp.what()), - dsc.df->getLogger().error(Logr::Info, exp.what(), "Had error handling DoQ DNS packet", "address", Logging::Loggable(remote))); + dsc.df->getLogger().error(Logr::Info, exp.what(), "Had error handling DoQ DNS packet", "client.address", Logging::Loggable(remote))); } } @@ -796,7 +796,7 @@ void doqThread(ClientState* clientState) { try { std::shared_ptr& frontend = clientState->doqFrontend; - auto frontendLogger = dnsdist::logging::getTopLogger()->withName("doq-frontend")->withValues("address", Logging::Loggable(clientState->local)); + auto frontendLogger = dnsdist::logging::getTopLogger()->withName("doq-frontend")->withValues("frontend.address", Logging::Loggable(clientState->local)); frontend->d_server_config->clientState = clientState; frontend->d_server_config->df = clientState->doqFrontend; diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc b/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc index 82b18ed325..b8a1f243d4 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc @@ -267,7 +267,7 @@ private: } catch (const std::exception& e) { SLOG(infolog("Error parsing the status header for stream ID %d: %s", frame->hd.stream_id, e.what()), - dnsdist::logging::getTopLogger()->error(e.what(), "Error parsing the status header for stream", "stream-id", Logging::Loggable(frame->hd.stream_id))); + dnsdist::logging::getTopLogger()->error(e.what(), "Error parsing the status header for stream", "http.stream_id", Logging::Loggable(frame->hd.stream_id))); return NGHTTP2_ERR_CALLBACK_FAILURE; } }