aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrew-rykov <arykov@ydb.tech>2022-11-17 20:48:20 +0300
committerandrew-rykov <arykov@ydb.tech>2022-11-17 20:48:20 +0300
commit5da5e8d7d55c2737d307e1ccec3f931088de3c5f (patch)
tree78929c964f5624c94728a7f61d5f490f88559d28
parent2d3c5d0080ff2afde3f91644718f1d094b9d6aa2 (diff)
downloadydb-5da5e8d7d55c2737d307e1ccec3f931088de3c5f.tar.gz
audit log system ss
-rw-r--r--ydb/core/tx/schemeshard/CMakeLists.txt1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation.cpp40
2 files changed, 17 insertions, 24 deletions
diff --git a/ydb/core/tx/schemeshard/CMakeLists.txt b/ydb/core/tx/schemeshard/CMakeLists.txt
index d227762db8..e533a8a913 100644
--- a/ydb/core/tx/schemeshard/CMakeLists.txt
+++ b/ydb/core/tx/schemeshard/CMakeLists.txt
@@ -61,6 +61,7 @@ target_link_libraries(core-tx-schemeshard PUBLIC
cpp-deprecated-enum_codegen
cpp-html-pcdata
ydb-core-actorlib_impl
+ ydb-core-audit
ydb-core-base
ydb-core-blob_depot
core-blockstore-core
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation.cpp b/ydb/core/tx/schemeshard/schemeshard__operation.cpp
index 7e84f443e1..800582cdbd 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation.cpp
@@ -6,6 +6,7 @@
#include "schemeshard__operation_db_changes.h"
#include "schemeshard_audit_log_fragment.h"
+#include "ydb/core/audit/audit_log.h"
#include "schemeshard_impl.h"
@@ -70,32 +71,23 @@ NKikimrScheme::TEvModifySchemeTransaction GetRecordForPrint(const NKikimrScheme:
return recordForPrint;
}
-TString GetAuditLogEntry(const TTxId& txId, const THolder<TProposeResponse>& response, TOperationContext& context) {
- auto auditLog = TStringBuilder();
-
- auditLog << "txId: " << txId;
-
+void MakeAuditLog(const TTxId& txId, const THolder<TProposeResponse>& response, TOperationContext& context) {
auto fragPath = TPath::Resolve(context.AuditLogFragments.front().GetAnyPath(), context.SS);
if (!fragPath.IsResolved()) {
fragPath.RiseUntilFirstResolvedParent();
}
- if (!fragPath.IsEmpty()) {
- auditLog << ", database: " << fragPath.GetDomainPathString();
- }
-
- auditLog << ", subject: " << context.GetSubject();
-
- auditLog << ", status: " << NKikimrScheme::EStatus_Name(response->Record.GetStatus());
- if (response->Record.HasReason()) {
- auditLog << ", reason: " << response->Record.GetReason();
- }
- for (const auto& frag: context.AuditLogFragments) {
- auditLog << ", ";
- auditLog << frag.ToString();
+ auto operations = TStringBuilder();
+ for (auto it = context.AuditLogFragments.begin(); it != context.AuditLogFragments.end(); it++) {
+ AUDIT_LOG(
+ AUDIT_PART("txId", std::to_string(txId.GetValue()))
+ AUDIT_PART("database", fragPath.GetDomainPathString(), !fragPath.IsEmpty())
+ AUDIT_PART("subject", context.GetSubject())
+ AUDIT_PART("status", NKikimrScheme::EStatus_Name(response->Record.GetStatus()))
+ AUDIT_PART("reason", response->Record.GetReason(), response->Record.HasReason())
+ AUDIT_PART("operation", (*it).ToString())
+ );
}
-
- return auditLog;
}
THolder<TProposeResponse> TSchemeShard::IgniteOperation(TProposeRequest& request, TOperationContext& context) {
@@ -138,7 +130,7 @@ THolder<TProposeResponse> TSchemeShard::IgniteOperation(TProposeRequest& request
response->SetError(quotaResult.Status, quotaResult.Reason);
Operations.erase(txId);
- LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "AUDIT: " << GetAuditLogEntry(txId, response, context));
+ MakeAuditLog(txId, response, context);
return std::move(response);
}
}
@@ -160,7 +152,7 @@ THolder<TProposeResponse> TSchemeShard::IgniteOperation(TProposeRequest& request
response->SetError(splitResult.Status, splitResult.Reason);
Operations.erase(txId);
- LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "AUDIT: " << GetAuditLogEntry(txId, response, context));
+ MakeAuditLog(txId, response, context);
return std::move(response);
}
@@ -241,13 +233,13 @@ THolder<TProposeResponse> TSchemeShard::IgniteOperation(TProposeRequest& request
context.OnComplete.ApplyOnExecute(context.SS, context.GetTxc(), context.Ctx);
Operations.erase(txId);
- LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "AUDIT: " << GetAuditLogEntry(txId, response, context));
+ MakeAuditLog(txId, response, context);
return std::move(response);
}
}
}
- LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "AUDIT: " << GetAuditLogEntry(txId, response, context));
+ MakeAuditLog(txId, response, context);
return std::move(response);
}