> This page location: /docs.md > /docs/management.md > /docs/atlas/operator/current.md > /docs/atlas/operator/current/ak8so-monitoring.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Configure Audit Logs

Atlas Kubernetes Operator doesn't support Atlas Infinite Database clusters in public preview. To learn which features Atlas Infinite Database supports in public preview, see [Atlas Infinite Database Edition](https://www.mongodb.com/docs/atlas/infinite/atlas-infinite-landing/). To learn more about preview features, see [Preview Features](https://www.mongodb.com/docs/preview-features/).

**Note:**

- This feature is not available for `M0` clusters and `Flex` clusters.

You can use Atlas Kubernetes Operator to configure audit logs. To learn more, see [Set Up Database Auditing.](https://www.mongodb.com/docs/atlas/database-auditing.md#std-label-set-up-database-auditing)

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](https://www.mongodb.com/docs/manual/core/auditing/) most of the documented [system event actions](https://www.mongodb.com/docs/manual/reference/audit-message/mongo.md#std-label-audit-action-details-results), with the following limitations:

- When an Atlas user performs an action in the Atlas UI on a cluster, both the audit logs and `mongodb.log` file log the `mms-automation` database user as the user performing the auditable action. However, the [Project Activity Feed](https://www.mongodb.com/docs/atlas/tutorial/activity-feed.md#std-label-view-activity-feed) logs the actual username of the Atlas user responsible for the action.

- The Atlas audit logs don't track user creation or modification events because Atlas performs these operations directly in the `admin` database.

**Important: Performing a Full Database Audit**

Due to these noted limitations, you must use a combination of audit logs, the `mongodb.log`, and the [Project Activity Feed](https://www.mongodb.com/docs/atlas/tutorial/activity-feed.md#std-label-view-activity-feed) to perform a full audit.

The `authCheck` event action logs authorization attempts by users trying to read from and write to databases in the clusters in your project. Atlas audits the following specific commands:

| `authCheck Reads` | `authCheck Writes` |
| --- | --- |
| [aggregate](https://www.mongodb.com/docs/manual/reference/command/aggregate/) | [aggregate](https://www.mongodb.com/docs/manual/reference/command/aggregate/) |
| [mapReduce](https://www.mongodb.com/docs/manual/reference/command/mapReduce/) | [mapReduce](https://www.mongodb.com/docs/manual/reference/command/mapReduce/) |
| [distinct](https://www.mongodb.com/docs/manual/reference/command/distinct/) | [delete](https://www.mongodb.com/docs/manual/reference/command/delete/) |
| [eval](https://www.mongodb.com/docs/manual/reference/command/eval/) | [eval](https://www.mongodb.com/docs/manual/reference/command/eval/) |
| [count](https://www.mongodb.com/docs/manual/reference/command/count/) | [findAndModify](https://www.mongodb.com/docs/manual/reference/command/findAndModify/) |
| [geoNear](https://www.mongodb.com/docs/manual/reference/command/geoNear/) | [insert](https://www.mongodb.com/docs/manual/reference/command/insert/) |
| [geoSearch](https://www.mongodb.com/docs/manual/reference/command/geoSearch/) | [update](https://www.mongodb.com/docs/manual/reference/command/update/) |
| [group](https://www.mongodb.com/docs/manual/reference/command/group/) | [resetError](https://www.mongodb.com/docs/v6.0/reference/command/resetError/) |
| [find](https://www.mongodb.com/docs/manual/reference/command/find/) | |
| [getLastError](https://www.mongodb.com/docs/manual/reference/command/getLastError/) | |
| [getMore](https://www.mongodb.com/docs/manual/reference/command/getMore/) | |
| [getPrevError](https://www.mongodb.com/docs/manual/reference/command/getPrevError/) | |
| [parallelCollectionScan](https://www.mongodb.com/docs/manual/reference/command/parallelCollectionScan/) | |

MongoDB versions 4.2 and later don't support these commands.

Atlas implements the `authCheck` event action as the following four separate actions:

| Event Action | Description |
| --- | --- |
| `authChecksReadFailures` | `authCheck` event action for all failed reads with the [auditAuthorizationSuccess](https://www.mongodb.com/docs/manual/reference/parameters/#param.auditAuthorizationSuccess) parameter set to false. This event action is the default for read-related event actions. |
| `authChecksReadAll` | `authCheck` event action for all reads, both sucesses and failures. This event action is the same as `authChecksReadFailures`, but with the [auditAuthorizationSuccess](https://www.mongodb.com/docs/manual/reference/parameters/#param.auditAuthorizationSuccess) parameter set to true. WARNING: If you enable [auditAuthorizationSuccess](https://www.mongodb.com/docs/manual/reference/parameters/#param.auditAuthorizationSuccess), you might severely impact cluster performance. Enable this option with caution. |
| `authChecksWriteFailures` | `authCheck` event action for all failed writes with the [auditAuthorizationSuccess](https://www.mongodb.com/docs/manual/reference/parameters/#param.auditAuthorizationSuccess) parameter set to false. This event action is the default for write-related event actions. |
| `authChecksWriteAll` | `authCheck` event action for all writes, both successes and failures. This event action is the same as `authChecksWriteFailures`, but with the [auditAuthorizationSuccess](https://www.mongodb.com/docs/manual/reference/parameters/#param.auditAuthorizationSuccess) parameter set to true. WARNING: If you enable [auditAuthorizationSuccess](https://www.mongodb.com/docs/manual/reference/parameters/#param.auditAuthorizationSuccess), you might severely impact cluster performance. Enable this option with caution. |

To learn about how MongoDB writes audit events to disk, see [Audit Guarantee](https://www.mongodb.com/docs/manual/core/auditing/#audit-guarantee) in the MongoDB Manual.

## Required Access

To configure audit logs, you must have [`Project Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Project-Owner) access to the project that you want to update or [`Organization Owner`](https://www.mongodb.com/docs/atlas/reference/user-roles.md#mongodb-authrole-Organization-Owner) access to the organization that contains the project that you want to update.

## Enable Audit Logs

**Note:**

To learn about best practices for auditing the actions of temporary database users, see [Audit Temporary Database Users.](https://www.mongodb.com/docs/atlas/production-notes.md#std-label-audit-temp-db-users)

To enable audit logs, set [spec.auditing.enabled](https://www.mongodb.com/docs/atlas/operator/current/atlasproject-custom-resource.md#std-label-atlasproject-spec-auditing) to `true` in the [`AtlasProject` Custom Resource.](https://www.mongodb.com/docs/atlas/operator/current/atlasproject-custom-resource.md#std-label-atlasproject-custom-resource)

**Example:**

```sh
cat <<EOF | kubectl apply -f -
apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
  name: my-project
spec:
  name: TestAuditing
  connectionSecretRef:
    name: my-atlas-key
  projectIpAccessList:
    - cidrBlock: "0.0.0.0/1"
      comment: "Everyone has access. For test purposes only."
    - cidrBlock: "128.0.0.0/1"
      comment: "Everyone has access. For test purposes only."
  auditing:
    enabled: true
 EOF
```

To retrieve the audit logs in Atlas, see [MongoDB Logs](https://www.mongodb.com/docs/atlas/mongodb-logs.md#std-label-mongodb-logs). To retrieve the audit logs using the API, see [Logs.](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-downloadgroupclusterlog)

## Configure a Custom Auditing Filter

**Note:**

- This feature is not available for `M0` clusters and `Flex` clusters.

Atlas supports specifying a JSON-formatted audit filter for customizing [MongoDB Auditing.](https://www.mongodb.com/docs/manual/core/auditing/)

Custom audit filters lets users forgo the managed Atlas UI [auditing filter builder](https://www.mongodb.com/docs/atlas/database-auditing/) 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.

The audit filter document must resolve to a query that matches one or more fields in the [audit event message](https://www.mongodb.com/docs/manual/reference/audit-message/#audit-message). The filter document can use combinations of [query operators](https://www.mongodb.com/docs/manual/reference/mql/query-predicates/) and equality conditions to match the desired audit messages.

To view example auditing filters, see [Example Auditing Filters](https://www.mongodb.com/docs/atlas/database-auditing.md#std-label-auditing-filter-example). To learn more about configuring MongoDB auditing filters, see [Configure Audit Filter.](https://www.mongodb.com/docs/manual/tutorial/configure-audit-filters/)

**Important:**

Atlas uses a [rolling update](https://www.mongodb.com/docs/atlas/reference/faq/deployment.md#std-label-high-availability) strategy for enabling or updating audit configuration settings across all clusters in the Atlas project. Rolling updates require at least one election per replica set.

To learn more about testing application resilience to replica set elections, see [/tutorial/test-resilience/test-primary-failover](https://www.mongodb.com/docs/atlas/tutorial/test-resilience/test-primary-failover/). To learn more about how Atlas provides high availability, see [Atlas High Availability.](https://www.mongodb.com/docs/atlas/reference/faq/deployment.md#std-label-high-availability)

To configure a custom auditing filter, specify the [spec.auditing.auditFilter](https://www.mongodb.com/docs/atlas/operator/current/atlasproject-custom-resource.md#std-label-atlasproject-spec-auditing) setting in the [`AtlasProject` Custom Resource](https://www.mongodb.com/docs/atlas/operator/current/atlasproject-custom-resource.md#std-label-atlasproject-custom-resource).  To specify a value for this setting, you must set [spec.auditing.enabled](https://www.mongodb.com/docs/atlas/operator/current/atlasproject-custom-resource.md#std-label-atlasproject-spec-auditing) to `true`.

**Example:**

```sh
cat <<EOF | kubectl apply -f -
apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
  name: my-project
spec:
  name: TestAuditing
  connectionSecretRef:
    name: my-atlas-key
  projectIpAccessList:
    - cidrBlock: "0.0.0.0/1"
      comment: "Everyone has access. For test purposes only."
    - cidrBlock: "128.0.0.0/1"
      comment: "Everyone has access. For test purposes only."
  auditing:
    enabled: true
    auditFilter: "{"atype": "authenticate"}"
 EOF
```

To learn more about the configuration parameters available from the API (Application Programming Interface), see the Atlas [Auditing.](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-updategroupauditlog)
