Skip to content

From Interface Error Monitor to Notification: An Alert Pipeline

Interactive Diagram

새 탭 ↗

An error-event query is not an operational Alert Pipeline. A fresh log may not yet be searchable because ingestion is delayed, while the same error may be evaluated again or its Notification delivery retried. If search, history persistence, and human notification share one synchronous transaction, a failure in one stage blocks the entire detection path.

This article implements a per-bucket monitor that finds failed executions by guid, sends them to an Alert API, and lets that API manage history and Notification independently. It builds on the distinction between Event, Alert, grouping, and dedup in Separating Integration Alerting and Metrics.

Every minute, the monitor queries the Trace index. It first restricts time and event type, then builds a bucket key from interfaceId and guid. Each bucket calculates error-event count and the last Trace, and only buckets with at least one error trigger.

A guid bounds one execution and interfaceId identifies the integration flow. Grouping by this pair collapses several ERR events from one execution into one detection candidate. It must not, however, become the long-lived suppression key; that would still create one Alert per request. The Alert API applies separate grouping and dedup policies.

{
"windowStart": "2024-04-15T09:58:30Z",
"windowEnd": "2024-04-15T09:59:30Z",
"buckets": [
{
"interfaceId": "inventory-sync-v1",
"guid": "g-demo-7f2c",
"errorCount": 2,
"lastTrace": {
"eventType": "ERR",
"statusCode": "E_TIMEOUT",
"time": "2024-04-15T09:59:12Z"
}
}
]
}

Include only required fields. Do not copy raw stack traces, credentials, or business payload into this request. When an operator needs details, use the guid to call an authorized Trace API.

At evaluation time T, the interval [T-90s, T-30s) is 60 seconds wide but deliberately excludes the newest 30 seconds. A one-minute monitor avoids querying right up to the present because an application log needs time to cross a collector, buffer, network, and index refresh before it becomes searchable.

For example, the 10:00 evaluation reads 09:58:30 inclusive through 09:59:30 exclusive; the 10:01 evaluation reads 09:59:30 inclusive through 10:00:30 exclusive. Under normal cadence the windows do not overlap. Instead, every event receives at least 30 seconds of ingestion allowance, reducing boundary misses from late indexing. The trade-off is at least 30 seconds of additional Alert latency.

This window does not guarantee exactly-once delivery. Monitor reruns, trigger retries, repeated notification of an active Alert, duplicate ingested events, and scheduler jitter can deliver the same logical error again. An event delayed by more than 30 seconds can still be missed. Lookback is therefore a lateness policy; it does not replace deduplication or reconciliation.

PlantUML Diagram

The monitor owns only search and condition evaluation. The Alert API does not trust the incoming payload: it validates schema, rule version, window, and bucket key. If lastTrace is absent, quarantine the malformed bucket instead of selecting an arbitrary first event. With multiple hits, choose the first event in descending (time, seq) order as the representative Trace.

History persistence and Notification requests require independent states. If they share a database, write an outbox row inside the History transaction and let a worker deliver it. If delivery uses a separate broker, use a transactional outbox or equivalent guarantee. Calling an email API before storing History can leave “email sent, no record” when the process dies between those actions.

A per-bucket guid is useful for opening a representative execution but too specific for outage grouping. If one target outage fails hundreds of guid values, it would produce one Notification per request.

groupKey = interfaceId + errorClass + target
dedupKey = ruleId + groupKey + windowStart

The groupKey decides which Events describe one operational problem. The dedupKey prevents a retried request from creating another History row and Outbox command. Enforce it atomically with a database unique constraint or conditional write. A select-then-insert sequence alone races under concurrent requests.

When several guid values share a group in one window, store occurrenceCount, first and last detection time, and one representative lastTrace.guid. If the same outage persists into later windows, update the existing Alert’s observations rather than automatically creating a new Incident, and notify again only according to repeatInterval. Per-window deduplication and long-lived suppression are separate decisions.

History is the audit record of what was detected, by which rule, and when. Notification is a side effect that attempts to deliver that record through a channel. They require separate retry policies and states.

ConcernTypical statesRetry rule
Alert historyOPEN, ACKNOWLEDGED, RESOLVEDIdempotent upsert for the same dedup key
Notification deliveryPENDING, DELIVERED, FAILED, SUPPRESSEDBackoff retry only for transient channel failures

Notification failure must not roll back History, and temporary History-query failure must not permanently block the monitor’s next search cycle. The Outbox worker either sends an idempotency key to the channel or keeps its own delivery ledger. Permanent failures stop retrying and surface as a dead-letter state and operational Metric.

Development and test environments should still execute detection and History persistence so that rules and parsing are testable. Actual human Notification should be enabled only in production or routed to an explicit test channel.

alerting:
detectionEnabled: true
historyEnabled: true
notification:
mode: SUPPRESS
allowedEnvironments: [production]
channelRef: ops-primary

Do not trust an environment name supplied in the request. Derive mode from deployment configuration and workload identity, and record SUPPRESSED as an outcome. This distinguishes “delivery code was intentionally not invoked” from “delivery was attempted and failed.” Recipient addresses and tokens do not belong in a rule or log; resolve them through channelRef.

A 30-second delay is an empirical setting, not a universal constant. Record these Metrics and tune it.

  • p95 and p99 of indexedAt - occurredAt
  • monitor scheduling delay and query duration
  • detected bucket count and dedup-hit count per window
  • late events arriving after 30 seconds
  • Notification delivery latency and retry count

If p99 ingestion delay frequently exceeds 30 seconds, increase the delay or add a separate late-event sweep. Expanding the window without limit increases duplicate candidates and query cost, so adjust it narrowly and assume deduplication is present.

A quiet Alert Pipeline can mean there were no errors, or it can mean ingestion stopped. A daily reconciliation job compares the previous day’s OpenSearch counts with counts persisted in the relational summary store.

PlantUML Diagram

Do not compare unlike units. Raw event count contains several events per execution and cannot equal execution count. Apply the same eventType filter, timezone, half-open day range [start, nextDay), and completed-execution definition on both sides. OpenSearch cardinality is approximate, so exact reconciliation requires composite bucket traversal or an idempotent execution ledger.

A reconciliation result records source count, stored count, difference, execution time, query window, and shard-failure status. On mismatch, do not immediately rebuild everything. Narrow the loss boundary across Trace index, raw history, and daily summary. Re-aggregation should idempotently upsert a date key instead of relying on delete-insert, and advance its watermark only after recording completion.

Operational data serves different purposes and should not share one arbitrary retention period.

DataPurposeRetention driver
Raw Trace logDetailed diagnosis and replay evidenceSearch cost, payload sensitivity, investigation horizon
Alert historyDetection and acknowledgement auditIncident review and regulatory requirements
Daily/monthly statisticsLong-term trend and capacity planningReporting horizon and aggregation granularity
Batch metadataJob restart and recent-execution diagnosisRestart horizon and repository size

Summaries commonly outlive raw logs, while batch metadata remains only as long as restart and diagnosis require it. Actual day counts come from regulation and operational objectives. Purge in dependency order with awareness of child records and delivery states, and prefer date partitions or bounded chunks over one enormous transaction.

The aggregation chain follows Trace → execution history → daily statistics. Verify each stage’s success marker before starting the next stage or purge. Running source retention first destroys the evidence needed for re-aggregation and reconciliation.

The [T-90s, T-30s) lookback evaluates one minute of data with a 30-second delay, providing ingestion allowance at the cost of slower detection. It does not eliminate retries or duplicate ingestion, so atomic deduplication in the Alert API is mandatory. Separate History from Notification delivery and record environment-based suppression so that one failure cannot erase evidence from the other path. Finally, daily reconciliation and dependency-ordered retention distinguish “there were no Alerts” from “there was no data.”