Help improve this page
To contribute to this user guide, choose the Edit this page on GitHub link that is located in the right pane of every page.
Observe agent workloads on Amazon EKS
Pod metrics tell you a container is busy. They don’t tell you which agent spent the tokens, which model it called, how long a turn took, which tools it used, or what it did in what order. Those are the questions you answer when an agent’s cost spikes, when a model change makes it slower, or when you need to reconstruct what an agent did after an incident. Agent telemetry answers them, and evaluation (Evaluate agent output on Amazon EKS) grades agents on the traces it collects, so turn telemetry on first.
Agent telemetry has two shapes. Metrics, such as tokens, call latency, and errors per agent and per model, are cheap to keep and drive dashboards and alarms. Traces record each turn as a tree of spans, one per model call and tool call, and show the agent’s trajectory. Keep per-turn detail on spans and keep metric dimensions coarse (see Metric design).
The OpenTelemetry GenAI semantic conventions define standard names for these signals, such as the model, token counts by type, and operation. An agent that emits them works with any backend that understands the conventions, so you choose the backend for operational reasons and can change it later without changing the agent:
-
Prometheus and Grafana, with a trace backend you run, keep telemetry in the cluster and give you full control of dashboards and retention. You operate every component, and you build trajectory views yourself.
-
Amazon CloudWatch and AWS X-Ray are managed. The CloudWatch GenAI Observability views show model calls, tool calls, and trajectories without views you build, and AgentCore online evaluation reads spans from the same store.
The following diagrams show each path.
Open source and AWS services paths
The following table compares how each path provides agent telemetry.
| Aspect | Open source | AWS services |
|---|---|---|
|
Collector |
OpenTelemetry collector in the cluster |
AWS Distro for OpenTelemetry (ADOT) collector in the cluster |
|
Metrics and dashboards |
Prometheus and Grafana, and Prometheus also scrapes the gateway |
Amazon CloudWatch metrics and dashboard, with Container Insights for nodes and pods |
|
Traces |
Langfuse, when you turn it on |
AWS X-Ray, with spans stored in the |
|
Collector’s access to the backend |
Writes to backends in the cluster, with Langfuse’s credentials from |
Signs its writes with its own IAM role |
|
Spend panels |
Dollar metric that the in-cluster gateway emits from its model cost catalog |
Read from Amazon CloudWatch |
|
Policy decisions |
Grafana dashboard that counts refusals, with no log store |
Network policy verdict log in CloudWatch Logs and a policy decisions dashboard |
|
Operation |
You operate every component, and build trajectory views yourself |
Managed, with CloudWatch GenAI Observability views of model calls, tool calls, and trajectories |
How telemetry reaches the backend
Agents send telemetry to a collector in the cluster, not directly to the backend. The collector batches and filters telemetry and holds the backend’s credentials, so changing backends means changing the collector, not every agent. It also keeps the network boundary small. Each agent needs egress to one in-cluster address instead of to every backend, and on the AWS services path the collector signs its writes with its own IAM role, so agents need no permission to write telemetry.
An agent that isn’t told where the collector is exports nothing. The standard OpenTelemetry variable OTEL_EXPORTER_OTLP_ENDPOINT carries the address, and the agent’s network policy must permit it.
In the reference sample, enable_observability turns on the whole layer on either path, and the base setup in the reference sample leaves it off.
-
Open source.
enable_langfuseadds Langfuse as the trace backend, at the cost of another stateful tier. -
AWS services. CloudWatch Transaction Search must be on to store spans for querying. It’s an account-and-Region setting, which the stack turns on by default.
For the agent code and collector configuration that the reference sample uses, see Step 2: Review how the agent and the collector are configured.
Key signals
Both paths ship a dashboard with the same panels:
-
Estimated spend per agent and per model.
-
Tokens by agent and by token type.
-
Model call rate, and call latency at p50 and p95.
-
Errors by type.
Use spend per agent to find the agent driving cost, and latency and errors per model to detect a model change.
Cost estimates
The dashboard’s dollar figures are estimates for comparing agents and weeks, not billing data.
-
Source. On the open source path, the in-cluster gateway prices each call from its model cost catalog and emits a dollar metric per model and per agent. On the AWS services path, the managed gateway has no in-cluster metrics endpoint, so the spend panels read Amazon CloudWatch.
-
Unpriced models. When the gateway finds no price for a model, it under-reports that model’s cost, and no panel flags the gap. Track the share of calls the gateway priced exactly.
-
Your rates. The catalog has list prices only. It excludes provisioned throughput, batch pricing, negotiated rates, and free tiers.
For billing-grade cost, use the AWS Cost and Usage Report with these cost allocation tags:
-
iamPrincipal/agent. The agent’s session tag. On the open source path, the gateway assumes each agent’s role to sign its model calls, so this tag splits model spend per agent. On the AWS services path, the managed gateway signs model calls with its own role, so the report attributes model spend to the gateway, and this tag splits only an agent’s own AWS calls, such as checkpoints and session state. -
aws:eks:cluster-name. Splits the cluster’s infrastructure cost, including nodes.
Set activate_cost_allocation_tags = true to activate the keys. Plan for these constraints before you set it:
-
It is an account-level billing setting, so the apply needs payer-account credentials.
-
A key can be activated only after it appears in the account’s tag inventory. Set the variable on a second apply, after agents have made calls.
-
Activation is not retroactive. Cost Explorer can take up to 24 hours to show a newly activated key.
Limitations
-
Denied egress. The network policy agent emits no metric for a denied connection, so on the agent dashboard a denial looks like a failed agent request. Its verdict log records the denial. See Policy decisions.
-
Tool-call outcomes and trajectories. These are spans, so the metrics dashboard does not show them. On the AWS services path, use the GenAI Observability views. On the open source path, query the trace backend; you build those views yourself.
-
Budget headroom. The gateway enforces budgets. The headroom panel compares the agent’s metric against a limit copied from the gateway configuration. If the gateway configuration changes and the panel’s copy does not, the panel is wrong.
Policy decisions
Each control in the stack decides something different and records its decision in a different place. To confirm that a policy took effect, look where the control that applies it writes its decisions:
| Control | Decides | Recorded in |
|---|---|---|
|
Network policy |
Each flow into and out of an agent pod, by IP address, with |
The verdict log on each agent node |
|
AgentCore Gateway |
Each model call and tool call, by Cedar policy |
The |
|
Admission |
Each pod an agent namespace refuses |
The control plane audit log, when it’s turned on |
|
IAM |
Each AWS call an agent’s role makes |
AWS CloudTrail, as |
|
MCP server |
Each tool call made for a person |
The MCP server’s pod log |
|
Nitro Sandbox |
Nothing, because it isolates rather than decides |
Nowhere |
A network policy count is of verdict records, not connections. A refused connection is logged once for each retry of its first packet, so it can count several times. The verdict log names IP addresses, not pods, and a pod’s address is reused when the pod is replaced, so resolve an address soon after the denial. The tier names the kind of policy that decided. NETWORK_POLICY is a namespaced policy, ADMIN is a cluster-scoped policy, and DEFAULT means that no policy matched and the node’s default applied.
Container Network Observability, which includes Network Flow Monitor and the service map in the EKS console, doesn’t show a sandboxed agent’s own flows. A sandboxed agent appears only where the other end of a connection is an unsandboxed pod, such as an MCP server, so its calls to the gateway and to the internet are missing from the map.
Metric design
Don’t use per-turn or per-cycle identifiers as metric dimensions. Each value creates a new time series, so cost grows without bound and no aggregate series exists for dashboards to query. Put per-turn identifiers on spans. Limit metric dimensions to agent, model, and operation.
Prerequisites
-
The base setup from Set up an Amazon EKS cluster for agent workloads, applied, and the in-cluster components from Set up EKS Capabilities and in-cluster components for agents, synced.
-
PAVED_PATHset toopen-sourceoraws-services, such as withexport PAVED_PATH=open-source. -
A shell with
kubectlaccess to the cluster, on the bastion or your workstation, and an agent deployed as in Deploy an agent on Amazon EKS. The commands use the reference agentresearchin namespaceagents. -
On the AWS services path, the AWS CLI, for the CloudWatch Logs query in Step 3.
On the AWS services path, the stack turns on AWS X-Ray Transaction Search by default. It’s an account-level setting, so it affects every workload in the account. The sample’s teardown script turns it off only on request, and only if no other cluster from this stack in the account uses it.
Step 1: Turn on observability
This step turns on the telemetry layer.
Every agent gets OTEL_EXPORTER_OTLP_ENDPOINT, pointing at the collector over OTLP/HTTP on port 4318, and an egress rule to it. Outside these templates, run a collector Service, set the variable on each agent, and permit egress to the collector only.
The bootstrap script applies the rendered root Application, refreshes and syncs it, and waits for the Applications to converge. With --roll-agents, it then recreates each agent pod whose Sandbox changed, and prints a line for each agent, such as agents/research: recreating (env OTEL_EXPORTER_OTLP_ENDPOINT added), or current for an agent that didn’t change.
The new Applications report Synced and Healthy. If one stays Progressing after its objects are ready, run the bootstrap script again, because Argo CD can keep the health it computed while they were starting. See Turn on a component later.
A Sandbox doesn’t replace its running pod when its spec changes, so without --roll-agents a sandboxed agent keeps exporting nothing. The --roll-agents on the sync recreates the pod. To confirm that the agent’s Sandbox has OTEL_EXPORTER_OTLP_ENDPOINT, run the following:
./scripts/run-stack.sh --root terraform/$PAVED_PATH -- bash -c "kubectl -n agents get sandbox research -o yaml | grep -A1 OTEL_EXPORTER_OTLP_ENDPOINT"
An agent with runtime: deployment rolls automatically.
Step 2: Review how the agent and the collector are configured
The sync in Step 1 configures both ends of the pipeline. The agent’s own code and environment decide what it emits, and the collector decides where the telemetry lands. If you build an agent or a collector of your own, these are the pieces it needs.
Agent instrumentation
Setting the OTEL_* environment variables isn’t enough on its own. Nothing reads them until the agent creates an OpenTelemetry tracer provider and meter provider and attaches exporters. Without that, an agent completes model calls and emits nothing, and every component still reports healthy. The reference agent uses the Strands Agents SDK, which emits the GenAI semantic conventions, and turns both signals on at startup:
import os from strands.telemetry import StrandsTelemetry def setup_telemetry(): if not os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT"): return # no collector: export nothing telemetry = StrandsTelemetry() telemetry.setup_otlp_exporter() # spans for each turn, model call, and tool call telemetry.setup_meter(enable_otlp_exporter=True) # GenAI metrics: token usage, operation duration
Traces alone leave metric dashboards empty, so set up the meter too. The agent also puts the conversation’s ID on every span as the session.id attribute, by passing trace_attributes={"session.id": session_id} to the Strands Agent. Trace backends and both evaluation backends group a conversation’s turns on that attribute.
If you build your agent’s server on FastAPI 0.165 or later, turn off FastAPI’s own OpenTelemetry tracing. Otherwise it makes an HTTP server span with no session ID the root of every trace, above the agent’s invoke_agent span, and the open source evaluation runner finds no agent invocation to grade. The reference agent’s server turns it off:
# apps/reference/server.py, abridged app = FastAPI(..., telemetry={"tracing": False, "metrics": False, "logs": False})
The Agent resource sets the standard OpenTelemetry variables on the agent’s container. On the open source path, the result looks like the following:
env: - name: OTEL_SERVICE_NAME # the Agent's name; backends group by it value: research - name: OTEL_RESOURCE_ATTRIBUTES value: k8s.namespace.name=agents,k8s.deployment.name=research,eks.agent=research,aws.service.type=gen_ai_agent - name: OTEL_EXPORTER_OTLP_PROTOCOL value: http/protobuf - name: OTEL_EXPORTER_OTLP_ENDPOINT value: http://opentelemetry-collector.monitoring.svc.cluster.local:4318
eks.agent is the dimension that the dashboards and the CloudWatch metrics use to split by agent. aws.service.type=gen_ai_agent is the attribute that AgentCore online evaluation selects sessions on. The AWS Distro for OpenTelemetry sets it automatically, but the plain OpenTelemetry SDK doesn’t, so an agent without it is never graded. When observability is off, the resource sets OTEL_SDK_DISABLED=true instead of an endpoint, so an SDK doesn’t retry against localhost:4318.
Collector and scrape configuration
Both paths run the collector as a Deployment with an OTLP receiver on ports 4317 (gRPC) and 4318 (HTTP). They differ in where the collector exports.
Step 3: Verify telemetry
This step confirms the agent’s telemetry reaches the backend.
Step 4: View the dashboards
Clean up
To remove the telemetry layer, turn it off as described in Turn on a component later. Set the variable to false, apply with scripts/apply.sh, and run the bootstrap script with --sync --prune. Set enable_observability to false, and enable_langfuse too if you turned it on. Agents then export nothing.
Next steps
Evaluate agent output on Amazon EKS, which runs on the traces this layer collects.