My mail pipeline had been running for a while: Graph notifications flowing through an Event Grid partner topic into an Azure Function, dead-lettering enabled to a blob container. Solid setup, one missing piece. If delivery ever failed for 24 hours straight and events started dead-lettering, nobody would know. The blobs would just sit there, quietly, being lost mail.

So, easy fix. Partner topics expose a DeadLetteredCount metric, and Azure has metric alerts. Metric, alert, action group, done in five minutes.

Except the topic’s menu has no Alerts entry at all. Every other Azure resource has one; this one goes straight from Metrics to Diagnostic settings. Trying through Azure Monitor instead just spells out why: “Event Grid Partner Topic isn’t supported for metric alerts.”

The metric exists. You can chart it. You just can’t alert on it. Yeah. About that.

Partner topic menu with no Alerts entry under Monitoring

TL;DR

You can’t create metric alerts on Event Grid partner topics, even though the metrics exist. The workaround: add a diagnostic setting on the topic that exports AllMetrics to a Log Analytics workspace, wait for the AzureMetrics table to appear (it’s created lazily, only after the first rows land), then create a log search alert on DeadLetteredCount > 0 with a static threshold. Add a second, earlier alert on handler failures in Application Insights so you hear about trouble hours before Event Grid gives up. Total cost: a few dollars a month.

Route the Metric to Log Analytics Instead

If the alert can’t come to the metric, the metric can go somewhere alerts work: a Log Analytics workspace.

On the partner topic, add a diagnostic setting: check AllMetrics, destination Send to Log Analytics workspace, and pick the same workspace your Application Insights already writes to. That last part is deliberate - one workspace means one place to query, and the companion alert later in this post lives in the same workspace for free.

Diagnostic settings exporting AllMetrics

From then on, every metric on the topic lands as rows in a table called AzureMetrics, and log search alerts can chew on that.

The AzureMetrics Table That Isn’t There Yet

Here’s the gotcha that cost me a confused half hour: AzureMetrics doesn’t exist until the first exported row arrives. The table is created lazily, around 15 minutes after the diagnostic setting starts producing data. And it only produces data if the topic has traffic.

The failure mode is a loop: you can’t create the alert rule because the table doesn’t exist, and the table doesn’t exist because nothing has happened yet. If your topic is quiet, send a test event through it (a test mail, in my case), wait for the export, and confirm with:

AzureMetrics
| take 10

Once that returns rows, you’re in business.

The Dead-Letter Alert That Matters

New alert rule on the workspace, with this query:

AzureMetrics
| where MetricName == "DeadLetteredCount"
| where Total > 0

What’s happening here?

  1. The exported metric rows carry the metric name and its aggregations as columns. Total is the sum for the time grain, so any row with Total > 0 means at least one event was dead-lettered in that slice.
  2. The condition is “any rows at all”: measure Table rows, aggregation Count, granularity 10 minutes, operator Greater than, threshold 0, evaluated every 5 minutes. The 10-minute window with 5-minute evaluation overlaps on purpose, so nothing falls between checks.
  3. The threshold is static, and it should be. The portal offers a Dynamic option right next to it, and it’s the wrong choice here: dynamic thresholds learn a baseline and alert on deviation, which makes sense for metrics with a natural rhythm. The natural rhythm of dead-letters is zero. Any dead-letter is an incident, not an anomaly.

For the rule details: severity 1 (a dead-letter means mail was lost after every retry Event Grid had), auto-resolve on so the alert closes itself when the query goes quiet, and 30 to 60 minutes of mute time - one poison batch can dead-letter a burst of events, and one email carries the same information as twelve. Wire it to an action group that emails whoever should care.

One more tip: put the runbook in the alert description. Mine says where the dead-letter container is and how to replay from it, because the person reading the alert email at 2 AM is future me, and future me does not want to do archeology. The blobs contain the full original event plus a deadLetterReason, and since Event Grid is a router, not a queue, replay is a DIY script that reads the blob and feeds it back through the handler’s service class.

Alert condition with the KQL query and threshold

The Early-Warning Alert That Fires First

The dead-letter alert has a built-in flaw: it’s the fire alarm that goes off after the house burnt down. Event Grid retries for roughly 24 hours before dead-lettering, which means by the time DeadLetteredCount ticks up, the problem is a day old.

The early warning lives in Application Insights, which is already recording every failed function invocation:

AppRequests
| where Name == "MailEventHandler"
| where Success == false

Condition: count of rows over a 1-hour window, threshold greater than 5, evaluated every 15 minutes. Severity 2, same action group.

If the handler starts failing - bad deploy, expired certificate, downstream outage - this fires within the hour, while Event Grid is still patiently retrying and no mail has been lost yet. The dead-letter alert becomes what it should be: the confirmation that you ignored the first alert for a day.

The threshold of 5 per hour instead of “any failure” is deliberate. The occasional transient failure is exactly what Event Grid retries exist to absorb; a failure a minute is a pattern. Tune it to your traffic.

What the Alerts Cost

Nearly nothing, but not literally nothing:

  • The dead-letter rule at 5-minute frequency is about $1.50 a month; the early-warning rule at 15-minute frequency about $0.50.
  • The exported metrics are a trickle - well under half a GB a month for one topic - and ingestion has a free tier that mine disappears into. Even billed, it’s pennies at ~$2.30/GB.
  • Emails from the action group: first 1,000 a month free, and if you’re sending more than that you have bigger problems than the bill.

Call it $2-3 a month for not silently losing mail. I’ve spent worse.

Gotchas

  • The metric existing doesn’t mean you can alert on it. Chart works, alert doesn’t. Check resource type support before designing your monitoring around a metric.
  • AzureMetrics appears lazily. No traffic, no table, no alert rule. Seed the topic with a test event and wait ~15 minutes before creating the rule.
  • Overlap your windows. A 10-minute window checked every 5 minutes double-covers; a 5-minute window checked every 10 leaves holes exactly where your incident will land.
  • Auto-resolve is not the default mindset. Without it, someone has to close every fired alert by hand, and alerts nobody closes become alerts nobody reads.
  • The dead-letter alert alone is not monitoring. It tells you about mail that’s already lost. Pair it with a failure alert upstream so you get a 23-hour head start.

Wrapping Up

Partner topics won’t do metric alerts, so export the metrics to where alerts do work: diagnostic settings into Log Analytics, a static-threshold log search alert on DeadLetteredCount > 0, and an early-warning alert on handler failures that fires while Event Grid is still retrying. Rule of thumb: alert on the failure while it’s still retryable, and treat the dead-letter alert as the postmortem bell.

References