정의
getAuditConfig버전 5.0의 신규 항목입니다.
getAuditConfigis an administrative command that retrieves audit configurations frommongodandmongosserver instances.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
중요
이 명령은 MongoDB Atlas 클러스터에서 지원되지 않습니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.
구문
명령은 다음과 같은 구문을 가집니다:
db.adminCommand( { getAuditConfig: 1 } )
행동
Auditing must be enabled to use getAuditConfig.
런타임 감사 구성에 참여하지 않는 노드는 auditLog.filter 및 setParameter.auditAuthorizationSuccess 에 대한 현재 구성 파일 설정을 반환합니다.
Nodes that are participating in the runtime audit synthesize their current configuration from memory. Configuration updates are distributed via the oplog mechanism which means updates on mongod nodes are distributed to secondary nodes very quickly. However, the distribution mechanism is different on mongos nodes. mongos nodes have to poll the primary server at regular intervals for configuration updates. You may see stale data due to polling delay if you run setAuditConfig on the primary server and getAuditConfig on a shard before the shard has polled the primary server for updated configuration details.
참고
자동화된 감사 스크립트를 작성하는 경우 클러스터 서명을 나타내는 데 사용되는 인용 스타일과 유형이 mongosh 와 레거시 mongo shell 간에 다르다는 점에 유의하세요. mongosh 에서 유형은 바이너리 및 Long입니다. 레거시 shell 에서 해당 유형은 BinData 및 NumberLong입니다.
// mongosh signature: { hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0), keyId: Long("0") } // mongo "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : Long(0) }
예시
Run getAuditConfig on the admin database .
db.adminCommand({getAuditConfig: 1})
예제 서버는 읽기 및 쓰기 작업을 감사하도록 구성됩니다. 여기에는 원하는 작업을 캡처하는 필터가 있으며 auditAuthorizationSuccess 값이 true 로 설정되었습니다.
{ generation: ObjectId("60e73e74680a655705f16525"), filter: { atype: 'authCheck', 'param.command': { '$in': [ 'find', 'insert', 'delete', 'update', 'findandmodify' ] } }, auditAuthorizationSuccess: true, ok: 1, '$clusterTime': { clusterTime: Timestamp(1, 1625767540), signature: { hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0), keyId: Long("0") } }, operationTime: Timestamp(1, 1625767540) }