# S3

The `s3` driver configures [session recordings](https://almaforge.com/storage.md#session-recordings) and [audit events](https://almaforge.com/storage.md#audit-events) on Amazon S3 or any S3-compatible object store (such as MinIO, SeaweedFS, Ceph RGW, Garage, Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, or Hetzner Object Storage).

S3 provides durable, scalable storage for high-volume append and playback data without running an external database. It cannot be used for [cluster state](https://almaforge.com/storage.md#cluster-state), which requires a transactional store such as [SQLite](https://almaforge.com/storage/sqlite.md), [PostgreSQL](https://almaforge.com/storage/postgresql.md), [DynamoDB](https://almaforge.com/storage/dynamodb.md), [etcd](https://almaforge.com/storage/etcd.md), or [Firestore](https://almaforge.com/storage/firestore.md).

| Storage concern                         | Supported | Purpose                                                                                      |
| --------------------------------------- | --------- | -------------------------------------------------------------------------------------------- |
| Cluster state (`name: state`)           | no        | Requires transactional compare-and-swap (SQLite, PostgreSQL, DynamoDB, etcd, Firestore)      |
| Audit events (`name: audit-*`)          | yes       | Gzipped JSON Lines (`.jsonl.gz`) audit event logs                                            |
| Session recordings (`name: recordings`) | yes       | Completed session recordings (`.pb`) and their gzipped JSON Lines search index (`.jsonl.gz`) |

You can use S3 for session recordings, audit events, or both. Each concern can point to a different bucket or use distinct path prefixes within a shared bucket.

## TL;DR[​](#tldr "Direct link to TL;DR")

1. Create your bucket(s), enable bucket versioning, and grant the Auth host read/write/version permissions.
2. Place `StorageConfig` manifests with `spec.s3` for `recordings` and/or `audit-*` in `/etc/almaforge/almad.d`.
3. Restart `almad` and verify session replay and audit search.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

Before you start, make sure you have:

* One or more pre-created S3 buckets. AlmaForge reads and writes objects, but never creates, modifies, or deletes buckets.
* Bucket versioning enabled on each bucket (see [Integrity and versioning](#integrity-and-versioning)).
* An IAM role attached to the Auth host (for AWS) or API credentials (`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` in `/etc/almaforge/almad.env`) for S3-compatible stores.
* A cluster state backend already configured ([SQLite](https://almaforge.com/storage/sqlite.md), [PostgreSQL](https://almaforge.com/storage/postgresql.md), [DynamoDB](https://almaforge.com/storage/dynamodb.md), [etcd](https://almaforge.com/storage/etcd.md), or [Firestore](https://almaforge.com/storage/firestore.md)).

## Configuration[​](#configuration "Direct link to Configuration")

This fast path configures AWS S3 using declarative manifests in `/etc/almaforge/almad.d`. For non-AWS stores, custom PKI, KMS keys, URI configuration, or internal storage layout, see [Advanced](#advanced).

### Step 1. Prepare the bucket and grant permissions[​](#step-1-prepare-the-bucket-and-grant-permissions "Direct link to Step 1. Prepare the bucket and grant permissions")

Create your bucket(s) in AWS. Keep `recordings` and `audit-*` in separate buckets or under separate path prefixes (such as `records/` and `events/`).

The `recordings` instance uses two prefixes under its `path`: `records/` and `records-index/`. Give the Auth host object permissions on both.

Attach an IAM role to the Auth host with the following permissions on every bucket and prefix used:

JSON

```json
{

  "Version": "2012-10-17",

  "Statement": [

    {

      "Effect": "Allow",

      "Action": [

        "s3:ListBucket",

        "s3:ListBucketVersions",

        "s3:ListBucketMultipartUploads"

      ],

      "Resource": "arn:aws:s3:::<bucket>"

    },

    {

      "Effect": "Allow",

      "Action": [

        "s3:PutObject",

        "s3:GetObject",

        "s3:GetObjectVersion",

        "s3:AbortMultipartUpload"

      ],

      "Resource": [

        "arn:aws:s3:::<bucket>/<path>/records/*",

        "arn:aws:s3:::<bucket>/<path>/records-index/*"

      ]

    }

  ]

}
```

Key rules:

* Bucket actions apply to `arn:aws:s3:::<bucket>`. Object actions apply to `arn:aws:s3:::<bucket>/<path>/records/*` and `arn:aws:s3:::<bucket>/<path>/records-index/*` for `recordings` (or `records/*` and `records-index/*` when `path` is unset), and `arn:aws:s3:::<bucket>/<path>/events/*` (or `events/*`) for `audit-*`.
* `s3:ListBucketVersions` and `s3:GetObjectVersion` are required for version-pinned reads.
* Do not grant `s3:DeleteObject` or `s3:DeleteObjectVersion`. AlmaForge never deletes objects. Retention is managed via bucket lifecycle rules.

### Step 2. Configure session recordings[​](#step-2-configure-session-recordings "Direct link to Step 2. Configure session recordings")

To store recordings in S3, place a `StorageConfig` manifest with `metadata.name: recordings` in `/etc/almaforge/almad.d` on every Auth host (see [Bootstrap-only](https://almaforge.com/storage.md#bootstrap-only)). There is exactly one `recordings` instance per cluster.

[`recordings.yaml`](https://almaforge.com/examples/storage/s3/recordings.yaml):

examples/storage/s3/recordings.yaml

```yaml
# S3 destination for session recordings.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: recordings

spec:

  s3:

    bucket: almaforge-recordings

    region: us-east-1

    path: records
```

| Field       | Required | Default         | Description                                                           |
| ----------- | -------- | --------------- | --------------------------------------------------------------------- |
| `bucket`    | yes      | none            | Target S3 bucket name.                                                |
| `region`    | no       | AWS SDK default | AWS region (falls back to `AWS_REGION` or `AWS_DEFAULT_REGION`).      |
| `path`      | no       | bucket root     | Path prefix inside the bucket (for example, `records`).               |
| `endpoint`  | no       | AWS default     | Custom endpoint for S3-compatible stores (see [Advanced](#advanced)). |
| `pathStyle` | no       | `auto`          | URL addressing format (`auto`, `path`, or `virtual`).                 |
| `caCert`    | no       | unset           | Path to PEM bundle for custom CA verification.                        |
| `sseKmsKey` | no       | unset           | AWS KMS key ID or ARN for server-side encryption.                     |
| `acl`       | no       | unset           | Canned ACL applied to uploads (such as `bucket-owner-full-control`).  |
| `insecure`  | no       | `false`         | Disables TLS (plain HTTP). Use only in local development.             |

### Step 3. Configure audit events[​](#step-3-write-any-audit-events-resources "Direct link to Step 3. Configure audit events")

Audit events stream directly to S3 as gzipped NDJSON / JSON Lines batches (`.jsonl.gz`). Place a `StorageConfig` manifest with `metadata.name: audit-primary` in `/etc/almaforge/almad.d`:

[`audit.yaml`](https://almaforge.com/examples/storage/s3/audit.yaml):

examples/storage/s3/audit.yaml

```yaml
# S3 destination for audit events. Use a bucket or a prefix of its own,

# separate from session recordings.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: audit-primary

spec:

  s3:

    bucket: almaforge-audit

    region: us-east-1

    path: events
```

Searching an object store scans event files in the chosen time window. Keep search queries bounded:

******Terminal

```bash
alma audit --last=1h
```

### Step 4. Restart and verify[​](#step-4-restart-and-verify "Direct link to Step 4. Restart and verify")

Restart the Auth Service to apply the new storage configuration:

******Terminal

```bash
sudo systemctl restart almad
```

Verify that both storage resources loaded successfully:

******Terminal

```bash
alma get storageconfig/recordings -o yaml
alma get storageconfig/audit-primary -o yaml
```

To verify end-to-end functionality:

1. **Test session recordings**: Start an SSH or database session, run a command, and exit. Open the Web UI or run `alma recording ls` to confirm the recording uploaded and replays.

2. **Test audit logging**: Run `alma audit --last=15m` to confirm login and session events appear.

3. **Inspect service logs**: Check `journalctl` for any S3 credential or permission errors:

   ******Terminal

   ```bash
   sudo journalctl -u almad -n 50 --no-pager
   ```

## Advanced[​](#advanced "Direct link to Advanced")

### S3-compatible endpoints and addressing (pathStyle)[​](#s3-compatible-endpoints-and-addressing-pathstyle "Direct link to S3-compatible endpoints and addressing (pathStyle)")

To use non-AWS stores (such as MinIO, SeaweedFS, Ceph RGW, Garage, Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, or Hetzner Object Storage), set `endpoint` and `region`, and supply credentials in `/etc/almaforge/almad.env`:

/etc/almaforge/almad.env

```env
AWS_ACCESS_KEY_ID=your-access-key-id

AWS_SECRET_ACCESS_KEY=your-secret-access-key
```

**How pathStyle works**

The `pathStyle` field controls how AlmaForge constructs request URLs:

| Value            | URL format                                                      | Typical providers                                                                                     |
| ---------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `auto` (default) | Path-style when `endpoint` is set, and virtual-hosted otherwise | Standard AWS S3 (virtual-hosted) or local MinIO/SeaweedFS (path-style)                                |
| `path`           | `https://<endpoint>/<bucket>/<key>`                             | Self-hosted stores: MinIO, SeaweedFS, Ceph RGW, Garage                                                |
| `virtual`        | `https://<bucket>.<endpoint>/<key>`                             | Cloud stores with custom endpoints: Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, Hetzner |

**Path-style stores (MinIO, SeaweedFS)**

Self-hosted object stores expect the bucket name in the URL path. Setting `endpoint` automatically uses path-style addressing by default:

[`recordings-compatible.yaml`](https://almaforge.com/examples/storage/s3/recordings-compatible.yaml):

examples/storage/s3/recordings-compatible.yaml

```yaml
# S3-compatible destination for session recordings.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: recordings

spec:

  s3:

    bucket: almaforge-recordings

    region: us-east-1

    endpoint: minio.internal.example.com

    path: records
```

**Virtual-hosted stores (Backblaze B2, Cloudflare R2, Spaces, Wasabi, Hetzner)**

Cloud providers that serve virtual-hosted URLs behind custom endpoints reject path-style addressing with 400 Bad Request, 404 Not Found, or redirects. Set `pathStyle: virtual`:

[`recordings-virtual-hosted.yaml`](https://almaforge.com/examples/storage/s3/recordings-virtual-hosted.yaml):

examples/storage/s3/recordings-virtual-hosted.yaml

```yaml
# Session recordings on a store that serves virtual-hosted URLs behind a

# custom endpoint, such as Cloudflare R2, DigitalOcean Spaces, Wasabi or

# Hetzner Object Storage.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: recordings

spec:

  s3:

    bucket: almaforge-recordings

    region: auto

    endpoint: https://account.r2.cloudflarestorage.com

    path: records

    # Setting endpoint otherwise selects path-style addressing, which these

    # stores reject. Accepts auto, path or virtual.

    pathStyle: virtual
```

### Custom internal PKI[​](#custom-internal-pki "Direct link to Custom internal PKI")

When your object store uses a TLS certificate issued by an internal certificate authority, set `caCert` to the authority's PEM file:

[`recordings-private-pki.yaml`](https://almaforge.com/examples/storage/s3/recordings-private-pki.yaml):

examples/storage/s3/recordings-private-pki.yaml

```yaml
# Session recordings on a self-hosted S3-compatible store that presents a

# certificate from an internal certificate authority.

#

# Install the authority on the Auth host as root:root 0600 before starting

# almad, or the service fails to start.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: recordings

spec:

  s3:

    bucket: almaforge-recordings

    region: us-east-1

    endpoint: https://seaweedfs.internal.example.com:8333

    path: records

    # Verifies the endpoint against this authority instead of the system

    # roots. Cannot be combined with insecure, which turns TLS off.

    caCert: /etc/almaforge/store-ca.pem
```

The file must be readable by root (`root:root 0600`). An unreadable or invalid certificate stops the Auth Service rather than falling back to system roots.

### AWS KMS encryption[​](#aws-kms-encryption "Direct link to AWS KMS encryption")

To encrypt uploads with an AWS KMS key, specify `sseKmsKey`:

[`recordings-kms.yaml`](https://almaforge.com/examples/storage/s3/recordings-kms.yaml):

examples/storage/s3/recordings-kms.yaml

```yaml
# S3 recording destination encrypted with an AWS KMS key.

apiVersion: almaforge.com/v1

kind: StorageConfig

metadata:

  name: recordings

spec:

  s3:

    bucket: almaforge-recordings

    region: us-east-1

    sseKmsKey: arn:aws:kms:us-east-1:123456789012:key/abcd1234-...
```

Ensure the Auth host role has `kms:Encrypt`, `kms:GenerateDataKey`, `kms:Decrypt`, `kms:ReEncrypt*`, and `kms:DescribeKey` on that key ARN.

### URI configuration[​](#uri-configuration "Direct link to URI configuration")

Instead of YAML manifests, you can pass `s3://` URIs via `ALMA_RECORDINGS_URI` or `ALMA_AUDIT_URI` in `/etc/almaforge/almad.env`:

/etc/almaforge/almad.env

```env
ALMA_RECORDINGS_URI=s3://almaforge-recordings/records?region=us-east-1

ALMA_AUDIT_URI=s3://almaforge-audit/events?region=us-east-1
```

For custom endpoints, append options as query parameters (always include `region` unless `AWS_REGION` or `AWS_DEFAULT_REGION` is set):

text

```text
s3://almaforge-recordings/records?region=us-east-1&endpoint=https://minio.internal:9000&ca_cert=/etc/almaforge/store-ca.pem
```

Accepted query parameters: `region`, `endpoint`, `path_style` (or `pathStyle`), `ca_cert` (or `caCert`), `sse_kms_key` (or `sseKmsKey`), `acl`, and `insecure`.

### S3 storage layout and internals[​](#s3-storage-layout-and-internals "Direct link to S3 storage layout and internals")

**Audit events layout**

Every key an audit instance writes starts at its own `path`:

text

```text
<StorageConfig.spec.path>/

└── events/<year>/<month>/<day>/<hour>/<unix-nanos>-<host-id>-<uuid>.jsonl.gz
```

Partitions are UTC. An audit object is gzipped Newline Delimited JSON, and each line in the decompressed object is one independent JSON event.

One object holds a whole batch of events, so its name is built rather than taken from the events in it: the time of the flush, the Auth instance's host ID, and a fresh UUID. The host ID is what separates two instances writing at once. The UUID separates one instance's own flush attempts, so a retry of a batch whose outcome was never learned cannot overwrite an object that already landed. An events object is therefore written once and never rewritten, which is what lets a search read the oldest version of a key and treat a second version as tampering.

**Session recordings layout**

text

```text
<StorageConfig.spec.path>/records/<session-id>.pb

<StorageConfig.spec.path>/records-index/<year>/<month>/<day>/<hour>/<unix-nanos>-<session-id>.jsonl.gz
```

A recording is one object named after its session ID. It buffers on the node while the session runs, and reaches S3 once the session ends. The suffix is `.pb` because a recording is a protobuf stream of the session's events.

Both prefixes are read at the version AlmaForge wrote, and the listing reads versions rather than current objects, so overwriting an index entry cannot rewrite a row and deleting one cannot hide a recording. This needs bucket versioning: a store without it serves whatever its keys currently hold, and says so once in the log.

Beside it, the sibling `records-index/` prefix holds one gzipped JSON Line (`.jsonl.gz`) object per recording, named for when the session started. That name needs no UUID, unlike an events object: an index entry describes one session, and the session ID makes it unique on its own. That is what the recordings list reads: partitions are UTC and keys sort chronologically, so a time window is a contiguous range of keys and a page of results costs one listing plus one read per row. Each index object holds the session's opening `SessionStart` record, which carries the session ID, protocol, owner, and host the list renders.

Both prefixes derive from the one `path` you configure. Because a recording's key is its session ID, a session ID from your SIEM is enough to fetch the recording with `aws s3 cp s3://<bucket>/records/<session-id>.pb -` (or `s3://<bucket>/<path>/records/<session-id>.pb` when `path` is set).

**Combined layout**

Both instances can share one bucket with `path` unset on both:

text

```text
almaforge-storage/

├── records/<session-id>.pb

├── records-index/<year>/<month>/<day>/<hour>/<unix-nanos>-<session-id>.jsonl.gz

└── events/<year>/<month>/<day>/<hour>/<unix-nanos>-<host-id>-<uuid>.jsonl.gz
```

Neither instance needs a `path` of its own, because recordings already write under `records/` and `records-index/` while audit writes under `events/`. Setting `path` on either instance simply nests those prefixes beneath it.

Separate buckets work the same way, because each instance's keys start at its own `path`. One case does call for separate buckets: Object Lock retention is a bucket-level setting, so keeping audit events longer than recordings needs a bucket for each.

**Listing and playing recordings needs no audit log**

The recordings store answers both questions about recordings on its own, so the list and the player work whether your audit events go to a bucket, to a SIEM, or nowhere.

When you run `alma recording ls` or open the recordings list in the Web UI, AlmaForge walks the `records-index/` prefix newest first, stops as soon as the page is full, and reads one index object per row. Playing a session reads the recording itself at `<path>/records/<session-id>.pb`.

Audit search answers a different question. It returns the session-end events of every session, recorded or not, which is "which sessions happened" rather than "what can I play". That is the question to route to a SIEM.

**Flush behavior and buffering**

* Audit events flush to S3 when the batch reaches 1 MiB, every 30 seconds, during graceful shutdown, or before an audit search query.
* Pending events stay buffered in memory up to 64 MiB. If an S3 write fails, events remain in memory for subsequent retries while searches continue serving existing bucket contents. If the buffer exceeds 64 MiB during an extended outage, subsequent audit emit calls fail with a limit exceeded error until the buffer flushes successfully.

## Troubleshooting[​](#troubleshooting "Direct link to Troubleshooting")

### Access denied on playback or audit search[​](#access-denied-on-playback-or-audit-search "Direct link to Access denied on playback or audit search")

If session uploads succeed but playback or audit searches fail with access denied errors:

* Check that the Auth host IAM role includes `s3:ListBucketVersions` on `arn:aws:s3:::<bucket>`. Without it an upload fails as well, because filing a recording in the index reads it back at the version just written.
* Check that the role includes `s3:GetObjectVersion` on `arn:aws:s3:::<bucket>/<path>/records/*` and `arn:aws:s3:::<bucket>/<path>/records-index/*`.
* Basic `s3:GetObject` permission is not sufficient for version-pinned reads.

### Certificate error on S3-compatible store[​](#certificate-error-on-s3-compatible-store "Direct link to Certificate error on S3-compatible store")

If `almad` fails with `x509: certificate signed by unknown authority`:

* The S3 endpoint uses TLS signed by an internal CA.
* Place the CA PEM bundle on the Auth host (for example, `/etc/almaforge/store-ca.pem`).
* Set `caCert: /etc/almaforge/store-ca.pem` in `StorageConfig` (or `ca_cert` in URI).

### Redirect or bucket-not-found error on non-AWS stores[​](#redirect-or-bucket-not-found-error-on-non-aws-stores "Direct link to Redirect or bucket-not-found error on non-AWS stores")

If uploads fail with 400 Bad Request, 404 Not Found, or 301 redirects on Backblaze B2, Cloudflare R2, Wasabi, Hetzner, or DigitalOcean Spaces:

* By default, setting `endpoint` enables path-style addressing (`https://endpoint/bucket`).
* These providers require virtual-hosted addressing (`https://bucket.endpoint`).
* Set `pathStyle: virtual` in `StorageConfig` (or `path_style=virtual` in URI).

### Store does not support object versioning[​](#store-does-not-support-object-versioning "Direct link to Store does not support object versioning")

If `almad` logs that the object store does not support versioning or returns `null` version IDs:

* Both session playback and audit search require the `ListObjectVersions` API. Stores that implement `ListObjectVersions` work even with bucket versioning switched off, but read current objects without overwrite or tamper protection.
* If a store does not implement the `ListObjectVersions` API at all, session playback warns and falls back to reading the current object, while audit search cannot list objects.
* Enable bucket versioning whenever your store supports it to gain tamper evidence and overwrite protection.

### Audit search fails with scan limit exceeded[​](#audit-search-fails-with-scan-limit-exceeded "Direct link to Audit search fails with scan limit exceeded")

If an audit search fails with an error indicating the search reached its scan limit (`an audit search of bucket ... reached ..., so narrow the time window`):

* The search query walked more than 1,000 days, 10,000 objects, or 256 MiB.
* Narrow the search window with `alma audit --last=1h` or explicit `--from-utc` and `--to-utc` flags.

### Cross-account uploads land in wrong account[​](#cross-account-uploads-land-in-wrong-account "Direct link to Cross-account uploads land in wrong account")

If objects uploaded to a secondary AWS account cannot be read by the destination account:

* Set `acl: bucket-owner-full-control` in `StorageConfig`.
* Ensure the Auth host IAM policy includes `s3:PutObjectAcl` on the object ARN.

### Recording not visible during an active session[​](#recording-not-visible-during-an-active-session "Direct link to Recording not visible during an active session")

* Recordings are buffered locally on the executing node while a session is active.
* The recording uploads to S3 only after the session terminates.

## Operations[​](#operations "Direct link to Operations")

### Integrity and versioning[​](#integrity-and-versioning "Direct link to Integrity and versioning")

To ensure audit logs and recordings remain immutable and tamper-evident:

* **Oldest-version reads on versioned buckets**: On a versioned bucket, AlmaForge queries object versions and reads the **oldest** version of a key. An unauthorized overwrite does not replace the original recording or audit object. On stores or buckets without versioning, reads fall back to current objects and cannot defend against overwrites.
* **Version warnings**: If multiple versions exist for an event log object under `events/`, AlmaForge logs a warning identifying the key as potentially tampered with. An events object is written once and never rewritten, so a second version of one is evidence that something wrote over the audit log.
* **High-assurance deployments (Object Lock)**: To protect against principals with `s3:DeleteObjectVersion` permissions, enable S3 Object Lock in Compliance mode. No user (including the AWS root account) can overwrite or delete object versions until the retention period expires.

### Server-side encryption[​](#encryption-and-endpoint-selection "Direct link to Server-side encryption")

AlmaForge supports two encryption models:

1. **Bucket default encryption (recommended)**: Configure SSE-S3 or default KMS encryption on the S3 bucket itself. Uploads inherit the bucket policy automatically without client-side configuration.
2. **AWS KMS key**: Set `sseKmsKey` in `spec.s3`. AlmaForge requests `aws:kms` encryption with that specific key for every upload.

### Retention and lifecycle rules[​](#retention-and-lifecycle-rules "Direct link to Retention and lifecycle rules")

AlmaForge does not delete expired audit events or recordings. Configure S3 lifecycle rules on your bucket:

* **Expire noncurrent versions**: Because AlmaForge reads the oldest version of each key, a lifecycle rule that only deletes current versions adds a delete marker while leaving the underlying data intact. Configure the rule to expire noncurrent versions.
* **Delete marker cleanup**: Enable cleanup of expired object delete markers (`ExpiredObjectDeleteMarker`).
* **Separate prefixes**: Use distinct lifecycle rules for `records/` and `events/`. A rule that expires recordings must cover `records-index/` as well, or the list keeps naming recordings the bucket no longer holds.

### Multi-sink audit logging and redundancy[​](#multi-sink-audit-logging-and-redundancy "Direct link to Multi-sink audit logging and redundancy")

For high availability, you can configure multiple audit sinks simultaneously by placing multiple `audit-*` manifests in `/etc/almaforge/almad.d`.

For example, pair an S3 audit sink (`audit-primary`) with a local disk sink (`audit-local` using `spec.file`). If network connectivity to S3 fails, the Auth Service continues writing events locally while buffering up to 64 MiB in memory for S3 upload retries. That bound is reported as `s3_audit_pending_bytes_limit`, and what is held against it as `s3_audit_pending_bytes`.

### Observability[​](#observability "Direct link to Observability")

Monitor these Prometheus metrics to ensure healthy S3 operations:

| Metric                                                           | Type      | Description                                                  | Alert condition                                                                                                                                                                          |
| ---------------------------------------------------------------- | --------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `s3_audit_events_refused_total`                                  | Counter   | Audit events refused because the buffer is full, by `reason` | Alert on any rate `> 0`: these events were not stored                                                                                                                                    |
| `s3_audit_pending_bytes`                                         | Gauge     | Audit event bytes held in memory, waiting to be written      | Alert when `s3_audit_pending_bytes / s3_audit_pending_bytes_limit > 0.8`. Both carry `bucket` and `path`, so an audit configuration that fans out to two buckets reports each separately |
| `s3_audit_pending_bytes_limit`                                   | Gauge     | Bytes held before events are refused                         | Use as the denominator above, rather than hardcoding the bound                                                                                                                           |
| `s3_audit_flush_failures_total`                                  | Counter   | Number of failed S3 audit batch uploads                      | Alert on any rate `> 0`                                                                                                                                                                  |
| `s3_audit_flushes_total`                                         | Counter   | Number of successfully flushed audit batches                 | Expected steady increase                                                                                                                                                                 |
| `s3_audit_flush_seconds`                                         | Histogram | Time to write one audit batch                                | A rising p99 is the store slowing before the buffer fills                                                                                                                                |
| `s3_audit_objects_listed`                                        | Histogram | S3 objects scanned per audit search                          | Query `rate(s3_audit_objects_listed_sum[5m]) / rate(s3_audit_objects_listed_count[5m])` or `s3_audit_objects_listed_bucket` to detect broad searches                                     |
| `s3_recordings_uploads_total`                                    | Counter   | Recordings stored, by `result`                               | Alert on `rate(s3_recordings_uploads_total{result="error"}[5m]) > 0`                                                                                                                     |
| `s3_recordings_downloads_total`                                  | Counter   | Recordings read, by `result`                                 | An error rate here is failing playback                                                                                                                                                   |
| `s3_recordings_searches_total`                                   | Counter   | Recordings listings served, by `result`                      | An error rate here is an empty recordings list in the web UI                                                                                                                             |
| `s3_recordings_upload_seconds`, `s3_recordings_download_seconds` | Histogram | Time to store or read one recording                          | Compare against session length to spot a slow store                                                                                                                                      |

See the [monitoring guide](https://almaforge.com/monitoring.md#alerts-that-earn-their-keep) for alert configuration and scrape rules.

## References[​](#references "Direct link to References")

* [Storage backends overview](https://almaforge.com/storage.md)
* [Local storage](https://almaforge.com/storage/local.md)
* [SQLite storage](https://almaforge.com/storage/sqlite.md)
* [PostgreSQL storage](https://almaforge.com/storage/postgresql.md)
* [DynamoDB storage](https://almaforge.com/storage/dynamodb.md)
* [etcd storage](https://almaforge.com/storage/etcd.md)
* [Firestore storage](https://almaforge.com/storage/firestore.md)
* [Monitoring and alerts](https://almaforge.com/monitoring.md#alerts-that-earn-their-keep)
