{"slug": "give-claude-code-the-production-logs-it-needs-to-investigate-a-bug", "title": "Give Claude Code the production logs it needs to investigate a bug", "summary": "SigNoz published a walkthrough showing how to connect Claude Code to SigNoz Cloud over the Model Context Protocol (MCP) so the agent can query production logs, traces and metrics and compare them against deployed application code. In a test on a public Python FastAPI demo that returns HTTP 500 at `/exception`, Claude retrieved five error logs containing `ValueError`, linked one to a failed `GET /exception` trace, and matched the logged stack trace to `raise ValueError(\"sadness\")`; it also reported 10 successful requests in the earlier window and 10 successes plus five failures in the later one. SigNoz advises using a read-only service account, supplying the service name, source commit and UTC time windows, and checking the agent's explanation against the evidence before acting.", "body_md": "# Give Claude Code the production logs it needs to investigate a bug\n\nClaude Code can investigate a failure by querying logs, traces and historical metrics stored in [SigNoz Cloud](https://signoz.io/log-management/), then comparing that evidence with the application code. The connection uses Model Context Protocol (MCP), which gives Claude tools to query the data.\n\nTo try this, follow the [Claude Code configuration steps](https://signoz.io/docs/ai/signoz-mcp-server/?client=cloud-claude-code#claude-code) using a read-only service account. Give Claude access to the relevant application code as well, so it can relate what it finds in the logs to the code that produced them. For cloud sessions, see the [Claude Code cloud setup guide](https://code.claude.com/docs/en/claude-code-on-the-web/).\n\nOnce connected, adapt this prompt to your service and incident window. Make the deployed source version available in the workspace:\n\n```\nUsing SigNoz, investigate errors for [service] between [start and end, UTC].\nRetrieve relevant logs and related traces where available, then compare\nthe evidence with the code deployed at [commit or release]. Cite the\nrecords supporting your explanation and identify any missing evidence.\nDo not make changes.\n```\n\n## Investigate an example failure\n\nFor example, we ran a [public Python app](https://github.com/SigNoz/examples/tree/b811d26ab91208d6c3ef884b9497e4f38489737d/fastapi/opentelemetry-fastapi-demo) that deliberately returns a server error (HTTP 500) when called at `/exception`. We sent its logs, traces and metrics to SigNoz Cloud.\n\nWe asked Claude to investigate the error using the logs and a failed trace, and to compare request counts before and during the failure. To help it find the right data and code, we gave it the service name, source commit and two time windows in UTC. The first window covered successful requests; the second included requests to `/exception`.\n\n## Check what the agent found\n\nClaude retrieved five error logs containing `ValueError` and linked one to a failed `GET /exception` trace. The logged stack trace pointed to `raise ValueError(\"sadness\")` in the sample, which matched the known failure.\n\nThe logs and trace explain an individual failure. To see how it fit into the wider request activity, Claude also compared the request counts for the two periods. Its report showed 10 successful requests in the earlier period, and 10 successes and five failures in the later period.\n\nFor your own incident, make sure Claude can access the source version that was deployed and the logs, traces and metrics for the relevant period. Check its explanation against the evidence, and ask it to identify any missing information before you act on it.\n\nSee [natural-language log exploration](https://signoz.io/docs/ai/use-cases/natural-language-log-exploration/) for more query examples.", "url": "https://wpnews.pro/news/give-claude-code-the-production-logs-it-needs-to-investigate-a-bug", "canonical_source": "https://signoz.io/faqs/claude-code-production-logs-debugging", "published_at": "2026-11-23 00:00:00+00:00", "updated_at": "2026-11-23 11:15:55.279177+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "agent-protocols", "mlops"], "entities": ["Claude Code", "SigNoz", "SigNoz Cloud", "Model Context Protocol", "FastAPI", "Anthropic"], "also_reported_by": [], "takeaway": "Connecting Claude Code to SigNoz Cloud via MCP with a read-only service account and supplying the service name, deployed commit and two UTC time windows let the agent pull five ValueError logs, link one to a failed GET /exception trace and compare 10 successful requests against 10 successes plus fiv", "recommendation": {"advice": "Give the agent read-only log and trace access plus the deployed commit and explicit UTC incident windows, then require it to cite supporting records and list missing evidence before you act.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/give-claude-code-the-production-logs-it-needs-to-investigate-a-bug", "markdown": "https://wpnews.pro/news/give-claude-code-the-production-logs-it-needs-to-investigate-a-bug.md", "text": "https://wpnews.pro/news/give-claude-code-the-production-logs-it-needs-to-investigate-a-bug.txt", "jsonld": "https://wpnews.pro/news/give-claude-code-the-production-logs-it-needs-to-investigate-a-bug.jsonld"}}