Skip to content
All articles

Product5 min read

Alarms that open tickets

When a CloudWatch alarm fires or a sale gets declined, the problem should land in a queue that belongs to someone.

The call pipeline we run for a lead generation call center in the United States has plenty of places that can fail quietly. The Lambda that dispatches uploaded CSV files can start throwing errors. A transcription batch can fall behind. On the business side, a confirmer can decline a sale that an agent booked. When that happens a team lead needs to hear about it before the next shift makes the same mistake.

We started where most teams start, with a CloudWatch dashboard of metrics from the audio downloads Lambda and the transcription service. Dashboards are good at showing that something happened. They’re much worse at making sure a person did something about it. An alarm email to a shared inbox has the same problem. Everyone sees it and each person assumes someone else is already on it.

The pattern we settled on is simple to state. Anything that needs a human becomes a ticket in TrueTicket, our ticketing product, created through its API with an organization’s API key. The ticket’s category decides which resolver group receives it. A deduplication ID keeps one recurring problem from opening a new ticket every time it repeats.

flowchart LR
    A["CloudWatch alarm"] --> T["SNS alarms topic"]
    T --> L["Alarm notifications Lambda"]
    R["JSON report lands in S3"] --> RS["Report service Lambda"]
    D["Confirmer declines a sale"] --> CS["Calls service listener"]
    L --> TT["TrueTicket API"]
    RS --> TT
    CS --> TT
    TT --> G["Resolver group for the category"]

Alarms go through one topic

On the infrastructure side the monitoring stack defines a single SNS topic for alarms, with a Lambda subscribed to it that turns each notification into a ticket. The topic is the only thing an alarm needs to point at. Adding a new alarm to the ticket flow means setting that topic as its action, with no new integration code.

The Lambda runs from a container image in private subnets with a 60 second timeout. It has a reserved concurrency of ten. That reservation also caps it at ten concurrent runs, so a burst of alarms during an outage reaches the ticketing API at most ten requests at a time. It authenticates to TrueTicket with an API key that belongs to the call center’s organization, passed in through the stage configuration rather than baked into the image.

The first alarm we wrote in the CDK watches the dispatch Lambda. One error in a five-minute window is enough to fire it. Missing data counts as not breaching, so a quiet night with no uploads doesn’t page anyone. A threshold that sensitive is only useful if someone owns what it finds, which is the whole argument for sending alarms like it to a ticket queue instead of an inbox.

Declined sales are tickets too

The business events matter at least as much as the infrastructure ones. When a confirmer sets a decline reason on a sale, the calls service publishes an event with the decline status. Cancel and reset declines (along with the combined reset-cancel status) open a ticket. Other statuses don’t.

A Spring event listener in the calls service handles it. It loads the call and the sale, builds a title from the status and the agent’s name and writes a body with what a team lead needs in order to act: the decline status, the agent, who declined it, the campaign and the reason the confirmer typed. The category comes from a prefix on the agent’s name, so each group of agents gets its own category, with a default category for names that don’t match any prefix. Severity is fixed at 4.

Six connected steps from a confirmer declining a sale, through the calls service event and status filter, to a ticket created in TrueTicket with the sale ID as deduplication key
A decline becomes a ticket in the agent's team category, deduplicated by sale ID.
The sale ID doubles as the deduplication ID. If the event fires twice for the same sale, TrueTicket answers with a 409 and the listener counts it on a deduplicated metric instead of treating it as an error. Ticket creation can't break the decline itself either. Any exception is logged and counted on a sales.decline.ticket.error metric while the decline flow carries on, so the worst case of a TrueTicket outage is a missing ticket and a metric that tells us so.

The request the listener sends is short:

An HTTP request to the TrueTicket create endpoint with an API key header and a JSON body holding category, severity, title, body and deduplication ID, followed by a 409 Conflict response line
The calls service sends an organization API key and the sale ID as deduplication key.
## What TrueTicket does with a machine caller

On the TrueTicket side, a request with an X-API-Key header and no user session goes through an API key filter. The key is validated against our API key service and mapped to an organization. The request then runs as a SYSTEM principal for that organization, with the organization set in the tenant context so row-level security applies to it like any other caller. A machine caller gets no special path into the database.

Deduplication is scoped to the organization and to open tickets. Before creating a ticket, the service looks for one in the same organization with the same deduplication ID and any status other than resolved. If it finds one, it returns 409 with the existing ticket’s ID in the error details. Once a person resolves that ticket, the next occurrence opens a fresh one. That’s the behavior we want for alarms in particular. A flapping alarm produces one open ticket instead of a page of them, while a problem that comes back after it was fixed gets a new ticket rather than reopening something everyone had already closed in their heads.

Deduplication started with alarm tickets on TrueTicket’s external endpoint. Ten days later we moved it to the regular create path, which is the path the API key filter covers and the one the calls service uses.

The external endpoint is still there for a different job. It creates tickets on behalf of someone outside the organization’s user list. It accepts either an API key or a one-time client secret, takes the requester’s email and a category name, provisions the requester as a client user if they don’t exist yet and emails them a magic link so they can follow the ticket without an account. A declined sale has no outside requester to email, so the calls service sends a category ID to the regular endpoint instead.

Reports that open tickets on their own schedule

A third source is slower than the other two. Reports land in an S3 bucket as JSON files that expire after 180 days. Each new file triggers a report service Lambda that carries its own TrueTicket key. It also has read and write access to an underperformance table in DynamoDB keyed by a deduplication ID. Alarms and declines happen one at a time, while a report covers a period. The table keyed by deduplication ID is how the report path keeps track of underperformance findings from one run to the next.

What makes it hold up

None of the pieces is complicated. The decline listener sends a key that comes from the thing it reports on (the sale ID), so duplicates collapse on the server instead of in the client. Any new source should follow the same rule. Every ticket gets a category and categories point at resolver groups, which is what turns “someone should look at this” into a name in a queue. Ticket creation never sits in the critical path of the business flow that triggered it. The listener counts what happened to each request as created, deduplicated or failed, so a silent failure in the ticketing path still shows up as a number.

The dashboard didn’t go away. It’s still where we look once a ticket says something is wrong. What changed is that a problem no longer depends on someone happening to open it.

Start with a free consultation

Tell us which process you want to fix. We’ll come back with a plain assessment of what data or AI can do for it and what it would take.