#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
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;
}
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<unsigned long long>(dnsquestion->getQueryRealTime().tv_sec), static_cast<unsigned long>(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),
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)));
}
}
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<unsigned long long>(response->getQueryRealTime().tv_sec), static_cast<unsigned long>(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),
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)));
}
}
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())));
}
}
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));
}
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));
}
}
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;
}
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));
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;
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
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 {
{
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);
{
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 ;
}
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);
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,
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,
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 {
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)));
}
}
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) {
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();
}
/* 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)) {
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);
}
}
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;
}
[[nodiscard]] std::shared_ptr<const Logr::Logger> 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
{
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 */
}
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;
}
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);
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;
}
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;
};
});
}
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<void(const ClientEntry& entry)>& callback)
}
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 */
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;
}
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;
#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;
}
}
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;
}
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()) {
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) */
}
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)));
}
}
}
state->xskInfoResponder = 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));
auto [success, error] = libssl_load_engine(std::string(engine.name), !engine.default_string.empty() ? std::optional<std::string>(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 */
}
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 */
}
}
// 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,
};
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()) {
}
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
{
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);
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"));
}
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)));
}
}
}
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;
}
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;
}
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);
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))
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;
}
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;
}
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;
}
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 = "<h1>Unauthorized</h1>";
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"));
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;
}
{
try {
setThreadName("dnsdist/XskResp");
- 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 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()) {
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;
}
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;
}
}
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)));
}
}
catch (const std::exception& e) {
if (remote && !response.empty() && static_cast<size_t>(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) {
}
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)));
}
}
}
}
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)));
}
}
}
{
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) {
// listens on a dedicated socket, lobs answers from downstream servers to original requestors
void responderThread(std::shared_ptr<DownstreamState> 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");
}
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)));
}
}
}
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
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
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.
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;
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;
}
++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);
}
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)));
}
}
}
catch (const std::exception& e) {
VERBOSESLOG(infolog("Got an error while parsing a %s query from %s, id %d: %s", (dnsQuestion.overTCP() ? "TCP" : "UDP"), dnsQuestion.ids.origRemote.toStringWithPort(), queryId, e.what()),
- dnsQuestion.getLogger()->error(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;
}
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;
}
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)));
}
}
}
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;
}
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;
}
if (sent < 0 || static_cast<unsigned int>(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)));
}
}
}
}
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)));
}
}
}
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)));
}
}
}
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"));
#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 */
}
#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
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)));
}
}
}
}
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) {
}
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)));
}
}
}
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 {
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)));
}
}
}
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 {
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)));
}
}
}
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
}
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 */
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
}
if (cstate.tlsFrontend != nullptr) {
if (!cstate.tlsFrontend->setupTLS()) {
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);
}
}
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();
}
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)));
}
}
}
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)));
}
}
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;
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);
}
}
// 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();
}
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<TCPClientCollection>(maxTCPClientThreads, std::vector<ClientState*>());
#endif
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")));
}
}
}
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();
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");
}
}
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)));
}
}
{
try {
std::shared_ptr<DOH3Frontend>& 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;
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;
}
}
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)));
}
}
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();
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;
}
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)));
}
}
{
try {
std::shared_ptr<DOQFrontend>& 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;
}
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;
}
}