AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

データベース監査を設定する

注意

このページは、Atlas InfiniteとAtlas Coreの両方に適用されます。

注意

この機能は、次の配置では使用できません。

  • 無料クラスター

  • Flex クラスター

詳しくは、「 制限 」を参照してください。

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 つの個別のアクションとして実装します。

イベント アクション
説明

authChecksReadFailures

authCheck event action for all failed reads with the auditAuthorizationSuccess parameter set to false. This event action is the default for read-related event actions.

authChecksReadAll

authCheck 成功と失敗の両方を含むすべての読み取りに対するイベント アクション。このイベント アクションは authChecksReadFailures と同じですが、auditAuthorizationSuccess パラメーターが true に設定されています。

警告: auditAuthorizationSuccessを有効にすると、クラスターのパフォーマンスに重大な影響を与える可能性があります。 このオプションを有効にする場合は注意が必要です。

authChecksWriteFailures

authCheck event action for all failed writes with the auditAuthorizationSuccess parameter set to false. This event action is the default for write-related event actions.

authChecksWriteAll

authCheck 成功と失敗の両方を含むすべての書き込み (write) に対するイベント アクション。このイベント アクションは authChecksWriteFailures と同じですが、auditAuthorizationSuccess パラメーターが true に設定されています。

警告: 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 リソース ポリシー を使用します。クラスターを作成または変更する前に、リソースポリシー を使用して、データベース監査を要求できます。

注意

一時データベース ユーザーのアクションを監査するためのベスト プラクティスについては、「一時データベース ユーザーの監査」を参照してください。

データベース監査を設定するには、次の手順に従います。

1
  1. まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。

  2. まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。

  3. サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。

  4. サイドバーで、Advanced をクリックします。

    詳細ページが表示されます。

2
3

By default, Atlas logs the failed authentication attempts of both known and unknown users in the audit log of the primary node.

4

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.

5

注意

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.

6

To retrieve the audit logs in Atlas, see MongoDB Logs. To retrieve the audit logs using the API, see Logs.

注意

この機能は、次の配置では使用できません。

  • 無料クラスター

  • Flex クラスター

詳しくは、「 制限 」を参照してください。

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 の高可用性」を参照してください。

1
  1. まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。

  2. まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。

  3. サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。

  4. サイドバーで、Advanced をクリックします。

    詳細ページが表示されます。

2
3
4
5

警告

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.

6

フィルターはいつでも編集できます。

1
  1. まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。

  2. まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。

  3. サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。

  4. サイドバーで、Advanced をクリックします。

    詳細ページが表示されます。

2
  1. Database Auditing Configure Your Auditing Filter の下にある Use Custom JSON Filter をクリックします。

  2. 必要な変更を加えます。

  3. [Save] をクリックします。

1
  1. まだ表示されていない場合は、プロジェクトを含む組織をナビゲーション バーの Organizations メニューで選択します。

  2. まだ表示されていない場合は、ナビゲーション バーの Projects メニューからプロジェクトを選択します。

  3. サイドバーで、 Security見出しの下のDatabase & Network Accessをクリックします。

  4. サイドバーで、Advanced をクリックします。

    詳細ページが表示されます。

2

カスタム監査フィルターは Database Auditing の下に表示されます。

独自のフィルターを作成する際のガイドとして、次の監査フィルターの例を使用してください。

重要

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 アクションが必要です。

{
"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 latencyStats histograms.

  • その他のパフォーマンス メトリクス: モニタリング ダッシュボードのデータベースとクラスターの統計を検索します。

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 auditing update [options]

コマンド構文とパラメータの詳細については、Atlas CLI ドキュメントの atlas 監査する 更新 を参照してください。

Atlas CLI で指定したプロジェクトの監査構成を取得するには、次のコマンドを実行します。

atlas auditing describe [options]

コマンド構文とパラメーターについて詳しくは、Atlas CLI のドキュメントの Atlas auditing describe を参照してください。