What Observability Stack Do AI Coding Agents Need?

An observability stack for AI coding agents needs queryable telemetry APIs, MCP tool access, correlated signals, scoped permissions, and redaction before model context.

An isometric coding-agent terminal querying logs, traces and metrics through an MCP gateway into a guarded telemetry backend

Contents

An observability stack for AI coding agents needs more than a dashboard wall with an API key attached. An agent needs production telemetry it can query safely, join across signals, and cite back to a human without seeing more data than the incident requires.

The short version: expose production telemetry through queryable APIs and Model Context Protocol (MCP), keep metrics, logs, traces, alerts and deploy context correlated, start read-only, and redact raw payloads before they become model-visible context.

This post is about telemetry an agent consumes while debugging or verifying code. It is separate from monitoring the agent’s own runs, token use and tool calls. If you are building or running MCP servers, our guide to MCP server monitoring covers that path.

What observability stack should AI coding agents use?

AI coding agents should use an observability stack with five layers:

  1. Queryable telemetry APIs for metrics, logs, traces, alerts, profiles and change events.
  2. MCP or an equivalent tool layer that turns those APIs into named, schema-bound tools.
  3. Correlated signals so a service, trace ID, deployment, log pattern and metric label point to the same incident window.
  4. Scoped permissions that default to read-only investigation and require approval for writes.
  5. Payload controls that keep secrets, raw request bodies and full transcripts out of model context by default.

That answer matters because an agent does not debug the way an engineer does. A human can glance at a dashboard, notice a strange panel, click into a trace and mentally reject irrelevant lines. An agent needs the system to do more boundary work before the model responds. The tool name, time window, typed result and evidence limit should all be explicit.

A good agent answer has three parts: confirmed evidence, plausible causes and missing evidence. The observability stack has to provide all three. Snippets alone let the model smooth over gaps. Dashboards alone force the agent to infer the underlying queries. Disconnected signals can turn unrelated facts into a convincing story.

Dashboards are the wrong primary interface for agents

Dashboards remain the right interface for humans. During an incident, an SRE wants a stable view they can scan, annotate and share. After the incident, dashboards become review material for an RCA or a rollout decision.

Agents need a different primary interface. They need bounded questions and structured answers:

  • “Which exceptions appeared for checkout-api between 14:00 and 14:30 UTC?”
  • “Which trace shows the slowest failing request in that window?”
  • “Did latency, error rate or dependency throughput change after deploy 2026.12.03-7?”
  • “Which log templates increased versus the previous equal-duration window?”

Each question maps to a tool call. The tool call has inputs, limits and an output shape the model can reason over. That is much safer than asking an agent to browse a dashboard screenshot or scrape a chart.

The dashboard still has a role. When the agent finds something important, it should return evidence links or create a draft view for a human to inspect. The dashboard is the review surface. The tool result is the agent’s working memory.

Layer 1: queryable telemetry APIs

The base layer is boring and non-negotiable: the observability backend must expose telemetry through APIs that can be called by software, not only through a UI.

For an incident or post-deploy check, the agent needs at least these read paths:

SignalWhat the agent asksWhy it matters
MetricsError rate, latency, throughput, saturation and deployment markersMetrics show that behavior changed and bound the time window.
LogsError lines, templates, counts and sampled raw recordsLogs explain failure text and code paths that metrics compress away.
TracesWaterfalls, span attributes, dependency calls and slow pathsTraces show what the request did across services.
AlertsFiring rules, severity, ownership and recent stateAlerts show what the system already thinks is wrong.
ChangesDeploys, config updates and feature flagsChanges help compare “before” and “after” without guessing.
ProfilesHot functions and CPU or memory hotspotsProfiles help when traces say “slow” but not “where CPU went.”

The API should make uncertainty explicit. Empty results need to say whether nothing matched, the service name was wrong, the time window was too narrow, or the signal is not instrumented. A partial result should say it is partial. A comparison result should separate correlation from cause.

This is where high cardinality becomes practical context for agents. If labels such as service.version, tenant, region, feature_flag or deployment.environment.name are dropped, the agent loses the filters that turn a broad symptom into a narrow explanation. Last9 has no hard limit on cardinality; 20M series per metric per day by default, raised on request. Use that headroom for incident dimensions that help root cause, and keep unbounded IDs out of metrics unless a query needs them.

Layer 2: MCP as the production telemetry interface

MCP is a protocol for connecting AI clients to tools and data sources. For observability, the practical job is simple: put a typed tool layer between the agent and the telemetry backend.

The Last9 MCP docs describe the shape. Last9 MCP exposes tools to query logs, traces, metrics, alerts and dashboards; inspect dependencies; review and author alerts; and manage dashboards. Your AI client decides which tools to call and uses the results to answer the user’s question.

For developers in an IDE, the hosted MCP endpoint uses OAuth. For bots, services and CI workflows, Last9 MCP for AI agents uses an MCP-type Client token sent as Authorization: Bearer <token>. That split matters:

  • OAuth fits a human session where the developer is present and the IDE can ask for confirmation.
  • Bearer tokens fit unattended workflows where the token identity, tool allowlist and audit path must be explicit.

MCP does not make an agent safe by itself. It gives you a place to define tool names, schemas, annotations, authentication and result limits. The safety comes from how you configure those boundaries.

A useful tool result should include the evidence and the limits around it. For example, an exception query should return the service, environment, window, exception groups, counts and sample trace IDs. A trace waterfall should return a bounded span tree and timing, not the entire universe of traces. A change-impact tool should return “regression,” “no significant change” or “insufficient data,” not just a chart link.

Layer 3: correlated signals across stores

An agent cannot reliably investigate from disconnected systems. If traces live in one place, logs in another, metrics in a third and deploy data in a fourth, the model has to infer joins from names and timestamps. That is fragile even when a human does it; it is worse when a model does it.

The stack should preserve common join keys:

  • service.name
  • deployment.environment.name
  • service.version
  • trace ID and span ID
  • route, endpoint or operation name
  • region, cluster and namespace
  • deploy or change-event ID
  • alert rule and owner metadata

The signals can live in more than one database. What matters is that the questions are joinable at the tool layer. When an alert fires for checkout-api, the agent should be able to ask for recent deploys, slow traces, error logs and dependency metrics for the same service and window without renaming the world at every step.

OpenTelemetry helps here because resource attributes travel across signals when you set them consistently. For release checks, service.version is the difference between “latency rose sometime today” and “latency rose on the new build.” For incident checks, deployment.environment.name keeps staging evidence out of a production report.

Telemetry still has limits. A trace can show an extra database call. It cannot prove the business logic is correct. A log line can show an exception. It cannot prove the absence of a security flaw. A deployment near the incident window is a clue, not a cause. Ask the agent to report those limits in the answer.

Layer 4: permissions and tool boundaries

Keep the default workflow read-only. An agent investigating production should read evidence before it can change anything.

A safe starting policy looks like this:

  • Allow service discovery, alerts, exceptions, logs, traces, metrics, profiles, dependencies, dashboards and change events.
  • Require approval for dashboard edits, alert lifecycle changes, notification-channel changes and drop-rule creation.
  • Deny shell access, deploy tools, secret stores, unrestricted cloud consoles, production databases and broad export tools.

Our guide to AI agent permissions for incident investigation covers this boundary in depth. The short version: prompts are not access control. Put the boundary in the MCP server, the client allowlist, the token scope and the audit trail.

For Last9 MCP, the documented controls include read-only filtering for self-hosted servers with --read-only or LAST9_MCP_READ_ONLY=true, tool annotations such as readOnlyHint, token scopes for write and delete paths, and workflow-specific allowlists. Write tools exist for operational objects such as dashboards, drop rules, alerts and notification channels, so treat them as production changes.

That does not mean writes are never useful. A post-incident agent might draft a dashboard panel or propose an alert rule. The difference is that a human approves the change, the tool is named, the credential is scoped, and the audit record shows what happened.

Layer 5: safe payload and transcript handling

The agent should not see every byte your observability stack stores. Production telemetry can contain request bodies, authorization headers, customer identifiers, stack traces, database fragments and copied .env output. Once those land in a transcript, they may be stored outside the systems you normally audit.

Use a simple default: metadata on, raw payloads off.

Record fields such as agent name, run ID, tool name, status, duration, retry count, result count, trace ID, log fingerprint, model, token count and policy decision. Keep full prompts, completions, tool arguments and tool results out by default.

When the agent needs payloads, narrow the scope:

  • one incident or run ID;
  • one service and environment;
  • one absolute time window;
  • capped raw log lines or trace attributes;
  • redaction before export;
  • a reason and expiry for payload capture.

Our LLM security guide for keeping secrets out of coding-agent transcripts goes deeper on this, and the AI agent permissions guide covers redaction at the tool boundary. For the observability stack, the operational requirement is that redaction and drop rules run before sensitive content becomes model-visible context or durable telemetry.

Reference architecture for agent access to production telemetry

A practical architecture has two paths: a read path for investigation and a collection path for safe telemetry.

Reference architecture showing a coding agent calling MCP tools through a permission boundary to read a telemetry backend, while applications send OpenTelemetry signals through a Collector policy layer before the evidence store. A separate approval gate handles writes such as dashboards, alerts and drop rules.
Keep the agent on a read-first path. Writes move through a separate approval gate, while collected telemetry is redacted or transformed before export.

The read path works like this:

  1. The user or workflow supplies a question, service, environment and absolute time window.
  2. The agent calls MCP tools through an allowlist.
  3. The permission boundary checks token scope, tool annotations and query limits.
  4. The telemetry backend returns bounded results with evidence links and missing-data states.
  5. The agent reports confirmed findings, possible causes and missing evidence.

The collection path works separately:

  1. Applications emit OpenTelemetry traces, metrics and logs with consistent resource attributes.
  2. The Collector or another policy layer redacts, drops or transforms sensitive fields before export.
  3. The backend stores correlated evidence for the same services, versions and environments the agent will query later.

Keep those two paths separate. A stored signal is not automatically safe model context. A dashboard proposal is not permission to save a dashboard without approval.

Roll out the stack without production superpowers

Start with one useful read-only workflow. A good first target is post-deploy verification for one service:

  • service: checkout-api
  • environment: production
  • window: 30 minutes after deploy
  • tools: change events, service metrics, exceptions, trace waterfall, log templates
  • output: regression verdict, evidence links, missing data

Keep the first workflow narrow. Record which tools the agent used, which it skipped, which calls failed and which evidence it could not verify. That log teaches you more than a broad demo prompt.

Then add workflows in order of risk:

  1. Read-only IDE investigation. A developer asks what changed for one service and opens the evidence manually.
  2. Read-only incident assistant. An on-call bot summarizes evidence inside an incident thread with a fixed time window.
  3. Post-deploy checker. CI or release automation runs the same comparison after a rollout.
  4. Draft-only writes. The agent creates disabled alert drafts or dashboard previews, with human approval before activation.
  5. Approved remediation. A separate workflow gets one named write action, with rollback and audit.

If you cannot explain what the agent is allowed to call, it has too much access. If the agent cannot explain which evidence is missing, the stack is not returning enough structure.

Where to start

Start by connecting the read path before you add write paths. The Last9 MCP page explains the product surface, and the MCP docs cover IDE setup. For a service or bot, use Last9 MCP for AI agents and keep the initial allowlist small.

Then make the telemetry joinable. Set service.name, deployment.environment.name and service.version consistently. Emit deploy or change events. Keep trace IDs available in logs. Preserve labels that help incident filtering, but do not copy unbounded IDs into every metric without a reason.

Finally, decide what the agent must never see. Write that policy before a production incident forces the question. Secrets, long-lived credentials, raw request bodies and full transcripts should not become the default debugging path.

Aim for an agent that can gather the right evidence, inside the right boundary, fast enough for an engineer to trust the next step.

FAQ

What observability stack should AI coding agents use?

AI coding agents should use an observability stack with queryable APIs for metrics, logs, traces, alerts and change events; an MCP layer that exposes those APIs as named tools; correlation across services, traces, logs, metrics and deploys; scoped read access by default; and redaction before production context reaches the model. Dashboards still matter for humans, but agents need bounded tool results they can cite.

How should an AI agent access production telemetry?

An AI agent should access production telemetry through a brokered tool layer such as MCP, not through broad shell, database or cloud-console access. The request should carry a service, environment and absolute time window. The tool layer should enforce token scope, result limits, read-only defaults and audit records, then return evidence with missing-data states rather than a vague summary.

Should coding agents have write access to observability tools?

Start with no write access. Let the agent read telemetry, assemble evidence and propose the next action. If a workflow needs writes, expose only named tools, such as dashboard edits or alert drafts, behind approval and separate credentials. Treat drop rules and alert changes as production changes, not as chat conveniences.

What telemetry should stay out of an AI agent transcript?

Keep long-lived secrets, authorization headers, raw request bodies, full prompts, completions, tool arguments and tool results out of transcripts by default. Record metadata such as tool name, duration, status, result count, trace ID, log fingerprint, policy decision and evidence links. Enable raw payload capture only for a narrow, time-bound investigation with redaction before export.

Last9 logo and enter key

See Last9 in action.

OpenTelemetry · Prometheus

Just update your config. Start seeing data on Last9 in seconds.

Datadog · New Relic · Others

We've got you covered. Bring over your dashboards & alerts in one click.

Built on Open Standards

100+ integrations. OTel native, works with your existing stack.