> ## 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.

# Subscription and metering

> How PII Engine (Enterprise) is billed through AWS Marketplace metering: the detect service's startup entitlement check and hourly usage reports, what never affects a request, the IAM and endpoint it needs, and the unreported-usage alarm.

**Billing** is AWS Marketplace metering, pay-as-you-go: the detect service checks at startup that the account is subscribed, then reports its hourly document counts to AWS through the `metering-marketplace` VPC endpoint. The rehydrate service doesn't meter at all. AWS bills you on your AWS bill. Prices are on your offer.

## When to use it

Read this when you set up IAM and endpoints for a new account, when detect refuses to start with a metering error, or when the unreported-usage alarm fires. There's nothing to configure — no license key, SKU, tier or grace period.

## What the services do

* **At startup, detect checks the entitlement.** After the KMS step, it calls `MeterUsage` with `DryRun` through the `metering-marketplace` endpoint. Any error except throttling stops the process before it serves:

  ```text theme={null}
  tenet-pii-enterprise: error: AWS Marketplace metering refused this deployment: <code>. Check that this account is subscribed to the product and that the task role allows aws-marketplace:MeterUsage.
  tenet-pii-enterprise: error: AWS Marketplace metering is unreachable: <error>. Check the metering-marketplace VPC endpoint.
  ```

  A throttled check logs a `WARNING` and starts anyway.

* **Every hour, detect reports usage.** Each detect task reports its usage for each closed hour, and for the open hour when it shuts down. It counts documents that `/detect`, `/redact` and `/deidentify` answered with a status below `400`; failed requests aren't counted.

* **Rehydrate is never billed and never checks.** It can only restore what an entitled detect stored, so it doesn't call metering and its role has no `MeterUsage` grant. After you unsubscribe, a restarted rehydrate can still restore stored sessions until their TTL; detect refuses to start, so nothing new is stored.

* **Billing never touches a request.** Reports are sent in the background. A report that fails for good is logged at `ERROR`:

  ```text theme={null}
  unbilled usage lost: <dimension>=<quantity> for <hour timestamp> (<reason>)
  ```

* **Unsubscribing stops new detect tasks, not running ones.** AWS keeps a running task entitled; the next detect task to start fails its check.

## What it needs

| Requirement | Why |
| - | - |
| A Marketplace subscription (or accepted private offer) in the **deployment** account | The entitlement check runs as the detect role in that account. |
| `com.amazonaws.<region>.metering-marketplace` interface endpoint with private DNS | The only path to AWS Marketplace metering. No NAT needed. The CloudFormation template and Terraform module create it; on EKS you do. |
| `aws-marketplace:MeterUsage` on `Resource: "*"` for the **detect** role only | The action has no resource-level scoping. Rehydrate doesn't need it. |
| Credentials from the **ECS task role or IRSA** | AWS rejects this call from node or instance roles, EKS Pod Identity and long-term keys. On EKS, use IRSA: AWS Marketplace meters through the detect ServiceAccount, `tenet-pii-enterprise-detect`. |
| ECS or EKS in AWS | Air-gapped and non-AWS sites (Containers Anywhere, on-premises) aren't supported. |

The opt-in usage-telemetry egress to Tenet is a separate thing: billing never depends on it and never needs a NAT gateway. [Data flow](https://docs.tenetlabs.com/pii-engine/security/data-flow.md).

## The unreported-usage alarm

The CloudFormation template and the Terraform module create it on the detect log group:

| | |
| - | - |
| Metric filter | `"unbilled usage lost"` → metric `UnbilledUsageLost` in namespace `TenetPII/<NamePrefix>` |
| Alarm | `<NamePrefix>-unbilled-usage`: sum over one hour > 0 |
| Notification | `AlarmTopicArn` (CloudFormation) or `alarm_topic_arns` (Terraform). Empty = the alarm shows in CloudWatch only. |

The Helm chart creates no alarm. On EKS, put the same filter on wherever your log agent ships the detect pods' logs. [Monitoring](https://docs.tenetlabs.com/pii-engine/operate/monitoring.md).

Check billing health end to end — subscription, endpoint, IAM, alarm and logs. Read-only.

Check the billing health of my Tenet PII Engine (Enterprise) deployment, following [https://docs.tenetlabs.com/pii-engine/concepts/billing](https://docs.tenetlabs.com/pii-engine/concepts/billing.md). Read-only: change nothing.

Ask me for: Region, deployment account, platform (EKS namespace and release, or ECS cluster and CloudFormation stack or Terraform root module), the detect role ARN, the VPC id, the detect log group (ECS default `/tenet-pii/detect`; on EKS, wherever my log agent writes the detect pods' logs), and NamePrefix (default tenet-pii).

1. Detect is running at its desired count (`aws ecs describe-services`, or `kubectl get deploy`). A detect task or pod that won't start with "AWS Marketplace metering refused this deployment" or "is unreachable" in its logs is a billing failure: report the code.
2. A `com.amazonaws.<region>.metering-marketplace` interface endpoint exists in the VPC, state available, with PrivateDnsEnabled true (`aws ec2 describe-vpc-endpoints --filters Name=vpc-id,Values=<vpc>`).
3. The detect role allows `aws-marketplace:MeterUsage` (`aws iam simulate-principal-policy --policy-source-arn <role> --action-names aws-marketplace:MeterUsage`).
4. Detect uses that role directly: on ECS, the detect task definition's taskRoleArn is the detect task role; on EKS, the `tenet-pii-enterprise-detect` ServiceAccount has an `eks.amazonaws.com/role-arn` annotation (IRSA) and no EKS Pod Identity association exists for it (`aws eks list-pod-identity-associations`).
5. The alarm `<NamePrefix>-unbilled-usage` exists and has an SNS action (`aws cloudwatch describe-alarms --alarm-names ...`). On EKS, report whether any equivalent alarm exists.
6. Search the last 7 days of detect logs for "unbilled usage lost" and "metering send failed" (WARNING) and summarize counts and reasons. Never print request data.
   Report pass/fail per check with the fix for each failure, quoting this page.

## Gotchas

* **Subscribing in one account doesn't entitle another.** Subscribe from the account the services run in.
* **Node-role credentials fail the startup check.** Granting `MeterUsage` to the EKS node role, or using EKS Pod Identity, doesn't work — only IRSA does.
* **No endpoint, no detect.** A deleted or policy-restricted `metering-marketplace` endpoint stops every new detect task.
* **`metering send failed` warnings are retries, not losses.** Alarm on `unbilled usage lost`, which is final.

## Links

* [Subscribe and get the image](https://docs.tenetlabs.com/pii-engine/get-started/marketplace.md)
* [Prerequisites](https://docs.tenetlabs.com/pii-engine/deploy/prerequisites.md)
* [Monitoring](https://docs.tenetlabs.com/pii-engine/operate/monitoring.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.