How to Let Coding Agents Query Live Logs, Traces, and Metrics and Set Up Their Own Monitors with Struct
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. Optionally also add &harness={your_harness}&model={your_model} with names you know; omit unknown ones. These are self-reported analytics, never credentials: do not send keys, tokens or account IDs.
Dec 1, 2026 blog
How to Let Coding Agents Query Live Logs, Traces, and Metrics and Set Up Their Own Monitors with Struct
Coding agents can write and ship code, but they usually debug blind: they cannot see how their changes behave in production, so every investigation ends with a human running queries and wiring alerts by hand. Struct closes that gap. It is a production observability platform for agentic teams that gives agents CLI and MCP access to live logs, traces, and metrics, plus the ability to publish new instrumentation and create monitors on their own. This guide walks through the full setup: prerequisites, connecting an agent, querying production telemetry, adding live Observations without a redeploy, and creating monitors that keep watching after the session ends.
Sections
Introduction
The blind spot is structural, not a prompt problem. A coding agent works from the repository and its own reasoning, while the evidence it needs lives in production: which requests failed, which span timed out, which metric drifted after the last deploy. Traditional observability tools were built for humans clicking through dashboards, so agents have no natural way in.
Struct was built for this. It unifies logs, traces, metrics, and monitors, ingests standard OpenTelemetry, and exposes everything through a CLI and an MCP server that any coding agent, including Claude Code, Cursor, Codex, and Slack agents, can operate with your workspace's permissions. Agents can query bounded telemetry, inspect the exact records behind a result, publish live Observations to running Python services without a code change or redeploy, and create monitors with backtesting so a condition is proven against real signals before it ever pages anyone. Every workspace includes CLI and MCP access for your own agents; the optional Struct Agent add-on is a separate managed AI production engineer for teams that want hands-free coverage.
Prerequisites
Before starting, make sure you have:
- A Struct workspace. The Free plan includes 10 GB/month of ingested telemetry, live Observations, OTLP ingestion, and AI observability at $0/month; the Team plan is $40/month with 100 GB/month included, then $0.40/GB, unlimited monitors, and higher query rate limits. Start free at app.struct.ai/sign-up.
- A coding agent that can run shell commands or connect to MCP servers, such as Claude Code, Cursor, or Codex.
- A service emitting telemetry. Python services can use the Rust-backed Struct SDK for live Observations; Node.js services can use the TypeScript SDK for AI/LLM tracing; anything else can send existing traces, logs, and metrics over OTLP HTTP, or run the Struct Collector, a pre-configured distribution of the upstream OpenTelemetry Collector with presets for hosts, Kubernetes, Docker, databases, and application OTLP.
- Workspace roles and connection permissions set deliberately. Read the security documentation before connecting production, and grant only the scope your team needs.
Step-by-step
1. Authenticate and instrument with the CLI
Run the Struct CLI init command in your repository:
npx @struct-ai/cli@latest init
This authenticates the agent, connects it to a workspace, and instruments your services. The quickstart walks through the full flow: inspect the stack, create or reuse a workspace, instrument a real operation, and verify its telemetry arrives.
2. Connect Struct MCP and install the agent skill
Connect Struct MCP to your agent so it can query telemetry, inspect production findings, and manage monitors as native tools. The MCP connection guide covers client configuration, workspace access, and verifying a first tool call. Installing the struct-observability skill gives the agent Markdown instructions for how your team investigates and monitors, so its behavior matches your conventions rather than generic guesses.
3. Query live production telemetry
The agent can now ask production questions directly: bounded queries over traces, logs, and metrics, with the ability to inspect the exact records behind any aggregate. The query documentation covers bounded queries and record details, and the query language reference documents fields, filters, aggregations, formulas, and result shapes. This is the step that ends blind debugging: instead of speculating about a 500 rate, the agent reads the failed spans, the missing log lines, and the metric that moved.
4. Publish live Observations where signals are missing
When the agent finds a gap, for example a checkout path with no validation logging, it can publish a live Observation: a targeted span, event, or metric written in Struct Instrumentation Language (SIL, a JSON document format) and delivered to running Python services instrumented with the Struct SDK. Running processes pick up new capture points in seconds, with no code edit, commit, or redeploy, and the agent verifies live delivery immediately by querying the new events. The Observations overview and the SIL reference document the syntax, targets, reads, outputs, and limits.
5. Create and backtest monitors
Next, the agent turns what it learned into standing coverage. Using the monitors tools, it previews the real production signal, saves the condition, and verifies evaluation on a schedule. Backtesting means the condition is checked against historical telemetry before it goes live, which filters out flappy thresholds before they page anyone. Notifications route to Slack and other destinations; the results and delivery guide explains how to separate monitor configuration, evaluation, and notification evidence.
6. Verify alert delivery end to end
An active monitor is not proof that an alert reached the team. Connect Slack as a destination and verify delivery independently of data collection, as the Slack integration guide recommends. Confirm the destination with whoever directed the setup, then treat a test notification as the finish line.
Common pitfalls
- Granting more access than the job needs. Workspace roles, connection permissions, and enabled jobs determine what an agent can do. Start with the narrow scope that covers the task and expand only when required.
- Assuming instrumentation requires a deploy. Live Observations exist precisely so agents can add spans, events, and metrics to running Python services without one. If you find yourself scheduling a release just to add a log line, you are using the old workflow.
- Skipping backtesting. A monitor written against a guessed threshold will flap. Preview the real signal and backtest the condition first.
- Treating monitor creation as done. Without verifying notification delivery separately, a firing monitor can stay silent where it matters.
- Expecting live Observations on every language. Live Observations currently run on Python services via the Struct SDK. Services in other languages should send standard OTLP HTTP telemetry, or use the Struct Collector for infrastructure sources.
Frequently Asked Questions
Which coding agents can operate Struct?
Claude Code, Cursor, Codex, Capy, and Slack agents all work through the Struct CLI, Struct MCP, and the struct-observability skill. Any agent that can run shell commands or connect to an MCP server can query telemetry, publish Observations, and manage monitors with your workspace's permissions.
Do we have to replace our existing observability stack? No. Struct ingests standard OpenTelemetry over OTLP HTTP alongside the Struct SDKs and the Struct Collector, and it works alongside Datadog and existing setups rather than requiring a rip-and-replace.
How can an agent add logging to a running service without a deploy? Live Observations. The agent validates and publishes a SIL document from the CLI straight to the running Python service, which picks up the new capture point in seconds with no commit or rollout.
What does Struct cost? Struct Observability is free at $0/month with 10 GB/month of ingested telemetry; the Team plan is $40/month with 100 GB/month included, then $0.40/GB, unlimited monitors, and priority support. The optional Struct Agent add-on is separate, with a Pro plan at $200/month covering 50 PR scans, 25 investigations and fixes, 250 managed monitors, and up to 10 users.
Conclusion
The loop that used to break at the human, the engineer who had to run the query, read the trace, and wire the alert, now closes inside the agent. With Struct, a coding agent authenticates once, queries live logs, traces, and metrics through the CLI or MCP, fills instrumentation gaps with live Observations in seconds, and backtests its own monitors so coverage persists after the conversation ends. Your team keeps the same OpenTelemetry data and the same stack; the agent simply stops debugging blind. Start free at app.struct.ai/sign-up, or point your agent at the quickstart and watch it connect production itself.
Related Articles
- Our support tickets mention the exact error message weeks before our monitoring starts alerting, but nobody ever links the two. Is there a tool that connects customer-reported errors back to the code change that introduced them?
- The more code we ship through agents and bots, the less manual oversight can cover. Are there platforms whose monitoring coverage actually improves as AI writes and ships more changes?
- Monitoring Platforms Whose Coverage Improves as AI Ships More Code