Automation
Azure Event Grid: diagnose a filter before widening a subscription
A production runbook for separating missing publications, Event Grid filter mismatches and delivery failures, then validating a bounded correction.
After a release, an order workflow stops starting for some files. The producer reports successful publication, the webhook is healthy, and the consumer has no record of the missing events. Removing every filter might restore visible traffic, but it can also trigger work for events outside the intended scope.
The running example is a custom Event Grid topic with a subscription for OrderReady events whose data.environment is production. A new producer version sends prod. That value change is a hypothesis to test, not a diagnosis inferred from a quiet webhook.
Locate the break
For a short UTC window, preserve the topic and subscription IDs, producer and consumer versions, change time, event IDs and redacted payload samples. Export both the effective configuration and the last approved version: included event types, subject prefix and suffix, advanced filters, destination and delivery policy. Payloads and destinations can contain sensitive information, so follow local retention controls.
Compare metrics over the same window and at the correct scope: topic publication, then subscription MatchedEventCount, DeliverySuccessCount and DeliveryAttemptFailCount. Check availability and dimensions for the actual resource type in Azure Monitor. Counters are aggregated and may arrive late; they do not prove the path of an individual event.
- Publication not confirmed: investigate the producer, its publish response and the target topic before changing filters.
- Publication confirmed but matches unexpectedly low: compare payload and filter contracts; do not infer the cause from one counter.
- Matches present with delivery failures: investigate the destination, authentication and delivery errors. A filter change will not repair a failing webhook.
- Deliveries succeed but the effect is absent: correlate consumer logs with business state. An acknowledgement is not proof of business processing.
An event that does not match this subscription is not a delivery failure for it. Do not rely on its dead-letter destination to reconstruct excluded events. An event may match a different subscription, so a topic-wide unmatched metric alone cannot diagnose this subscription.
Compare contracts field by field
Obtain authorized, redacted examples for each cohort: an expected event not received, one received before the change, and one that must remain excluded. Preserve type, subject, relevant field structure and types, ID and time. Identify the actual schema, Event Grid or CloudEvents, before choosing filter field names.
Subscription: orders-prod
Intended filter: event type OrderReady AND data.environment StringIn [production]
Before release: data.environment = "production" -> expected: match
After release: data.environment = "prod" -> business expects match; current filter: no match
Out of scope: data.environment = "test" -> expected: no match
Missing field: data.environment absent -> expected: no match
Wrong type: data.environment = 1 -> expected: no match This is a diagnostic example, not Event Grid output. Multiple filters combine under the documented rules; do not infer the final result from one field. Check case, subject prefix or suffix, data types and arrays. Missing keys and negative operators do not all behave alike, so test each operator in use. Array filtering requires explicit enablement and arrays of objects are not supported.
Test without involving the production consumer
Where permissions and local policy allow, create a temporary subscription on a representative test topic with the same filter version and an isolated destination with no business side effects. Publish synthetic fixtures only. Do not send sensitive data or production events to an active destination. Confirm the schema, case, types and event path reproduce the real case.
Run the matrix before and after the candidate change:
| Fixture | Expected result |
|---|---|
production | Received |
prod, if permitted by the business contract | Received after correction |
test | Not received |
| Missing or numeric field | Not received for this StringIn filter |
| Wrong event type or excluded subject | Not received |
Give each fixture a unique ID. Check metrics and test-destination receipt separately, and allow an appropriate observation window for negative cases. An early absence is not proof. If the test does not reproduce the issue, hold the change and investigate contract or configuration differences.
Choose a bounded correction
Ask the contract owner to decide whether the producer should return to production, or whether both values are valid going forward. In the latter case, an explicit allowlist can be more precise than removing the filter. Record duplicate-processing risk during migration and a retirement date for any temporary value.
Before deployment, preserve the previous configuration, diff, owner, change window, stop conditions and restoration procedure using the normal deployment tool. Check for concurrent changes; do not blindly restore a snapshot over legitimate updates. Apply to a pilot subscription or an equivalent test scope without duplicating production side effects. If no safe canary exists, use an approved, controlled validation on the smallest feasible scope.
After the change, validate an authorized positive event and a non-destructive negative case, then correlate ID, delivery and business state. Watch matched volume, delivery failures and unexpected side effects over an agreed window. More deliveries alone do not prove the fix.
Recover the gap and decide whether to roll back
Changing a filter does not retroactively recover excluded events. Reconcile the incident window against the business source or a reliable publication log. Before republishing anything, define the missing set, its business validity, deduplication, relevant ordering, effects already performed and a batch limit. Without a trustworthy source or proof of idempotency, hold recovery with the business owner.
Restore the approved configuration if prohibited events pass, downstream effects diverge or the canary fails. First stop temporary processing or republication, restore the filter through the validated procedure, then repeat positive and negative tests and check consumer health. Filter rollback does not undo side effects already produced: identify those separately and obtain approval for compensation.
The final decision is explicit: retain a proven correction, restore the previous contract, or hold the flow and recovery until evidence is sufficient. Preserve the matrix, diff, test results and outstanding business discrepancies.