> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenetlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Monitoring

> What the services and VPC Lattice log, how to read readiness when the probes aren't routed through Lattice, the CloudWatch metric filters and alarms to create (audit and erasure failures, 403 spikes, metering, readiness, vault), and the counts-only usage records you can hand an auditor.

**Monitoring surface**: container logs (stdout/stderr → CloudWatch Logs or your log agent), VPC Lattice access logs, readiness as your platform sees it, the per-call audit records, and hourly counts-only usage records. The services expose no metrics endpoint. Everything stays in your account unless you opt in to sending usage records.

## When to use it

Set the alarms below before production traffic, then use this page when an alarm fires.

## What you get

| Signal | Where | What it carries |
| - | - | - |
| Access log | Each service's stdout | One line per request that reached the task: peer address, method, path, status. Never bodies. |
| Runtime log | stderr | Startup checks, refusals with their reason, keyring events, vault reachability, metering. Identifiers and AWS error codes only — never values or key material. |
| Audit lines | Rehydrate and detect stdout | The same JSON as the S3 audit records: `tenet.reidentify-audit.v3` per `/reidentify` (rehydrate), `tenet.erasure-audit.v1` per erasure (detect). |
| Usage records | Detect stdout, or `TENET_TELEMETRY_PATH` | Documents by length and findings per entity label, per hour. |
| Lattice access logs | `/<NamePrefix>/lattice` (CloudFormation, Terraform); `lattice.accessLogDestinationArn` (Helm) | Every request Lattice received — including the ones it refused — with the caller principal and `requestId`, which equals `upstream_request_id` in the audit record. Principal tags appear only on denied requests. |
| Readiness | ECS service and Lattice target health; Kubernetes readiness | The Lattice target groups and the readiness probes call `/readyz` (model loaded and vault reachable). The probes aren't routed through Lattice, so callers can't reach them. |
| AWS metrics and events | CloudWatch, CloudTrail | ECS/EKS CPU and memory, Aurora, KMS and Marketplace metering calls in CloudTrail. |

Log lines worth knowing:

```text theme={null}
keyring is empty; creating the first vault key pair
vault key pair k20261106T091500Z-1a2b3c4d is now current
vault key rotated: k20261003T091500Z-9f8e7d6c -> k20261106T091500Z-1a2b3c4d
vault unreachable: OperationalError                                                  # WARNING
refused POST on route reidentify: arn:aws:sts::<account-id>:assumed-role/claims-app/… is not allowed to call reidentify   # WARNING → the caller got 403
audit bucket <bucket> has Object Lock enabled but no default retention rule; …      # WARNING
on_reidentify hook failed for request_id=<id>                                        # ERROR → the call returned 503, nothing restored
on_erase hook failed for request_id=<id>                                             # ERROR → the call returned 503, nothing deleted
Marketplace entitlement check was throttled; starting anyway                         # WARNING
metering send failed: <AWS error code>                                               # WARNING, retried
unbilled usage lost: <dimension>=<quantity> for <hour> (<reason>)                    # ERROR
```

## Alarms

| Alarm on | How | Why |
| - | - | - |
| **Reidentify audit failures** | Metric filter on the rehydrate log: `"on_reidentify hook failed"` | Every such call returned `503` with nothing restored. Page someone. |
| **Erasure audit failures** | Metric filter on the detect log: `"on_erase hook failed"` | Every such erasure returned `503` and the session was kept. |
| **Refused callers** | Metric filter on both logs: `"refused"`; or on the Lattice access logs, a filter on `403` responses | A role missing from an invoker list or its identity policy, a missing approval tag — or someone probing. [Requests refused with 403](https://docs.tenetlabs.com/pii-engine/troubleshooting.md#requests-refused-with-403). |
| **Unreportable usage** | Built in: CloudFormation and Terraform create a metric filter on `"unbilled usage lost"` and an alarm, `<NamePrefix>-unbilled-usage`. Set `AlarmTopicArn` / `alarm_topic_arns` to be notified. On EKS, create the same filter yourself. | AWS Marketplace didn't accept a usage report. Check the `metering-marketplace` endpoint and `aws-marketplace:MeterUsage` on the detect role. |
| **Readiness** | ECS: EventBridge on `ECS Service Action` events of type `WARN`/`ERROR` for the cluster, and stopped tasks with a non-zero exit code. EKS: `kube_deployment_status_replicas_unavailable` > 0. | Model not loaded, vault unreachable, or a startup refusal. |
| **Vault unreachable** | `"vault unreachable"` | Readiness fails; de-identify and re-identify fail. |
| **Unknown-session spikes** | JSON filter on the rehydrate log: `{ $.schema = "tenet.reidentify-audit.v3" && $.outcome = "unknown_session" }` | Expired sessions — or someone guessing session ids. |
| **Re-identify volume** | `{ $.schema = "tenet.reidentify-audit.v3" }` count, by hour; split by `$.caller` in Logs Insights | A per-caller baseline to spot unusual rehydration. |
| **Erasure volume** | `{ $.schema = "tenet.erasure-audit.v1" }` count, by hour | A baseline for your retention jobs. |
| **Detect CPU** | ECS service `CPUUtilization` / pod CPU vs. request | Sustained > 60% means autoscaling is at its ceiling. [Sizing](https://docs.tenetlabs.com/pii-engine/operate/sizing.md). |
| **Break-glass use** | EventBridge on CloudTrail `AssumeRole` for the break-glass role | Every use should be a known incident. [Break-glass](https://docs.tenetlabs.com/pii-engine/operate/break-glass.md). |
| **CMK destruction** | CloudTrail `ScheduleKeyDeletion` / `DisableKey` on the CMK | Losing the key loses the vault and the audit trail. |

Example (ECS, the stack's log groups are `/<NamePrefix>/detect`, `/<NamePrefix>/rehydrate` and `/<NamePrefix>/lattice`):

```bash theme={null}
aws logs put-metric-filter --log-group-name /tenet-pii/rehydrate \
  --filter-name tenet-audit-failures --filter-pattern '"on_reidentify hook failed"' \
  --metric-transformations metricName=AuditFailures,metricNamespace=TenetPII,metricValue=1,defaultValue=0
aws cloudwatch put-metric-alarm --alarm-name tenet-pii-audit-failures \
  --namespace TenetPII --metric-name AuditFailures --statistic Sum --period 60 \
  --evaluation-periods 1 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold \
  --treat-missing-data notBreaching --alarm-actions <sns-topic-arn>
```

Repeat with `"on_erase hook failed"` on `/tenet-pii/detect`. Before you rely on a filter, prove it with `aws logs test-metric-filter` against a line from this page.

Create the recommended CloudWatch metric filters and alarms for a deployment.

Create monitoring for my Tenet PII Engine (Enterprise) deployment, following [https://docs.tenetlabs.com/pii-engine/operate/monitoring](https://docs.tenetlabs.com/pii-engine/operate/monitoring.md).

Ask me for: Region; platform; the detect, rehydrate and Lattice log group names (ECS stack defaults `/NAME_PREFIX/detect`, `/NAME_PREFIX/rehydrate`, `/NAME_PREFIX/lattice`, NAME\_PREFIX defaults to tenet-pii; on EKS, where my log agent writes container logs and my `lattice.accessLogDestinationArn`); the SNS topic ARN for alarms; the break-glass role ARN if one exists; the CMK ARN; whether I manage alarms in CloudFormation/Terraform (then write them there instead of running CLI commands).

Create, in namespace TenetPII: metric filters and alarms for reidentify audit failures (`"on_reidentify hook failed"`, rehydrate log), erasure audit failures (`"on_erase hook failed"`, detect log), refused callers (`"refused"` on both service logs), vault unreachable (`"vault unreachable"`), and counts of audit records (`{ $.schema = "tenet.reidentify-audit.v3" }` and `{ $.schema = "tenet.erasure-audit.v1" }`) for a baseline. On ECS, check that the stack's `<NAME_PREFIX>-unbilled-usage` alarm exists and tell me whether it notifies anyone (AlarmTopicArn / alarm\_topic\_arns); on EKS create the same `"unbilled usage lost"` filter and alarm on the detect log. Create EventBridge rules for ECS Service Action events of type WARN or ERROR on the cluster (ECS only), for CloudTrail AssumeRole on the break-glass role, and for ScheduleKeyDeletion/DisableKey on the CMK, targeting the SNS topic.

Show me every resource before creating it and wait for approval. After creating, run `aws logs test-metric-filter` for each pattern with a sample line from the page to prove it matches. Never create a filter that extracts request text, and never one that extracts a session\_id.

## Usage records

The detect service counts `POST /detect`, `/redact` and `/deidentify` requests that returned \< 400, by document length in characters, and counts the entity labels in each response's `findings`. It reads `len(text)` and the labels, and drops both bodies — values, spans and offsets are never read.

```json theme={null}
{"schema": "tenet.pii.usage.v1", "hour_utc": "2026-11-06T12:00:00Z", "source": "marketplace",
 "deployment_id": "acme-prod-use1", "product_version": "<product version>", "engine_version": "<engine version>",
 "documents": {"XS": 120, "S": 40, "M": 7, "L": 1, "tail": 1}, "tail_increments": 3,
 "findings": {"EMAIL": 31, "REFERENCE_NUM": 4, "SSN": 2}}
```

`documents` and `tail_increments` count the hour's documents by length; `findings` counts entity labels.

* **Where:** stdout (→ your logs) by default, or JSONL at `TENET_TELEMETRY_PATH` (must be under `/tmp` on the read-only filesystem). Always written locally.
* **When:** each process writes completed hours about once a minute, and a cumulative snapshot of its current hour on shutdown. Records are **per process** and each is an absolute snapshot of its hour — take the latest snapshot per process and hour, then sum across replicas.
* **Sent to Tenet only if you opt in** (CloudFormation `EnableUsageTelemetryEgress`, Terraform `enable_usage_telemetry_egress`, Helm `telemetry.egress.enabled`): the same records, unchanged, except that `deployment_id` carries `:<replica id>` in the HTTP body. Undeliverable records are kept in memory for up to 48 hours, then dropped (`dropped N usage records older than 48h`). [Setup](#sending-usage-records-to-tenet).
* **For auditors:** the schema is an allowlist of exactly these keys; every record is checked against it before it's written. Hand over the stdout lines (CloudWatch Logs Insights: `filter schema = "tenet.pii.usage.v1"`) as evidence of volume with no payload-derived field.

### Sending usage records to Tenet

**Opt in to see each deployment's hourly volume and entity mix on the PII page of Tenet Platform.** Detection and AWS Marketplace billing don't depend on it, and records keep being written locally either way.

**1. Create a Tenet Platform API key**

Sign in to [Tenet Platform](https://platform.tenetlabs.com), open **API Keys** and click **Generate**. Copy the `sk_tenet_…` key — it's shown once. Records land in the Tenet account that owns the key, so generate it in the account whose **PII** page should show this deployment. Only the account owner sees **API Keys**. Sending records uses no credits.

**2. Store the key**

**ECS (CloudFormation, Terraform):** a Secrets Manager secret in the account and Region of the deployment, as a plain string:

```bash theme={null}
read -rs TENET_KEY   # paste the key; keeps it out of shell history and argv
printf '%s' "$TENET_KEY" | aws secretsmanager create-secret \
  --name tenet-pii/usage-telemetry-api-key \
  --secret-string file:///dev/stdin --query ARN --output text
```

If the secret uses a customer-managed KMS key, allow the detect execution role `kms:Decrypt` with it.

**EKS (Helm):** a Secret in the release namespace, with no trailing newline (or sync it from Secrets Manager with External Secrets Operator):

```bash theme={null}
read -rs TENET_KEY
printf '%s' "$TENET_KEY" | kubectl -n tenet-pii create secret generic tenet-usage-telemetry \
  --from-file=api-key=/dev/stdin
```

**3. Turn on egress**

CloudFormation: `EnableUsageTelemetryEgress=true`, `UsageTelemetryApiKeySecretArn=<secret ARN>`, `UsageTelemetryNatSubnetId=<public subnet id>`. Terraform: `enable_usage_telemetry_egress = true`, `usage_telemetry_api_key_secret_arn`, `usage_telemetry_nat_subnet_id`. If the private route tables already have a default route, also set `UsageTelemetryCreateDefaultRoute=false` / `usage_telemetry_create_default_route = false`.

This adds a NAT gateway and a tcp/443 egress rule on the detect task security group — cost and the egress tradeoff are under [CloudFormation parameters](https://docs.tenetlabs.com/pii-engine/deploy/ecs-cloudformation.md#parameters). The update replaces the detect tasks so they pick up the key.

Helm: `telemetry.egress.enabled=true` and `telemetry.egress.apiKeySecret.name=tenet-usage-telemetry`. The detect NetworkPolicy gains one rule, tcp/443 to public addresses, with private and link-local ranges (including IMDS) still closed. The chart can't create a NAT gateway: your node subnets need a route to one. `helm upgrade` replaces the detect pods. [Helm values](https://docs.tenetlabs.com/pii-engine/deploy/eks-helm.md).

**4. Check that records arrive**

A few minutes after the first hour with traffic closes, open **PII** in Tenet Platform and filter **Source: Marketplace**. Each row is one hour of one `DeploymentId`, summed across replicas, so it should equal the sum of that hour's latest local record per process. Times show in your browser's time zone.

A successful send logs nothing. Failures log on the detect service and records are retried for up to 48 hours:

| Log line | Meaning |
| - | - |
| `usage telemetry rejected the API key (HTTP 401); retrying with backoff` | Wrong or revoked key. Logged at most once an hour. |
| `usage telemetry send failed: <error>` | No path out. Check the NAT gateway, the default routes and the detect security group (on EKS, the node subnets' route to a NAT and the detect NetworkPolicy). |
| `usage telemetry egress needs both TENET_TELEMETRY_SINK_URL and TENET_TELEMETRY_API_KEY; it stays off` | Only one of the two is set; nothing is sent. |

To stop sending, set `EnableUsageTelemetryEgress=false` / `enable_usage_telemetry_egress = false`, which also removes the NAT gateway, or `telemetry.egress.enabled=false` on Helm. Revoking the key on **API Keys** stops delivery too, but the detect service keeps retrying and logging `HTTP 401`.

## Gotchas

* **Callers can't reach `/healthz` or `/readyz`.** Lattice answers them with `404`. Read readiness from ECS, the Lattice target groups (`aws vpc-lattice list-targets`) or Kubernetes.
* **A refusal can come from two places.** Lattice refuses on its auth policy and logs it in its access log; requests it lets through are re-checked by the service, which logs `refused … : <reason>`. Check both.
* **Caller ARNs are workforce identifiers.** Audit lines and Lattice access logs carry role session ARNs, whose session name is often an email address. Treat these logs accordingly.
* **Don't add body logging** in a proxy, sidecar or APM agent in front of the services. The logs are value-free by design; a body logger breaks that.

## Links

* [Rehydration and audit](https://docs.tenetlabs.com/pii-engine/concepts/rehydration-and-audit.md)
* [Billing and metering](https://docs.tenetlabs.com/pii-engine/concepts/billing.md)
* [Troubleshooting](https://docs.tenetlabs.com/pii-engine/troubleshooting.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.