Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ /
Atlas 아키텍처 센터
/ /

Atlas 감사 지침

Atlas 플랫폼 활동을 모니터 하려면 감사를 사용하세요.

M10+ 클러스터에서 사용할 수 있는 데이터베이스 감사를 사용하면 사용자가 여러 명인 배포서버의 시스템 활동을 추적 할 수 있습니다.

Atlas 관리자는 MongoDB 에서 사용자 지정 JSON 감사 필터하다 만들어 시스템 전체에서 감사 대상을 정확하게 제어할 수 있습니다.

이 접근 방식을 사용하면 모니터링해야 하는 작업, 데이터베이스 사용자 및 Atlas 역할을 정확하게 지정할 수 있으므로 Atlas UI 의 표준 필터하다 빌더에 비해 감사 프로세스 더 세밀하게 제어할 수 있습니다.

수동 감사 구성을 사용하면 Atlas 에서 문서화된 거의 모든 시스템 이벤트 조치를 모니터 할 수 있습니다.

포괄적인 데이터베이스 감사 기능은 다음에 대한 자세한 추적을 제공합니다.

  • DDL(데이터 정의 언어) 작업

  • DML(데이터 조작 언어) 작업

  • DCL(데이터 제어 언어) 작업.

이를 통해 데이터베이스 스키마 변경, 데이터 수정 및 권한 조정에 대한 완전한 가시성을 제공합니다.

전체 이벤트 목록과 실제 구성 예시를 포함한 구현 지침 MongoDB 감사감사 필터 예시 문서를 참조하세요. 추가 설정 지침은 데이터베이스 감사 설정 섹션에서 확인할 수 있습니다.

감사 필터를 만들어 특정 고려 작업으로만 감사를 제한할 수 있습니다. 작업 감사를 활성화 Atlas 감사 이벤트 작업, 세부 정보 및 결과에 자세히 설명된 대로 감사 가능한 모든 작업을 기록합니다.

Atlas 기록 해야 하는 이벤트를 제한하려면 이벤트 감사 필터를 지정하면 됩니다.

다음 문서 test 데이터베이스 에 대해 발생하는 인증 작업으로만 감사를 제한하는 감사 필터하다 정의합니다.자세한 학습 은 감사 필터 구성을 참조하세요.

{ "atype": "authenticate", "param.db": "test" }

감사 필터하다 활성화 하려면 플래그와 함께 Atlas 감사 업데이트 명령을 실행 --enabled 하고 감사 필터하다 문서 작은따옴표로 묶어 문서 문자열로 전달하도록 지정합니다.

atlas auditing update --enabled --auditFilter '{"atype": "authenticate", "param.db": "test"}'

사용자 지정 감사 필터를 사용하면 managed {atlas-ui+} 감사 필터하다 빌더를 사용하지 않고 이벤트 감사를 수동으로 세분화하여 제어할 수 있습니다. Atlas 사용자 지정 필터하다 유효한 JSON 구문을 사용하는지만 확인하며, 필터의 기능을 검증하거나 테스트하지 않습니다.

감사 필터하다 문서:

  • 감사 이벤트 메시지에 있는 하나 이상의 필드와 일치하는 쿼리 로 해석되어야 합니다.

  • 쿼리 연산자와 동등 조건의 조합을 사용하여 원하는 감사 메시지를 일치시킬 수 있습니다.

Atlas MongoDB 감사를 사용자 지정하기 위해 JSON 형식의 감사 필터하다 지정을 지원합니다.

사용자 지정 필터하다 에 대한 JSON 구성 파일 구성하는 것도 유용합니다. 큰 필터하다 생성해야 하는 경우 필터 구성을 별도의 파일 에 저장 필터하다 를 관리 하고 유지 관리하기가 더 쉽습니다.

다음 Atlas CLI 명령은 지정된 JSON 구성 파일 에 정의된 감사 필터하다 활성화합니다.

atlas auditing update --enabled -f filter.json

다음 권장 사항은 모든 배포서버 패러다임에 적용 .

클러스터를 프로비저닝할 때 데이터베이스 감사를 설정하다 것이 좋습니다.

데이터베이스 감사는 클러스터 리소스 사용량과 운영 비용을 증가시킵니다.

  • 최적의 성능을 유지하고 비용을 제어하려면 필수 사용자만 감사하고 필요하지 않은 개발 환경에서는 감사를 해제하는 것이 좋습니다.

  • 의료 및 금융 서비스와 같은 특정 산업에서는 컴플라이언스 위해 개발 환경에서 감사를 계속 활성화하도록 선택할 수 있습니다.

다음 이벤트는 최소한 감사 하는 것이 좋습니다.

  • 로그인 실패

  • 세션 활동

  • 로그온 및 로그오프

  • 승인되지 않은 기능을 수행하려고 시도하는 경우

  • 비밀번호 변경

  • 데이터베이스 사용자 액세스 변경 사항

  • DDL & 시스템 구성 저장 프로시저

  • 네이티브 감사 수정

  • 백업 또는 복원 작업 수행

  • DBMS 네이티브 감사 설정 변경

  • 보안 수정

  • 데이터베이스 시작 및 중지 명령 실행

모든 필러에 권장 사항을 시행하다 하는 Terraform 예시는 Github 에서 다음 예시 중 하나를 참조하세요.

다음 예시는 Atlas 자동화 도구를 사용하여 로그를 조회하고 다운로드하며 감사를 구성하는 방법을 보여줍니다.

프로젝트의 감사 구성을 업데이트 하려면 atlas auditing 업데이트 명령을 사용하고 새 감사 필터하다 지정합니다. 다음 명령은 기존 감사 필터하다 구성을 프로젝트 의 알려진 사용자에 대한 모든 인증 이벤트를 감사하는 새 필터하다 로 바꿉니다.

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 설치

감사 필터를 생성하여 문서화된 대부분의 시스템 이벤트 조치 에 대한 수동 감사를 구성할 수 있습니다. 감사 필터 구성에 대해 자세히 학습 감사 필터 구성을 참조하세요.

다음 Terraform 스크립트 포괄적인 데이터베이스 감사를 통해 전체 MongoDB Atlas 인프라를 설정합니다. 스크립트:

  • 조직 내에 새 프로젝트 생성하고 미국 동부 리전 의 AWS에 배포된 3노드 복제본 세트 클러스터 (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
}

돌아가기

감사 및 로깅

이 페이지의 내용