Atlas 플랫폼 활동을 모니터링하려면 감사 기능을 사용하세요.
Atlas 감사의 기능
M10+ 클러스터에서 사용 가능한 데이터베이스 감사 기능은 여러 사용자가 있는 배포에서 시스템 활동을 추적할 수 있게 해줍니다.
Atlas 관리자는 MongoDB에서 사용자 지정 JSON 감사 필터를 생성해 시스템 전반의 감사 항목을 세밀하게 제어할 수 있습니다.
이 접근 방식을 사용하면 모니터링할 작업, 데이터베이스 사용자 및 Atlas 역할을 정확히 지정할 수 있어 Atlas UI의 기본 제공 필터 빌더보다 감사 과정을 더욱 세밀하게 관리할 수 있습니다.
수동 감사 구성을 사용하면 Atlas에서 문서화된 거의 모든 시스템 이벤트 조치를 모니터링할 수 있습니다.
포괄적인 데이터베이스 감사 기능은 아래 항목을 상세히 추적할 수 있습니다.
DDL(데이터 정의 언어) 작업
DML(데이터 조작 언어) 작업
DCL(데이터 제어 언어) 작업
이는 데이터베이스 스키마 변경, 데이터 수정 및 권한 조정에 대한 완전한 가시성을 제공합니다.
구현 지침, 전체 이벤트 목록 및 실용적인 구성 예시는 MongoDB 감사 및 감사 필터 예시 문서를 참조하세요. 추가 설정 지침은 데이터베이스 감사 설정 섹션에 있습니다.
Atlas에서 감사 필터를 생성하고 활성화하기
감사 필터를 생성하여 관심 있는 특정 작업으로만 감사를 제한할 수 있습니다. 작업 감사를 활성화하면 Atlas는 감사 이벤트 작업, 세부 정보 및 결과에 자세히 명시된 모든 감시 대상 작업을 기록합니다.
Atlas가 기록할 이벤트를 제한하려면 이벤트 감사 필터를 지정할 수 있습니다.
다음 문서는 test 데이터베이스에서 발생하는 인증 작업만 감사하도록 감사 필터를 정의합니다. 자세히 알아보려면 감사 필터 구성을 참조하세요.
{ "atype": "authenticate", "param.db": "test" }
감사 필터를 활성화하려면 --enabled 플래그와 함께 atlas auditing update 명령을 실행하고 감사 필터 문서를 작은따옴표로 묶어 string으로 전달합니다.
atlas auditing update --enabled --auditFilter '{"atype": "authenticate", "param.db": "test"}'
사용자 지정 감사 필터를 사용하면 관리형 {atlas-ui+} 감사 필터 빌더를 사용하지 않고 이벤트 감사를 수동으로 세밀하게 제어할 수 있습니다. Atlas는 사용자 지정 필터가 유효한 JSON 구문을 사용하는지 여부만 확인하며 필터의 기능을 검증하거나 테스트하지 않습니다.
감사 필터 문서:
감사 이벤트 메시지에서 하나 이상의 필드와 일치하는 쿼리로 확인해야 합니다.
원하는 감사 메시지를 일치시키기 위해 쿼리 연산자와 동등 조건의 조합을 사용할 수 있습니다.
Atlas에서는 MongoDB 감사를 맞춤 설정하기 위해 JSON 형식의 감사 필터를 지정할 수 있습니다.
사용자 지정 필터를 위한 JSON 설정 파일을 구성하는 것도 유용합니다. 대형 필터를 만들어야 하는 경우 필터 구성을 별도의 파일에 저장하면 필터 관리와 유지 관리가 훨씬 쉬워지기 때문입니다.
다음 Atlas CLI 명령어는 지정된 JSON 설정 파일에 정의된 감사 필터를 활성화합니다.
atlas auditing update --enabled -f filter.json
Atlas 감사에 대한 권장 사항
다음 권장사항은 모든 배포서버 패러다임에 적용됩니다.
클러스터를 프로비저닝할 때 데이터베이스 감사를 설정하는 것이 좋습니다.
데이터베이스 감사는 클러스터 리소스 사용량과 운영 비용을 증가시킵니다.
최적의 성능을 유지하고 비용을 관리하려면 필수 사용자만 감사하고 개발 환경에서 필요하지 않은 감사는 해제하는 것이 좋습니다.
의료 및 금융 서비스와 같은 특정 업계에서는 컴플라이언스를 위해 개발 환경에서 감사를 활성화된 상태로 둘 수 있습니다.
다음 이벤트는 최소한 감사 하는 것이 좋습니다.
로그인 실패
세션 활동
로그온 및 로그오프
승인되지 않은 기능을 수행하려고 시도하는 경우
비밀번호 변경
데이터베이스 사용자 액세스 변경 사항
DDL & 시스템 구성 저장 프로시저
네이티브 감사 수정
백업 또는 복원 작업 수행
DBMS 네이티브 감사 설정 변경
보안 수정
데이터베이스 시작 및 중지 명령 실행
자동화 예시: Atlas 감사
팁
모든 필러에 권장 사항을 시행하다 하는 Terraform 예시는 Github 에서 다음 예시 중 하나를 참조하세요.
다음 예시는 Atlas 자동화 도구를 사용하여 로그를 조회하고 다운로드하며 감사를 구성하는 방법을 보여줍니다.
감사 구성 업데이트
프로젝트의 감사 구성을 업데이트하려면 atlas auditing update 명령을 사용하고 새로운 감사 필터를 지정하세요. 다음 명령은 기존 감사 필터 구성을 프로젝트 내 알려진 사용자 전체의 인증 이벤트를 감사하는 새 필터로 변경합니다.
atlas auditing update --enabled --auditFilter '{"atype": "authenticate"}'
감사 구성 설명
atlas auditing describe 명령을 실행하여 지정한 프로젝트의 감사 구성을 반환합니다.
atlas auditing describe --output json
다음 예시 배포서버 에 대한 감사를 활성화 방법을 보여줍니다. Terraform으로 리소스를 생성하려면 먼저 다음을 수행해야 합니다.
결제 조직 생성 하고 결제 조직에 대한 API 키를 생성 합니다. 터미널에서 다음 명령을 실행 하여 공개 키와 비공개 키를 환경 변수로 저장합니다.
export MONGODB_ATLAS_PUBLIC_KEY="<insert your public key here>" export MONGODB_ATLAS_PRIVATE_KEY="<insert your private key here>"
감사를 활성화하고 감사 필터를 생성하기
감사 필터를 생성하여 문서화된 대부분의 시스템 이벤트 조치 에 대한 수동 감사를 구성할 수 있습니다. 감사 필터 구성에 대해 자세히 학습 감사 필터 구성을 참조하세요.
다음 Terraform 스크립트는 포괄적인 데이터베이스 감사를 포함하여 완전한 MongoDB Atlas 인프라를 설정합니다. 스크립트:
조직 내에 새 프로젝트를 생성하고 미국 동부 지역의 AWS에 배포된 세 개 노드(M10 인스턴스)로 구성된 복제본 세트 클러스터를 프로비저닝합니다.
인증 이벤트, 사용자 관리 작업, 데이터 조작 및 쿼리 작업을 포함한 다양한 데이터베이스 명령을 모니터링하는 JSON 필터를 통해 상세 감사 기능을 활성화합니다.
감사 구성은 특히 관리자 및 외부 데이터베이스 사용자를 대상으로 하며 인증 시도, 역할 수정, 일반적인 데이터베이스 명령(예: find, insert, update, delete 작업 등)과 같은 중요한 작업을 추적합니다.
Add the MongoDB Atlas Provider terraform { required_providers { mongodbatlas = { source = "mongodb/mongodbatlas" version = "1.34.0" } } } Configure the MongoDB Atlas Provider provider "mongodbatlas" { public_key = var.mongodbatlas_public_key private_key = var.mongodbatlas_private_key } Create a Project resource "mongodbatlas_project" "this" { org_id = var.atlas_org_id name = var.atlas_project_name } Create an Atlas Advanced Cluster resource "mongodbatlas_advanced_cluster" "atlas-cluster" { project_id = mongodbatlas_project.atlas-project.id name = "ClusterPortalProd" cluster_type = "REPLICASET" mongo_db_major_version = "8.0" replication_specs { region_configs { electable_specs { instance_size = "M10" node_count = 1 } provider_name = "AWS" priority = 7 region_name = "US_WEST_1" } } Advanced configuration backup_enabled = true pit_enabled = true version_release_system = "LTS" } Create comprehensive auditing configuration to capture all possible audit events resource "mongodbatlas_auditing" "atlas-auditing" { project_id = mongodbatlas_project.atlas-project.id Comprehensive audit filter to capture all possible audit events audit_filter = jsonencode({ "$or" = [ # Capture all authentication events { "atype" = { "$in" = [ "authenticate", "authCheck", "logout" ] } }, # Capture all authorization events { "atype" = "authCheck" }, # Capture all CRUD operations { "atype" = "authCheck", "param.command" = { "$in" = [ # Read operations "find", "getMore", "count", "distinct", "aggregate", "group", "mapReduce", "geoNear", "geoSearch", "parallelCollectionScan", "eval", "getLastError", "getPrevError", "resetError", # Write operations "insert", "update", "delete", "findAndModify", "save", # Index operations "createIndexes", "dropIndexes", "listIndexes", "reIndex", # Collection operations "create", "drop", "listCollections", "collMod", "convertToCapped", "emptycapped", "renameCollection", # Database operations "dropDatabase", "listDatabases", "copydb", "clone", # GridFS operations "filemd5" ] } }, # Capture all DDL (Data Definition Language) operations { "atype" = "authCheck", "param.command" = { "$in" = [ "create", "drop", "createIndexes", "dropIndexes", "collMod", "renameCollection", "dropDatabase", "createCollection", "dropCollection" ] } }, # Capture all user and role management operations { "atype" = "authCheck", "param.command" = { "$in" = [ "createUser", "dropUser", "dropAllUsersFromDatabase", "updateUser", "grantRolesToUser", "revokeRolesFromUser", "createRole", "updateRole", "dropRole", "dropAllRolesFromDatabase", "grantRolesToRole", "revokeRolesFromRole", "grantPrivilegesToRole", "revokePrivilegesFromRole" ] } }, # Capture replica set operations { "atype" = "authCheck", "param.command" = { "$in" = [ "replSetGetStatus", "replSetInitiate", "replSetReconfig", "replSetStepDown", "replSetSyncFrom", "replSetFreeze", "replSetMaintenance", "replSetGetConfig" ] } }, # Capture sharding operations { "atype" = "authCheck", "param.command" = { "$in" = [ "shardCollection", "addShard", "removeShard", "movePrimary", "enableSharding", "split", "moveChunk", "mergeChunks" ] } }, # Capture administrative operations { "atype" = "authCheck", "param.command" = { "$in" = [ "shutdown", "fsync", "getParameter", "setParameter", "serverStatus", "dbStats", "collStats", "currentOp", "killOp", "listCommands", "buildInfo", "hostInfo", "connectionStatus", "getCmdLineOpts", "logRotate", "planCacheClear", "planCacheListFilters", "planCacheSetFilter", "planCacheClearFilters" ] } }, # Capture diagnostic operations { "atype" = "authCheck", "param.command" = { "$in" = [ "explain", "profile", "validate", "dbHash", "ping", "ismaster", "isMaster", "hello" ] } }, # Capture connection and session events { "atype" = { "$in" = [ "createSession", "endSession", "refreshSession" ] } }, # Capture transaction events { "atype" = "authCheck", "param.command" = { "$in" = [ "abortTransaction", "commitTransaction", "startTransaction" ] } }, # Capture change stream events { "atype" = "authCheck", "param.command" = { "$in" = [ "aggregate" ] }, "param.pipeline" = { "$elemMatch" = { "$changeStream" = { "$exists" = true } } } } ] }) Enable comprehensive auditing settings audit_authorization_success = true # Audit both successful and failed operations enabled = true # Enable auditing } Variables variable "mongodbatlas_public_key" { default = "" description = "MongoDB Atlas Public Key" type = string sensitive = true } variable "mongodbatlas_private_key" { default = "" description = "MongoDB Atlas Private Key" type = string sensitive = true } variable "atlas_org_id" { default = "" description = "MongoDB Atlas Organization ID" type = string } variable "atlas_project_name" { description = "MongoDB Atlas Project Name" type = string default = "Atlas Auditing Example" } Outputs output "cluster_connection_string" { description = "Connection string for the Atlas cluster" value = mongodbatlas_advanced_cluster.atlas-cluster.connection_strings[0].standard_srv sensitive = true } output "cluster_id" { description = "Atlas cluster ID" value = mongodbatlas_advanced_cluster.atlas-cluster.cluster_id } output "project_id" { description = "Atlas project ID" value = mongodbatlas_project.atlas-project.id } output "auditing_enabled" { description = "Whether auditing is enabled" value = mongodbatlas_auditing.atlas-auditing.enabled }