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:
parent
82aea1d428
commit
0bd81777cb
@ -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));
|
||||
|
@ -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 {
|
||||
|
@ -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(
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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(); };
|
||||
|
Loading…
Reference in New Issue
Block a user