> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/integrations/siem-integrations/amazon-s3-audit-setup.md).

# Amazon S3 (audit logs) setup

Write P0 audit logs as batched files to an Amazon S3 bucket in your AWS account.

{% hint style="info" %}
The Amazon S3 (audit logs) integration is in beta. Functionality and configuration may change.
{% endhint %}

P0 writes the audit log events from your P0 tenant to an Amazon S3 bucket in your AWS account, as gzipped files of one JSON event per line. Tools that read log files from S3, such as Splunk, Elastic, Datadog, Sumo Logic, and Amazon Athena, can ingest the files directly.

## Prerequisites

* Existing P0 account at [p0.app](https://p0.app/)
* P0's [AWS](https://docs.p0.dev/integrations/resource-integrations/aws.md) integration installed for the AWS account that owns the bucket
* An S3 bucket encrypted with Amazon S3 managed keys (SSE-S3) or the AWS managed KMS key (`aws/s3`)
* Permission to create IAM roles in that AWS account

## Set up the Amazon S3 (audit logs) integration

{% hint style="info" %}
This setup takes about 10 minutes.
{% endhint %}

1. **Note your bucket's name and region.** In the AWS console, open **Amazon S3** and find your bucket. The **AWS Region** column shows its region, for example `us-west-2`.
2. **Add the bucket in P0.** Log in to [p0.app](https://p0.app) and select **Integrations**. Under **Security Information & Event Managers**, select **Amazon S3 (audit logs)**, then the **Bucket name** component, and add a bucket.
3. **Enter the bucket details** and click **Next**. See [#configure-amazon-s3-audit-logs](#configure-amazon-s3-audit-logs "mention") for the fields.
4. **Create P0's role.** P0 shows the commands that create the `P0RoleIamS3Writer` role in your account. The role can only add new files to your bucket. Run the shell commands in [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html) or a terminal signed in to that account, or apply the Terraform. Then click **Next**. P0 checks that the role exists and that its policies match.
5. **Click Finish.** P0 writes one test file to `p0-install-check/<timestamp>.json` in your bucket to confirm it can deliver events. The test file looks like this:

   ```json
   {"type":"test","action":"p0.integration.test","timestamp":"2026-10-26T19:09:08.670Z","source":"p0","tenant":"your-org","id":"p0-test-1793041748670"}
   ```

P0 writes audit events from the moment you click **Finish**. Events from before the integration was installed are not written. P0 supports one Amazon S3 bucket per P0 organization.

## Configure Amazon S3 (audit logs)

### Bucket name

The name of the bucket P0 writes audit files to, for example `acme-p0-audit-logs`. Enter the name only, not an ARN or `s3://` URL.

### AWS account ID

The AWS account that owns the bucket. The list shows the accounts where P0's AWS integration is installed.

### Region

The AWS region the bucket is in, for example `us-west-2`.

### AWS partition

Leave this as **Commercial (aws)** unless the account is in AWS GovCloud (US).

## File format

P0 writes a new file about every 15 minutes, when there are new events. Each file holds up to 5,000 events, so a busy period can produce several files at once. P0 never overwrites a file.

Files use this key layout, with dates in UTC:

```
p0-audit-events/year=<YYYY>/month=<MM>/day=<DD>/<timestamp>-<suffix>.json.gz
```

The `year=`, `month=`, and `day=` folders let Amazon Athena discover partitions without extra setup.

Each file is gzipped, with one audit log event per line as single-line JSON, in the format described in [Audit log format](https://docs.p0.dev/integrations/siem-integrations/audit-log-format.md). P0 adds three fields to every event:

| Field    | Description                                                                                                                   |
| -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `source` | Always `p0`                                                                                                                   |
| `tenant` | Your P0 organization identifier                                                                                               |
| `id`     | A unique identifier for the event. Use it to drop duplicates, because an event can occasionally appear in more than one file. |

The `timestamp` field is an ISO 8601 string.

## Troubleshooting

### P0 stopped writing files

If P0 can't write to your bucket because the bucket was deleted, P0's role was removed or changed, or the region in P0 is wrong, P0 stops writing to the bucket.

To resume, fix the cause, then install the Amazon S3 (audit logs) integration again from the **Bucket name** component. P0 checks the role, writes a test file, and then writes the events from the period it was stopped before continuing with new events.

### A file appeared in `p0-install-check/`

P0 writes this test file when you install the integration. It is not an audit event, and you can delete it.

{% hint style="success" %}
Congratulations! You are now set up with the Amazon S3 (audit logs) integration.
{% endhint %}
