Infraspec
Back to the hackathon

AI debugging · Sreyas P Pradeep

From Alert to Diagnosis in One Chat Thread: Building an AI Alert Debugger

Sujeet and I built Alert Debugger at Infraspec's internal hackathon, a service that starts investigating an alert as soon as it fires, so the on-call engineer starts with answers instead of questions.

The idea is simple. When SigNoz fires an alert, it still reaches our usual alerts channel, as before. Alert Debugger receives the same alert separately and posts its own copy to a dedicated Google Chat channel, demo-alert. Minutes later, a reply appears under that copy, in the same thread: what is affected, the likely cause, the evidence, a suggested fix, and what the AI couldn't confirm.

Getting there took more decisions than we expected. This post walks through the version we built during the hackathon: how it works, why we made the choices we did and what we learned. The project has grown since, and we cover what changed at the end.

Understanding the problem first

We've watched this play out many times. An alert fires at 2 a.m. The on-call engineer wakes up, opens a laptop and starts the same routine as every other night. Which namespace is this? Are the pods restarting? What do the events say? What do the logs show around the time it started? What changed?

None of that is hard. It's just slow, and it happens at the worst possible time. The first fifteen minutes of almost every incident go to collecting facts before any real thinking begins.

We already had a prototype that tried to help. A Kubernetes CronJob ran every hour, picked one firing alert, asked an AI agent to investigate it and saved the result as a page in our wiki. It worked, but it had the wrong shape:

  • An alert could wait up to an hour for an investigation.
  • Each run handled only one alert, to keep AI spend bounded. Three alerts firing together took three hours to clear.
  • The answer landed on a wiki page that nobody on call was looking at.

So the new version had to start the moment the alert fires, put the answer in Google Chat, where on-call engineers already work, and produce something people could trust at 2 a.m.

The one thing we didn't want to build

The easy version of this project would be to send the alert to an AI and post whatever it outputs. You'd get confident, well-written paragraphs, and you'd have no idea which parts were checked and which were guessed.

A wrong answer at 2 a.m. is worse than no answer, because people act on it. So before writing any code, we agreed on a few rules:

  • Look, don't touch. The AI can only read. Nothing it does may change the cluster, and it must never claim a fix was applied.
  • Alerts are data, not instructions. Alert text is free text written by whoever set up the rule. If it says "ignore your instructions", that's just a string.
  • Never guess where the problem is. The AI must find the affected namespace and workload from labels or evidence, or say it couldn't.
  • A failed check is missing evidence, not proof. If a query fails with a permission error, that doesn't mean the resource doesn't exist.
  • "We don't know" is a valid answer. Every report has a section for what the AI couldn't confirm.
  • A human decides. The AI does the first pass. An engineer reads it and acts.

Who does what: the alarm, the dispatcher and the detective

The way we like to explain it: think of an emergency call. There's an alarm, a dispatcher, a detective with a toolkit, and the place where the answers land.

The alert-debugger pod: a webhook handler, a SQLite database, an investigation worker and a delivery worker, with SigNoz, HolmesGPT, read-only tools and Google Chat around it
The alert-debugger pod: one replica, Python standard library
  • SigNoz is the alarm. It's our observability platform. It evaluates alert rules over metrics, logs and traces, and sends a webhook when an alert fires or resolves.
  • Alert Debugger is the dispatcher. It receives the alert, decides whether it needs an investigation and hands it to the detective. Its delivery worker then makes two calls to the Google Chat webhook, one to post the alert, which starts the thread, and one to post the investigation as a reply in that thread. A third call adds a short reply when the alert resolves. It never investigates anything itself.
  • HolmesGPT is the detective. It's an open-source AI troubleshooting agent running inside our cluster. Given an alert, it decides what to check, runs its read-only tools and writes up what it found, along with the list of every tool call it made.
  • The read-only tools are the detective's toolkit. Reading Kubernetes resources, events and logs, querying SigNoz, and reading code and commits on GitHub.
  • The LLM is the detective's brain. HolmesGPT uses a Claude model to decide what to look at and to write the analysis.
  • Google Chat is where the answers land. Alert Debugger posts each alert to the demo-alert channel in its own thread, and everything about that alert stays in it.

Following one alert through

Let's say an alert fires for a service in our cluster. Here's what happens next:

  1. The alarm goes off. SigNoz sends the alert to Alert Debugger's webhook, with its name, severity, labels, description, start time and a link back to SigNoz.
  2. Write it down first. Alert Debugger checks that the request came from SigNoz (using a shared webhook password) and that it's a valid alert, saves it to its database, and only then replies "got it".
  3. Open a thread. It posts its own copy of the alert to the demo-alert channel in Google Chat, ending with "Investigation will follow in this thread."
  4. Investigate. A background worker sends HolmesGPT the alert and our instructions. There is only one investigation worker, so if another alert is already being investigated, this one waits its turn in the queue. HolmesGPT works out the namespace, checks the pods, events and logs, and looks at SigNoz around the start time. For a "no data" alert, it looks at the telemetry path itself instead.
  5. Check the checks. Alert Debugger goes through every tool call HolmesGPT made and flags any that failed.
  6. Reply in the thread. The report is posted as a reply under Alert Debugger's copy of the alert, using the five headings our instructions ask for: Affected resources, Likely cause and confidence, Evidence, Suggested fix and Uncertainty / missing evidence.
  7. Close the loop. When SigNoz reports the alert as resolved, a short "resolved" reply lands in the same thread.
Sequence diagram of one alert: intake, open thread, investigate, report and resolve, across SigNoz, the webhook, SQLite, the workers, HolmesGPT and Google Chat
One alert, end to end: intake, open thread, investigate, report, resolve

The on-call engineer ends up with one thread per incident: what fired, what the AI found, and when it resolved. And if the investigation fails three times in a row, the thread says so plainly instead of going quiet.

"But what if the AI gets it wrong?"

It's the first question everyone asks, and it's the right one.

Our answer starts with the rules above, written into the instructions HolmesGPT gets with every alert. But instructions are only a request. So the important ones are also enforced in code, where the AI can't talk its way around them:

  • Failed evidence is flagged. Alert Debugger inspects every tool call, including nested errors and messages like "forbidden" or "permission denied". If anything failed, the report opens with "Evidence incomplete; failed queries: ...". A confident answer built on a failed query should look different from one built on real data.
  • The AI can't page the whole team. Alert and AI text are cleaned so they can't produce Chat mentions that notify everyone in the space, even if an alert was written to try.
  • Reports have a fixed size. Every message has a length cap, and if a report is shortened, it says so.
  • The service holds almost nothing. Alert Debugger has no Kubernetes credentials and no AI keys. It holds a webhook password and the Chat URL. Only HolmesGPT's read-only tools touch the cluster, and that isn't left to the AI's good behaviour. HolmesGPT's Kubernetes account can only get, list and watch resources, and the tools that could change things (running commands, Helm, bash, and GitHub's branch, push and pull-request actions) are switched off.

The decisions behind it

A few decisions shaped everything else. For each, here's what we chose, why, and what it cost us.

React, don't poll

The hourly schedule was the root of the delay, so we flipped it around. SigNoz pushes each alert to Alert Debugger the moment it fires. An investigation can start within seconds instead of waiting for the next hour, as long as the investigation worker is free.

The cost was a safety net. If SigNoz gives up retrying before we accept an alert, that alert is lost. We considered keeping the old poller as a backup, but two systems would have needed to deduplicate against each other. We chose one simple path and documented that alerts can be lost this way.

Build a small dispatcher, not a platform

We looked at the Holmes Operator, which can react to alerts by itself. At the time it was alpha and couldn't post to Google Chat, so we would have written the SigNoz and Chat glue anyway. Instead, we wrote one Python file of under 700 lines, using only the standard library: no web framework, no third-party packages. Fewer moving parts meant faster review and nothing extra to patch.

Write it down before saying "got it"

An investigation takes minutes, but SigNoz expects a reply in seconds. So the webhook does almost nothing, it validates the alert, saves it to SQLite, and only then answers SigNoz's webhook request with an HTTP 202 Accepted response. This is a reply to SigNoz, not a Chat message. Because the reply comes after the save, a crash a second later loses nothing. If the database is unavailable, the webhook returns an error and SigNoz tries again.

We run exactly one copy, with the database on a persistent disk. At a few alerts an hour, one process with a local database is far easier to reason about than a message queue plus a separate database. The cost is no horizontal scaling and a gap during each deploy. The database sits on a disk that can attach to only one pod, and two pods sharing one SQLite file could pick up the same alert twice, so the old pod has to stop before the new one starts. Alerts sent in that gap rely on SigNoz retrying them.

Keep investigating and delivering apart

There are two background workers. One runs investigations. The other sends Chat messages from a queue in the database.

This one matters more than it looks. If Chat is down or its URL is wrong, the finished report waits in the database and is retried. HolmesGPT is never called again, so a Chat outage never costs a second AI investigation. The cost is that delivery isn't exactly-once, if Chat accepts a message but the reply gets lost, the retry can post it twice, though always in the same thread.

Investigate each alert once

SigNoz repeats itself. It re-sends firing alerts and later sends a resolved notice. Without care, every repeat would start a new, paid investigation. So Alert Debugger groups notifications into episodes, identified by the alert's fingerprint plus the time it started.

Flowchart of episode handling: a firing for a new episode queues an investigation, a duplicate does nothing, a resolved notice marks the episode resolved, and an unknown resolved notice is tombstoned
Count episodes, not notifications: a late "firing" for a tombstoned episode is ignored

A resolved notice for an episode we never saw is kept as a "tombstone", so a late firing notice can't bring it back to life. The cost is that we never delete old episodes automatically, so the disk needs watching.

One thread per alert

Our first version posted each investigation as its own Chat message. In a busy space, it was hard to tell which report belonged to which alert. So now every episode gets its own thread, keyed by its episode ID. A report is only sent after its opening message has been delivered, and if someone deletes the thread, the reply fails instead of appearing as a stray message somewhere else. That's also why Alert Debugger posts its own copy of each alert instead of replying to the one in our usual alerts channel: SigNoz's own Chat messages have no shared thread key that another service could reply to.

One investigation at a time

A single investigation worker was the simplest way to cap how much AI spend can happen at once. Each alert gets at most three attempts and fifteen minutes per attempt. The cost is speed during an alert storm, when alerts wait their turn. It also doesn't cap total daily spend, so the AI provider's spending limit stayed our real hard limit.

What we learned along the way

A few moments stand out.

A dry run isn't free. The old poller had a DRY_RUN switch that skipped saving to the wiki. It still asked the AI to investigate, which is the part that costs money. The only real "spend nothing" switch was to stop the job, and the provider's spending limit was the only control nothing in our cluster could get around.

Alerts don't always say where the problem is. Our SigNoz alerts carry no namespace label, so finding the namespace had to become the AI's first job.

A successful call isn't a successful diagnosis. HolmesGPT can return a perfectly good HTTP response even when some of its checks failed underneath. Treat a failed query as "nothing found" and you get a confident, wrong answer.

Test alerts aren't real alerts. While testing, every "view rule" link in our messages opened an error page in SigNoz. It turned out SigNoz test notifications put the rule's name where real alerts put its ID. The fix was small: link to the rule list when the ID isn't a real ID. We only found it by running the whole path end to end.

Error messages can leak secrets. A Google Chat webhook URL contains its own key, and an HTTP error can include the URL. So we log only the type of error and its status code, never its text.

Retries can cost money twice. If the service restarts in the middle of an investigation, the retry may pay for the same work again. We accepted that for a hackathon, and wrote it down.

Writing down the limits saves time. We listed everything the system does not guarantee in the README: not exactly-once, no polling backup. Reviews went faster, because nobody had to discover the edge cases.

What we're taking away

  • Make the front door durable and dumb. Save first, reply fast, and do everything else in the background.
  • Don't let failures in one place cost money in another. Keeping delivery separate from investigation meant Chat problems never triggered a second AI run.
  • Count episodes, not notifications. Otherwise your alerting system's retries become your AI bill.
  • Put the answer where people already work. A Chat thread beats a perfect document nobody opens.
  • Guard the AI in the prompt and in code. The prompt asks; the code makes sure.
  • "We don't know" beats a guess. A report that admits what it couldn't check is one people can trust.

The hackathon version was deliberately small: one file, one database, one investigation at a time. Since then, it has grown to run investigations in parallel, cap daily spend, and check every piece of evidence in a report against the actual tool output. But the core idea hasn't changed: let the AI do the first fifteen minutes, and keep a human in charge of what happens next.

References

If you want to dig into the pieces we used:

More from the hackathon