Turn Grafana alerts into diagnosed issues and draft fix pull requests

Fernando Mendes wired Grafana alerts to a GitHub Actions job where Claude Code reads traces, logs and code, files a diagnosis issue and, for a divide-by-zero bug, opened a draft fix PR.

Done withClaude CodeinGrafanaGrafana CloudGitHub· Nov 11, 2026

What they did

Mendes built a proof of concept around a small .NET API that sends OpenTelemetry traces, metrics and logs to a free Grafana Cloud stack. A Grafana alert rule on 5xx errors calls a webhook that starts a GitHub Actions workflow. The workflow installs Claude Code and the official Grafana MCP server, then a shell script pulls the active alerts, skips ones already handled, and runs Claude Code headless on each new one. The agent gets a read-only Grafana service account and only the Grafana, read and edit tools, with no terminal. It is asked to query metrics, logs and traces around the alert time, find the stack trace in the code, make the smallest fix if the cause is clearly in the code, and end with a confidence score. The script, not the agent, opens the issue and, above a confidence threshold, a draft pull request.

How it went

In his test run an alert fired, the workflow picked it up, and the agent traced the errors to a division by zero and opened a draft PR with a fix for the team to review. In other test runs it only filed issues with the diagnosis. He says the payoff is that the investigation is already written up when a person looks, and that tokens are only spent when a new alert exists. He gives no timing or cost numbers, and the app was built to throw errors on purpose.

Worth knowing

It ran on a Claude Pro subscription token, so usage counts against that plan's limits. Set the alert to keep firing for about 15 minutes, or it can resolve before the workflow starts and the agent finds nothing. GitHub Actions must be allowed to create pull requests, and the script throws away any change the agent makes under .github.

Try it

With Claude Code· 4 parts to fill in

You are investigating a production alert for [my service] monitored in [Grafana or my observability tool]. Here is the alert: [alert JSON or name and start time]. Using the observability tools, pull the related metrics, error logs and traces from a window of [15 minutes] around the start time and correlate them by trace id. Find the exception and the matching file and line in this repository. If the evidence clearly points to a code defect, make the smallest possible fix and add or adjust a unit test. If the cause is infrastructure, data or unclear, change nothing. Do not touch CI config, secrets or dependencies. Reply in Markdown with a summary, evidence, likely cause, code involved, what you changed and why, how to validate, and a confidence score from 0 to 100. Stop there; a person reviews before anything merges.

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related