注意
このページは、Atlas InfiniteとAtlas Coreの両方に適用されます。
Database auditing lets administrators track system activity for deployments with multiple users. Atlas administrators can select the actions, database users, Atlas roles, and LDAP groups that they want to audit. Atlas supports auditing most of the documented system event actions.
authCheck イベント アクションは、プロジェクト内のクラスター内のデータベースに対して読み取りや書込みを試行するユーザーによる承認試行を記録します。Atlas では、次の特定のコマンドが監査されます。
authCheck Reads | authCheck Writes |
|---|---|
mapReduce (deprecated in MongoDB 5.0) | mapReduce (deprecated in MongoDB 5.0) |
geoNear (removed in MongoDB 4.2) | |
geoSearch (removed in MongoDB 5.0) | |
group (removed in MongoDB 4.2) | resetError (removed in MongoDB 5.0) |
getLastError (removed in MongoDB 5.1) | |
getPrevError (removed in MongoDB 4.2) |
Atlas は、authCheck イベント アクションを次の 4 つの個別のアクションとして実装します。
イベント アクション | 説明 |
|---|---|
|
|
|
警告: auditAuthorizationSuccessを有効にすると、クラスターのパフォーマンスに重大な影響を与える可能性があります。 このオプションを有効にする場合は注意が必要です。 |
|
|
|
警告: auditAuthorizationSuccessを有効にすると、クラスターのパフォーマンスに重大な影響を与える可能性があります。 このオプションを有効にする場合は注意が必要です。 |
To learn about how MongoDB writes audit events to disk, see Audit Guarantee in the MongoDB Manual.
必要なアクセス権
監査ログを構成するには、更新するプロジェクトへの Project Owner アクセス権、または更新するプロジェクトを含む組織への Organization Owner アクセス権が必要です。
To learn about recommendations for auditing and logging, including the events that we recommend auditing, see Guidance for Atlas Auditing and Logging in the Atlas Architecture Center.
注意
The MongoDB Atlas Shared Responsibility Model defines the complementary duties of MongoDB and its customers in maintaining a secure and resilient data environment. Under this framework, MongoDB manages the security and operational integrity of the underlying platform, while customers are responsible for the configuration, management, and data policies of their specific deployments. For a detailed breakdown of ownership across security and operational excellence, see Shared Responsibility Model.
プロジェクト内のすべてのクラスターでデータベース監査が有効になっているように強制するには、 Atlas リソース ポリシー を使用します。クラスターを作成または変更する前に、リソースポリシー を使用して、データベース監査を要求できます。
手順
注意
一時データベース ユーザーのアクションを監査するためのベスト プラクティスについては、「一時データベース ユーザーの監査」を参照してください。
データベース監査を設定するには、次の手順に従います。
Atlas で、プロジェクトの Advanced ページに移動します。
まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。
まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。
サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。
サイドバーで、Advanced をクリックします。
詳細ページが表示されます。
認証の失敗を監査することを確認します。
By default, Atlas logs the failed authentication attempts of both known and unknown users in the audit log of the primary node.
Select users and roles でアクションを監査するデータベース ユーザー、Atlas ロール、および LDAP グループを選択します。
Alternatively, click Use Custom JSON Filter to manually enter an audit filter as a JSON string. For more information on configuring custom audit filters in Atlas, see Configure a Custom Auditing Filter.
Select actions to audit で監査対象のイベント アクションを選択します。
注意
authenticate アクションの選択を解除すると、Atlas は認証失敗を監査できなくなります。
注意
When selecting the authorization success granularity of auditing for the authCheck event action, Atlas does not support different selections for reads and writes. For example, you may not select Successes and Failures for authCheck Reads and Failures for authCheck Writes. If you select both authCheck Reads and authCheck Writes, Atlas automatically applies your selected granularity to both.
To retrieve the audit logs in Atlas, see MongoDB Logs. To retrieve the audit logs using the API, see Logs.
カスタム監査フィルターを構成する
Atlas は、MongoDB Auditing をカスタマイズする JSON 形式の監査フィルターの指定をサポートしています。
Custom audit filters let users forgo the managed Atlas UI auditing filter builder in favor of hand-tailored granular control of event auditing. Atlas checks only that the custom filter uses valid JSON syntax, and doesn't validate or test the filter's functionality.
監査フィルター ドキュメントは、監査イベント メッセージ内の 1 つ以上のフィールドに一致するクエリに解決される必要があります。フィルター ドキュメントでは、必要な監査メッセージを一致させるために、クエリ演算子と等価条件の組み合わせを使用できます。
To view example auditing filters, see Example Auditing Filters. To learn more about configuring MongoDB auditing filters, see Configure Audit Filter.
重要
Atlas は、Atlas プロジェクト内のすべてのクラスターにわたって監査構成設定を有効化または更新するために、ローリング アップデート 戦略を使用します。ローリング アップデートでは、レプリカセットごとに少なくとも 1 回の選挙が必要です。
レプリカセットの選挙に対するアプリケーションの回復力をテストする方法の詳細については、「プライマリ フェイルオーバーのテスト」を参照してください。Atlas が高可用性を実現する仕組みについて詳しくは、「Atlas の高可用性」を参照してください。
手順
Atlas で、プロジェクトの Advanced ページに移動します。
まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。
まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。
サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。
サイドバーで、Advanced をクリックします。
詳細ページが表示されます。
Audit authorization successes を切り替えます。
警告
Audit authorization successes を有効にすると、クラスターのパフォーマンスに重大な影響を与える可能性があります。このオプションを有効にする場合は注意が必要です。
For audit filters specifying the authCheck action type, the auditing system logs only authorization failures for any specified param.command by default. Enabling Audit authorization successes directs the auditing system to also log authorization successes. If you don't enable auditAuthorizationSuccess, your audit system can't log successful CRUD operations specified in the action type. To learn more, see auditAuthorizationSuccess.
カスタムの監査フィルターを編集する
フィルターはいつでも編集できます。
Atlas で、プロジェクトの Advanced ページに移動します。
まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。
まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。
サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。
サイドバーで、Advanced をクリックします。
詳細ページが表示されます。
カスタム監査フィルターを表示する
Atlas で、プロジェクトの Advanced ページに移動します。
まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。
まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。
サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。
サイドバーで、Advanced をクリックします。
詳細ページが表示されます。
監査フィルターの例
独自のフィルターを作成する際のガイドとして、次の監査フィルターの例を使用してください。
重要
These examples are not intended for use in production environments, nor are they a replacement for familiarity with the MongoDB Auditing Documentation.
既知のユーザーのすべての認証イベントを監査する
{ "atype": "authenticate" }
既知のユーザーのすべての認証イベントと未知のユーザーの認証失敗を監査する
{ "$or": [ { "users": [] }, { "atype": "authenticate" } ] }
注意
既知および未知のユーザーからの認証失敗をログに記録するには、authenticate アクションが必要です。
「myClusterAdministrator」ユーザーの認証イベントを監査する
{ "atype": "authenticate", "param": { "user": "myClusterAdministrator", "db": "admin", "mechanism": "SCRAM-SHA-256" } }
選択したコマンドを実行する不正な試みを監査する
{ "atype": "authCheck", "param.command": { "$in": [ "insert", "update", "delete" ] } }
ユーザーの作成と削除 イベントを監査する
{ "atype": { "$in": [ "createUser", "dropUser", "directAuthMutation" ] } }
注意
directAuthMutationアクションは、 admin.system.users コレクションと admin.system.roles コレクションへの直接変更を追跡します。これには、Atlas が adminデータベースで直接実行する SCRAM ユーザーの作成と変更操作が含まれます。
監査するログのモニタリングエージェント クエリ
データベース監査を有効にすると、監査ログに mms-monitoring-agent ユーザーからのクエリが表示される場合があります。これらのクエリは、Atlas がモニタリング機能のメトリクスとパフォーマンス データを収集するために使用する内部操作です。
The mms-monitoring-agent user has the clusterMonitor and directShardOperations roles and performs queries on behalf of the following Atlas monitoring features:
クエリインサイト: クエリパフォーマンスの統計と形状を収集し、低速クエリの特定に役立ちます。
Namespace Insights: Gathers collection-level latency statistics using $collStats aggregation pipelines with
latencyStatshistograms.その他のパフォーマンス メトリクス: モニタリング ダッシュボードのデータベースとクラスターの統計を検索します。
監査するログのエントリ例
The following example shows an audit log entry for a Namespace Insights query. This query uses the $collStats stage to collect latency statistics for a collection:
{ "atype": "authCheck", "ts": { "$date": "2025-11-20T13:44:20.201+00:00" }, "users": [ { "user": "mms-monitoring-agent", "db": "admin" } ], "roles": [ { "role": "clusterMonitor", "db": "admin" }, { "role": "directShardOperations", "db": "admin" } ], "param": { "command": "aggregate", "ns": "test_db.people_1234", "args": { "aggregate": "people_1234", "pipeline": [ { "$collStats": { "latencyStats": { "histograms": true } } } ], "$readPreference": { "mode": "nearest" } } }, "result": 0 }
These queries are expected behavior and don't require action. If you want to exclude monitoring agent queries from your audit logs, you can create a custom audit filter. To learn more, see Configure a Custom Auditing Filter.
Atlas CLI によるデータベースの監査を管理する
Atlas CLI を使用して、プロジェクトのデータベース監査構成を管理できます。
監査構成の更新
Atlas CLI で指定したプロジェクトの監査設定を更新するには、次のコマンドを実行します。
atlas auditing update [options]
コマンド構文とパラメータの詳細については、Atlas CLI ドキュメントの atlas 監査する 更新 を参照してください。
監査構成の表示
Atlas CLI で指定したプロジェクトの監査構成を取得するには、次のコマンドを実行します。
atlas auditing describe [options]
コマンド構文とパラメーターについて詳しくは、Atlas CLI のドキュメントの Atlas auditing describe を参照してください。