0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-51489 Add client IP to slow query log lines in server logs

This commit is contained in:
Amirsaman Memaripour 2020-11-24 20:27:00 +00:00 committed by Evergreen Agent
parent 82aea1d428
commit 0bd81777cb
6 changed files with 12 additions and 12 deletions

View File

@ -25,7 +25,7 @@ if (isJsonLog(conn)) {
return log.id === 20250 && log.attr.principalName === "root" &&
log.attr.authenticationDatabase === "admin" &&
/(?:\d{1,3}\.){3}\d{1,3}:\d+/.test(log.attr.client);
/(?:\d{1,3}\.){3}\d{1,3}:\d+/.test(log.attr.remote);
}
function checkSCRAMfail(element, index, array) {
@ -33,7 +33,7 @@ if (isJsonLog(conn)) {
return log.id === 20249 && /SCRAM-SHA-\d+/.test(log.attr.mechanism) &&
log.attr.principalName === "root" && log.attr.authenticationDatabase === "admin" &&
/(?:\d{1,3}\.){3}\d{1,3}:\d+/.test(log.attr.client);
/(?:\d{1,3}\.){3}\d{1,3}:\d+/.test(log.attr.remote);
}
assert(log.some(checkAuthSuccess));

View File

@ -49,7 +49,7 @@ function authAndTest(mongo, {clusterUserSeparationOveride = false} = {}) {
return logJson.id === 20429 && logJson.attr.user === CLIENT_USER &&
logJson.attr.db === "$external" &&
/(?:\d{1,3}\.){3}\d{1,3}:\d+/.test(logJson.attr.client);
/(?:\d{1,3}\.){3}\d{1,3}:\d+/.test(logJson.attr.remote);
}
assert(log.some(checkAuthSuccess));
} else {

View File

@ -202,7 +202,7 @@ Status doSaslStep(OperationContext* opCtx,
"mechanism"_attr = mechanism.mechanismName(),
"principalName"_attr = mechanism.getPrincipalName(),
"authenticationDatabase"_attr = mechanism.getAuthenticationDatabase(),
"client"_attr = opCtx->getClient()->getRemote().toString(),
"remote"_attr = opCtx->getClient()->getRemote(),
"result"_attr = redact(swResponse.getStatus()));
sleepmillis(saslGlobalParams.authFailedDelay.load());
@ -231,7 +231,7 @@ Status doSaslStep(OperationContext* opCtx,
"mechanism"_attr = mechanism.mechanismName(),
"principalName"_attr = mechanism.getPrincipalName(),
"authenticationDatabase"_attr = mechanism.getAuthenticationDatabase(),
"client"_attr = opCtx->getClient()->session()->remote());
"remote"_attr = opCtx->getClient()->session()->remote());
}
if (session->isSpeculative()) {
status = authCounter.incSpeculativeAuthenticateSuccessful(

View File

@ -310,7 +310,7 @@ bool CmdAuthenticate::run(OperationContext* opCtx,
"Successfully authenticated",
"user"_attr = user.getUser(),
"db"_attr = user.getDB(),
"client"_attr = opCtx->getClient()->session()->remote());
"remote"_attr = opCtx->getClient()->session()->remote());
}
uassertStatusOK(authCounter.incAuthenticateSuccessful(mechanism));

View File

@ -1085,6 +1085,10 @@ void OpDebug::report(OperationContext* opCtx,
pAttrs->add("operationMetrics", builder.obj());
}
if (client && client->session()) {
pAttrs->add("remote", client->session()->remote());
}
if (iscommand) {
pAttrs->add("protocol", getProtoString(networkOp));
}

View File

@ -237,9 +237,7 @@ public:
TimeoutSyncSEP(Mode mode) : _mode(mode) {}
void startSession(transport::SessionHandle session) override {
LOGV2(23040,
"Accepted connection from {session_remote}",
"session_remote"_attr = session->remote());
LOGV2(23040, "Accepted connection", "remote"_attr = session->remote());
startWorkerThread([this, session = std::move(session)]() mutable {
LOGV2(23041, "waiting for message");
session->setTimeout(Milliseconds{500});
@ -335,9 +333,7 @@ TEST(TransportLayerASIO, SourceSyncTimeoutSucceeds) {
class TimeoutSwitchModesSEP : public TimeoutSEP {
public:
void startSession(transport::SessionHandle session) override {
LOGV2(23044,
"Accepted connection from {session_remote}",
"session_remote"_attr = session->remote());
LOGV2(23044, "Accepted connection", "remote"_attr = session->remote());
startWorkerThread([this, session = std::move(session)]() mutable {
LOGV2(23045, "waiting for message");
auto sourceMessage = [&] { return session->sourceMessage().getStatus(); };