Alert lifecycle
Keep turns signals from monitoring and other providers into alert records that people and automated systems can act on. An alert moves through intake, common formatting, duplicate checks, storage, rule evaluation, and client delivery, while its history and related incidents remain available for later search.
Lifecycle overview
The backend accepts alerts through provider webhooks, generic events, and provider polling. It processes each event in the tenant context, keeps a durable alert history, and exposes a current view for the alert list and related product features.
The main flow is:
flowchart LR
A[Provider signal] --> B[Intake]
B --> C[Common alert form]
C --> D[Maintenance and duplicate checks]
D --> E[Alert history and current alert]
E --> F[Workflows and rules]
F --> G[Incidents]
E --> H[Search and alert API]
G --> H
E --> I[Search index and client update]
The event path is asynchronous from the caller's point of view. The intake endpoint returns an accepted task, then background processing completes the work and notifies clients when their view may have changed.
Alert intake
Alert intake is the boundary between external systems and Keep's alert model. Provider-specific payload handling occurs before the shared processing path, so downstream stages can work with one alert shape even when providers send different fields and formats.
Intake paths
The provider event endpoint receives a provider type and raw body. The generic event endpoint accepts an alert that already follows the common contract. Provider polling can also start the same processing path when a client query asks Keep to refresh provider data.
The intake boundary performs these high-level tasks:
- Authenticates the request and assigns it to a tenant.
- Resolves the provider and parses its raw event body.
- Accepts a provider ID or a provider name that Keep can resolve to an ID.
- Queues processing in Redis-backed workers when enabled. Otherwise, it submits background work in the API process.
- Returns a task name with HTTP
202instead of waiting for storage and downstream actions.
References: keep/…/alerts.py• L598-781 keep/…/alerts.py• L194-225
Common alert form
The common alert form gives every event the fields needed for state, display, and grouping. It supplies an ID when one is missing, maps unknown severity to info, maps unknown status to firing, and normalizes the event time to UTC. A missing fingerprint is derived from the alert name or, if needed, the full payload.
The form also carries provider data and flexible event fields. Keep can therefore preserve provider context while allowing later enrichment, search facets, and rules to use fields that were not known when the model was written.
References: keep/…/alert.py• L25-60 keep/…/alert.py• L75-119 keep/…/alert.py• L148-213 keep/…/alert.py• L249-295
Alert processing
Alert processing applies the checks and state changes that make an incoming signal useful to the rest of Keep. It runs pre-format extraction, provider formatting, maintenance handling, duplicate checks, and post-format enrichment before it publishes the result.
Processing stages
The processing service follows this order:
- Run tenant extraction rules before provider formatting.
- Format raw provider data into one or more common alerts.
- Apply a maintenance window policy. An alert in maintenance can be withheld or marked with maintenance state according to the configured policy.
- Compare the event with the latest event for its fingerprint.
- Calculate firing and unresolved history values from the prior alert.
- Dispose temporary enrichments and run post-format extraction and mapping rules.
- Store the accepted event and update the current alert for its fingerprint.
- Send the enriched event to the search index, workflows, correlation rules, and connected clients.
This order matters because duplicate checks need a stable common form, while workflows and rules need the stored alert plus its enrichment and history values.
References: keep/…/process_event_task.py• L130-347 keep/…/process_event_task.py• L361-496 keep/…/process_event_task.py• L662-800
Deduplication
Deduplication limits repeated provider signals without losing the distinction between an alert group and an alert event. The fingerprint identifies the group of related events, while the alert hash represents the contents of one event after ignored fields are removed.
Duplicate outcomes
Keep selects a rule for the tenant and provider. A custom rule can define fields to ignore. If no custom rule applies, the default rule ignores the receive time. Keep hashes the resulting alert and compares it with the latest hash for the same fingerprint.
| Outcome | Meaning | Downstream effect |
|---|---|---|
| Full duplicate | The fingerprint and relevant event content match the latest event. | The event is not stored as a new alert event. Keep records the duplicate action and updates the group's receive-time enrichment. |
| Partial duplicate | The fingerprint matches but the relevant event content changed. | The event continues through storage and downstream evaluation. |
| New event | No prior hash exists for the fingerprint. | The event starts or extends the alert history. |
Deduplication statistics are recorded as full, partial, or none events. The detailed rule and provider behavior belongs in Alert ingestion and deduplication.
References: keep/…/alert_deduplicator.py• L45-178 keep/…/alert_deduplicator.py• L197-290 keep/…/process_event_task.py• L424-458
Alert state and storage
Keep stores both the event history and a fast current view. This split lets the product show every meaningful event for a fingerprint while common list operations use the latest event without scanning the full history.
Alert records
An alert record belongs to one tenant and stores provider identity, the normalized event, its fingerprint, and its alert hash. A LastAlert record points to the newest event for each tenant and fingerprint. It also keeps the first timestamp for the current alert group, which supports firing duration and start-time views.
Enrichment is stored separately by fingerprint. This holds user and system data such as assignments, notes, dismissal state, and other values that can change without rewriting every historical event. Alert audit records provide a time-ordered record of system and user actions.
References: keep/…/alert.py• L43-65 keep/…/alert.py• L107-199 keep/…/alert.py• L312-334 keep/…/process_event_task.py• L180-306 keep/…/db.py• L5708-5749
Alert state transitions
The alert status describes the operational state of an event or alert group. A firing event is active. A resolved event ends the active period. An acknowledged event records that a person has taken ownership without resolving the alert. Suppressed, pending, and maintenance states represent policy or source conditions that affect how the alert is handled.
Keep derives counters and firing times from the previous event with the same fingerprint. A new firing sequence starts at the current receive time. A later firing event continues that sequence. A resolved event resets the unresolved counter, while an acknowledged event resets the firing counter for the next active sequence.
References: keep/…/alert.py• L40-60 keep/…/enrichment_helpers.py• L61-180 keep/…/process_event_task.py• L184-220
Alert evaluation
After storage, Keep evaluates the enriched alert against automation and correlation rules. These systems use the same alert fields that the product can search, which keeps automated actions aligned with the operator view.
Workflow evaluation
The workflow manager receives the enriched alert after it is stored. Workflows can react to the alert and to later changes such as assignment or enrichment. The alert path treats workflow execution as a downstream action, so a workflow failure is logged without removing the stored alert.
References: keep/…/process_event_task.py• L538-557 keep/…/alerts.py• L491-507 keep/…/alerts.py• L1008-1013
Incident evaluation
When correlation is enabled, the rules engine tests each accepted alert against tenant rules. A matching rule creates or reuses an incident group, links the alert by fingerprint, and applies the rule's threshold and grouping conditions before the incident becomes visible. Resolved alerts can resolve linked incidents when their configured resolution condition is met.
The alert-to-incident link is part of the alert's presentation rather than a copy of the alert event. This allows one fingerprint to retain its alert history while its incident links change over time. See Alert search, filtering, and incidents for the query and incident-facing behavior.
References: keep/…/rulesengine.py• L52-71 keep/…/rulesengine.py• L73-225 keep/…/db.py• L3865-3896 keep/…/process_event_task.py• L558-580
Alert presentation
Keep presents alerts through a tenant-scoped API and optional search index. The API reads the current alert view, joins enrichment and incident data when requested, and converts database records back to the common alert form used by clients.
Search and filtering
The alert query path supports pagination, sorting, time limits, and CEL filters. CEL is a small expression language used to select alert fields. Static and tenant-defined facets provide the field choices used by filter controls. Queries can include incident fields, which causes the alert view to include active incident links.
The search and filtering model is described in Alert search, filtering, and incidents. Its child page also covers dismissal, counts, alert history, and incident-facing queries.
References: keep/…/alerts.py• L94-192 keep/…/alerts.py• L194-250 keep/…/alerts.py• L42-178 keep/…/alerts.py• L233-444
Client updates
After processing, Keep can index the enriched alert by fingerprint and notify the tenant's private client channel. The notification tells the client to poll for current alert data rather than sending a second copy of the alert as the source of truth. Incident and preset changes use related notifications so the visible product state can refresh as one processing run changes several views.
References: keep/…/elastic.py• L203-259 keep/…/process_event_task.py• L496-521 keep/…/process_event_task.py• L582-648
Related pages
- Alert ingestion and deduplication explains provider polling and event intake, parsing, enrichment, duplicate rules, and persistence paths.
- Alert search, filtering, and incidents explains alert queries, filters, dismissal, counts, and incident behavior.
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the common alert fields must stay aligned with provider formatting, the CEL field map, search indexing, and DTO conversion.
- Changes to fingerprint or alert-hash rules must stay aligned with
LastAlert, deduplication statistics, alert history, and search document IDs. - Changes to enrichment keys must account for both current alert display and instance or historical enrichment when
dispose_on_new_alertis used. - Changes to processing order must preserve the contract that workflows, incident rules, search indexing, and client notifications receive the post-enrichment alert.
- Changes to incident links or resolution rules must cover both the alert query joins and the incident resolution check after a resolved event.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Provider parsing or common formatting fails | The event is not processed as an alert. The raw event is saved as an error alert when available, and worker jobs can retry. | Keep provider parsing and formatting must produce a valid common alert before deduplication. |
| A stale event finishes after a newer event for the same fingerprint | The current alert view could move backward in time. | LastAlert is updated only when the incoming timestamp is newer. |
| CEL query syntax is invalid | The alert query or facet option request returns a client error instead of a result. | The query path converts CEL errors to HTTP 400. |
| Search indexing fails after database storage | The stored alert remains available through the API, but search results can be stale. | Indexing errors are logged and do not discard the stored alert. |
| Incident or workflow evaluation fails | The alert remains stored, but an automation action or incident update can be missing. | These downstream stages handle and log their own failures after persistence. |
Key files
| File | Why to read it |
|---|---|
| keep/…/alerts.py | Shows the alert intake endpoints and the API paths that read and enrich alerts. |
| keep/…/process_event_task.py | Shows the end-to-end processing order from formatting through storage, evaluation, indexing, and client updates. |
| keep/…/alert.py | Defines the common alert fields, status values, and normalization rules. |
| keep/…/alert_deduplicator.py | Explains the distinction between fingerprints, hashes, and duplicate outcomes. |
| keep/…/alert.py | Shows the durable relationships between event history, current alerts, enrichments, and incident links. |
| keep/…/alerts.py | Shows the alert query field map, facets, CEL filtering, and current-alert query boundary. |
| keep/…/rulesengine.py | Shows how accepted alerts become incident changes through rule evaluation. |
| keep/…/elastic.py | Shows the optional search-index representation and fingerprint-based document identity. |