Introducing a new way to review your PRs.

Read the announcement

keephq / keep

The open-source AIOps and alert management platform

View on GitHub

22 documents · Updated Nov 23, 2026

docs / alert-ingestion-and-deduplication

Alert ingestion and deduplication

Keep turns alerts from monitoring and incident tools into tenant-scoped alert history. Provider polling and inbound events enter one processing path that normalizes the signal, adds tenant rules and context, rejects exact repeats, and stores the result for workflows, rules, search, and incidents.

This page covers the intake part of the alert lifecycle. The stored output is later used by alert search, filtering, and incidents.

Intake paths

Alert intake has two main sources. Polling asks installed providers for current alerts. Event intake accepts a provider webhook or a generic Keep alert. Both sources use the same event processor, so later behavior does not depend on how an alert arrived (keep/…/preset.py• L50-61, keep/…/alerts.py• L598-655, keep/…/alerts.py• L685-781).

Provider polling

Provider polling is a background refresh of the current state held by external systems. Keep checks each installed provider’s pull setting and last-pull time, groups returned alerts by fingerprint, then submits each group to event processing without sending a client refresh for every alert (keep/…/preset.py• L63-121, keep/…/base_provider.py• L560-644).

The poll path can also return related incident or topology data. These side paths are optional. Alert processing remains the shared result of the poll cycle (keep/…/preset.py• L123-185).

Zabbix polling reads problems from a recent time window and maps each problem to a Keep alert. The Zabbix event ID supplies the stable identity while the provider maps problem state, severity, environment, and source data (keep/…/zabbix_provider.py• L523-566).

Sentry polling can cover one configured project or all projects in an organization. It reads recent events and related issues, then maps each event to a Keep alert with an event ID, issue group fingerprint, status, severity, project, and source data (keep/…/sentry_provider.py• L464-548).

Graylog polling reads alert events from a recent one-day window and maps each event to a Keep alert. The Graylog event ID supplies the fingerprint, while the event definition remains useful context for the alert name and message (keep/…/graylog_provider.py• L754-808, keep/…/graylog_provider.py• L664-689).

References: keep/…/preset.py• L50-61 keep/…/preset.py• L63-121 keep/…/preset.py• L123-185 keep/…/base_provider.py• L603-687 keep/…/zabbix_provider.py• L523-566 keep/…/sentry_provider.py• L464-548 keep/…/graylog_provider.py• L664-689 keep/…/graylog_provider.py• L754-808

Event intake

Event intake exposes a generic endpoint and provider-specific endpoints. The generic endpoint accepts an alert model, a list, or a dictionary. A provider endpoint reads JSON, form data, or raw bytes, then lets the provider parse a non-JSON body before it queues the event (keep/…/dependencies.py• L26-49, keep/…/alerts.py• L598-655, keep/…/alerts.py• L685-735).

The endpoint returns an accepted task name instead of waiting for alert work to finish. With Redis enabled, the task goes to the basic worker queue. Without Redis, Keep sends it to a local event worker pool (keep/…/alerts.py• L621-655, keep/…/alerts.py• L748-781).

Provider setup can create the external event link as part of this path. The Zabbix provider installs or updates a Zabbix script and action that sends event fields to Keep with an API key, then accepts problem, recovery, and update notifications through the provider endpoint (keep/…/zabbix_provider.py• L568-717, keep/…/zabbix_provider_script.js• L11-47).

Sentry can install a webhook for one project or for every project in an organization. The setup keeps existing webhook URLs, enables the webhook service, and creates an alert rule that sends events to Keep. Scope checks report a useful status even when Sentry returns an empty or non-JSON error response (keep/…/sentry_provider.py• L168-223, keep/…/sentry_provider.py• L312-441).

Graylog setup creates or replaces its Keep notification, allows the Keep URL through Graylog, and attaches the notification to event definitions. Graylog v4 puts the API key in the URL. Older versions send it in the request header (keep/…/graylog_provider.py• L75-96, keep/…/graylog_provider.py• L549-662).

References: keep/…/dependencies.py• L26-49 keep/…/alerts.py• L598-655 keep/…/alerts.py• L685-781 keep/…/arq_worker.py• L69-121 keep/…/sentry_provider.py• L168-223 keep/…/sentry_provider.py• L312-441 keep/…/graylog_provider.py• L75-96 keep/…/graylog_provider.py• L549-662

Alert normalization

Normalization converts provider data into the common AlertDto shape. This gives downstream systems stable fields for identity, status, severity, time, source, service, labels, and provider data. Provider classes own the mapping from their external format. The base provider applies shared dispatch and fingerprint rules (keep/…/base_provider.py• L410-538, keep/…/alert.py• L75-118).

Field validation

The alert model supplies safe defaults and rejects values that cannot support alert processing. It creates an ID when needed, maps unknown severity to info, maps unknown status to firing, normalizes timestamps, and checks description format. A missing fingerprint uses the alert name or a hash of the payload. Provider-specific fields remain available because the model allows extra fields (keep/…/alert.py• L25-37, keep/…/alert.py• L148-213, keep/…/alert.py• L249-305).

Keep also checks the timestamp before persistence. If it is absent or invalid, Keep uses the current UTC time so the database and alert history have a usable event time (keep/…/process_event_task.py• L114-127, keep/…/process_event_task.py• L247-264).

References: keep/…/alert.py• L25-37 keep/…/alert.py• L75-118 keep/…/alert.py• L148-213 keep/…/alert.py• L249-305 keep/…/process_event_task.py• L114-127 keep/…/process_event_task.py• L247-264

Provider mapping

Each provider maps its own payload into the common model. For example, the Prometheus mapper turns labels and annotations into alert fields, maps provider status and severity to Keep values, and keeps provider data in labels and payload fields (keep/…/prometheus_provider.py• L153-169, keep/…/prometheus_provider.py• L172-236).

Zabbix maps both polled problems and pushed event data. Its mapping converts provider severity and status values, uses event tags for the environment, derives host and service context, and builds a Zabbix event URL when the provider supplies the needed identifiers. Update actions can override the base status with acknowledged or suppressed state (keep/…/zabbix_provider.py• L489-521, keep/…/zabbix_provider.py• L719-787).

Sentry maps event and issue data into alert name, message, status, severity, project, environment, source, URL, tags, and payload fields. Webhook and polling formats both preserve a stable event identity and a group-based fingerprint, so repeated Sentry events can share one alert stream (keep/…/sentry_provider.py• L225-310, keep/…/sentry_provider.py• L510-548).

Graylog uses the same event mapper for polling and webhook input. It maps the Graylog event ID to alert identity, converts priority into Keep severity, sets the event to firing, and preserves the definition, origin, message, and timestamp as alert context (keep/…/graylog_provider.py• L664-695, keep/…/graylog_provider.py• L780-808).

Provider identity is attached after mapping. This identity lets Keep select the correct tenant rule and keeps alerts from different provider instances distinct when their payloads look alike. The base provider can also apply a configured fingerprint rule after an alert already has the common AlertDto shape (keep/…/base_provider.py• L438-538, keep/…/base_provider.py• L603-633).

References: keep/…/prometheus_provider.py• L153-169 keep/…/prometheus_provider.py• L172-236 keep/…/zabbix_provider.py• L489-521 keep/…/zabbix_provider.py• L719-787 keep/…/sentry_provider.py• L225-310 keep/…/sentry_provider.py• L510-548 keep/…/graylog_provider.py• L664-695 keep/…/graylog_provider.py• L780-808 keep/…/base_provider.py• L438-538 keep/…/base_provider.py• L603-633

Processing flow

The event processor is the shared path after polling or intake. It performs pre-format extraction, provider formatting, caller-supplied identity, maintenance checks, deduplication, persistence, indexing, workflow delivery, rule evaluation, and client notification (keep/…/process_event_task.py• L661-800).

This diagram shows how an external signal becomes a stored and usable Keep alert.

flowchart LR
    A[Provider poll] --> C[Event processor]
    B[Webhook or generic event] --> C
    C --> D[Pre-format extraction]
    D --> E[Provider mapping and validation]
    E --> F[Fingerprint and metadata]
    F --> G[Maintenance check]
    G --> H[Deduplication]
    H --> I[Persist alert history]
    I --> J[Enrich and map]
    J --> K[Search index]
    J --> L[Workflows and rules]
    J --> M[Client refresh]

References: keep/…/process_event_task.py• L661-800 keep/…/process_event_task.py• L361-458

Enrichment paths

Enrichment adds context that is not in the provider's first payload. Keep runs extraction rules before provider mapping and again after the alert has its common shape. It then applies stored mapping rules after the alert is saved. These stages let raw provider data drive later field extraction while keeping the final alert useful to workflows and search (keep/…/process_event_task.py• L702-743, keep/…/process_event_task.py• L223-306, keep/…/enrichments_bl.py• L130-167, keep/…/enrichments_bl.py• L297-338).

Stored enrichment is keyed by fingerprint and is applied when alerts are read back. This matters for polled alerts because Keep may receive a fresh provider object instead of updating the same database row. Special enrichment data tracks per-occurrence deletion and assignment by lastReceived (keep/…/enrichment_helpers.py• L29-59, keep/…/enrichment_helpers.py• L183-263).

References: keep/…/process_event_task.py• L702-743 keep/…/process_event_task.py• L223-306 keep/…/enrichments_bl.py• L130-167 keep/…/enrichments_bl.py• L297-338 keep/…/enrichment_helpers.py• L29-59 keep/…/enrichment_helpers.py• L183-263

Deduplication

Deduplication decides whether a new signal adds a new alert occurrence. A fingerprint identifies the alert stream. An alert hash describes the current content after ignored fields are removed. Keep compares the new hash with the latest hash for that fingerprint and classifies the result as a full duplicate, partial duplicate, or new (keep/…/alert.py• L107-129, keep/…/alert_deduplicator.py• L45-116).

Deduplication rules

Rules are selected by tenant, provider type, and provider ID. A custom rule can choose fingerprint fields and fields to ignore. If no custom rule exists, Keep uses a full-deduplication rule that ignores lastReceived, so a changed receive time does not create a new occurrence (keep/…/alert_deduplicator.py• L118-178, keep/…/alert_deduplicator.py• L197-245, keep/…/alert_deduplicator.py• L260-290).

Custom fingerprint rules run for provider formatting and provider polling. The provider base also exposes the rule as a separate step for alerts that already have the common AlertDto shape. The later deduplication rule still compares the normalized alert content, which separates stream identity from content equality (keep/…/base_provider.py• L464-538, keep/…/base_provider.py• L603-633). Zabbix uses the event ID as its default fingerprint field, so polling and webhook events for one Zabbix problem can share one alert stream (keep/…/zabbix_provider.py• L60-67, keep/…/zabbix_provider.py• L523-566, keep/…/zabbix_provider.py• L719-787). Sentry uses the external event group as its poll fingerprint and preserves the event ID inside the normalized alert, which allows related events to share a stream while keeping event-level identity (keep/…/sentry_provider.py• L510-548).

Graylog uses the event ID as its default fingerprint for both polled and webhook alerts. It does not use the event definition ID because that value identifies the notification rule and could merge separate alert instances into one stream (keep/…/graylog_provider.py• L124-133, keep/…/graylog_provider.py• L664-689).

References: keep/…/alert.py• L107-129 keep/…/alert_deduplicator.py• L45-116 keep/…/alert_deduplicator.py• L118-178 keep/…/alert_deduplicator.py• L197-245 keep/…/alert_deduplicator.py• L260-290 keep/…/base_provider.py• L464-538 keep/…/base_provider.py• L603-633 keep/…/sentry_provider.py• L510-548 keep/…/graylog_provider.py• L124-133 keep/…/graylog_provider.py• L664-689

Duplicate handling

Full duplicates do not create another alert row. Keep records their latest receive time as enrichment and writes a system audit entry. Partial duplicates and new alerts continue through persistence, so a changed state such as firing or resolved remains part of alert history (keep/…/process_event_task.py• L130-180, keep/…/process_event_task.py• L424-458).

Keep records one deduplication event for each rule result. These events support counts and recent distribution data for deduplication views. Each event records whether the result is full, partial, or none (keep/…/alert_deduplicator.py• L154-177, keep/…/db.py• L2696-2740, keep/…/db.py• L2743-2840).

References: keep/…/process_event_task.py• L130-180 keep/…/process_event_task.py• L424-458 keep/…/alert_deduplicator.py• L154-177 keep/…/db.py• L2696-2740 keep/…/db.py• L2743-2840

Persistence and downstream delivery

Non-duplicate alerts are stored as tenant-scoped alert rows with the normalized event, provider identity, fingerprint, and alert hash. Keep updates a LastAlert record for each fingerprint so the next event can compare with the latest occurrence and preserve ordering when work completes out of order (keep/…/alert.py• L43-65, keep/…/alert.py• L107-129, keep/…/process_event_task.py• L180-286, keep/…/db.py• L5708-5761).

Before and around persistence, Keep calculates firing and unresolved counters from the prior alert in the same fingerprint stream. It also records the first firing time and runs post-format extraction and mapping. These values describe the alert lifecycle that downstream rules and views consume (keep/…/process_event_task.py• L183-247, keep/…/enrichment_helpers.py• L61-180).

After the database commit, Keep may write the alert to Elasticsearch with the fingerprint as the document ID. The same identity lets the search copy represent the latest alert state for that stream. Workflows and the rules engine then receive the enriched events, while the client gets a throttled refresh signal (keep/…/process_event_task.py• L496-567, keep/…/process_event_task.py• L582-658, keep/…/elastic.py• L203-225).

References: keep/…/alert.py• L43-65 keep/…/alert.py• L107-129 keep/…/process_event_task.py• L180-286 keep/…/db.py• L5708-5761 keep/…/process_event_task.py• L496-567 keep/…/process_event_task.py• L582-658 keep/…/elastic.py• L203-225

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the provider formatter contract aligned with AlertDto defaults, status values, timestamp rules, and fingerprint assignment. A mismatch can drop or misclassify events before persistence.
  • Keep custom fingerprint calculation aligned for provider formatting, provider polling, and alerts that already have the common AlertDto shape. Changing one path only can split one provider alert stream or leave a configured rule unapplied.
  • Keep Sentry polling and webhook mappings aligned on event ID, group fingerprint, status, severity, project, and receive time. A change in one source can make one Sentry issue appear as two alert streams or shapes.
  • Keep Sentry scope checks and setup behavior aligned with Sentry's error response formats. An empty or non-JSON response must remain a readable validation result instead of causing setup to fail with a parser error.
  • Keep Graylog polling and webhook mapping aligned on event ID, timestamp, priority, and firing status. A change in one source can split one Graylog alert instance or make its severity differ by intake path.
  • Keep the Graylog fingerprint on the event ID rather than the event definition ID. The definition identifies a notification rule and is not a unique alert occurrence.
  • Keep LastAlert.alert_hash updates tied to the same fingerprint and event-order rules. A stale hash can mark a valid state change as a full duplicate.
  • Keep the full-duplicate path aligned with per-occurrence enrichment and audit data. Removing that update can make polled alert history show the wrong receive time.
  • Keep post-persistence enrichment before search indexing and workflow delivery. Downstream systems otherwise receive different alert data than the database.

Important failure modes

TriggerConsequenceGuard
Provider raw-body parsing failsThe event is rejected with a malformed-event response before it enters the worker path.Provider-specific raw parsing and the provider endpoint's parse error boundary.
A provider formatter raises an exceptionThe event is not stored as a normal alert. Keep stores the raw event in the error-alert path and retries worker jobs when a worker context exists.process_event error handling and AlertRaw error records.
A Graylog event has an unsupported priority or missing required event fieldGraylog mapping fails before the event reaches normal persistence.The Graylog webhook and polling payload must provide an event ID, a priority from the supported range, and an event timestamp.
A Graylog event timestamp cannot be parsedGraylog mapping fails before the event reaches normal persistence.Graylog must send the timestamp in the format accepted by the provider mapper.
A Zabbix webhook sends an invalid event timestampZabbix formatting fails before the event reaches normal persistence.The webhook must send the expected Zabbix date format. Test notifications use a current UTC time instead of the template value.
Sentry returns an empty or non-JSON error during scope validationScope validation can no longer read a detail field from the response. The provider reports the HTTP status or a string response instead._extract_error_detail in SentryProvider.validate_scopes.
Sentry has no projects when no project is configuredEvent-read scope validation cannot choose a project to check. The provider reports No projects found.Project-list handling in validate_scopes.
A custom fingerprint rule differs between provider formatting, polling, and already parsed alertsThe same external signal can produce separate alert streams or bypass the configured deduplication rule.Shared custom fingerprint handling in BaseProvider.format_alert, BaseProvider.get_alerts, and BaseProvider.apply_custom_deduplication_rule.
A full duplicate arrivesNo new alert row is created. Only its latest receive time and audit record are updated.The full-duplicate branch in event persistence.
The latest event completes before an older retryThe older event must not replace the current last-alert pointer.Timestamp comparison in set_last_alert.
Elasticsearch indexing fails after database saveAlert history remains in the database, but the search copy can be stale or missing.Per-alert indexing error handling and database-backed alert reads.

Key files

FileWhy to read it
keep/…/preset.pyShows how provider polling starts and how pulled alerts enter shared processing.
keep/…/alerts.pyShows generic and provider event intake and asynchronous task handoff.
keep/…/process_event_task.pyShows the full path from normalized event to deduplication, persistence, indexing, and downstream delivery.
keep/…/base_provider.pyDefines the provider contract for polling, formatting, raw-body parsing, provider identity, and custom fingerprints.
keep/…/graylog_provider.pyShows how Graylog polling and webhook events map to Keep alerts and how Graylog notification delivery is connected.
keep/…/zabbix_provider.pyShows how Zabbix problems and webhook events become Keep alerts and how the provider link is installed.
keep/…/zabbix_provider_script.jsShows the Zabbix-side handoff that sends event data to Keep and checks the accepted response.
keep/…/sentry_provider.pyShows Sentry polling, webhook setup, scope validation, and event mapping.
keep/…/alert.pyDefines the common alert shape and validation rules.
keep/…/alert_deduplicator.pyExplains fingerprint-content comparison and duplicate classification.
keep/…/alert.pyShows the durable alert, last-alert, enrichment, raw-event, and deduplication records.
keep/…/db.pyShows persistence helpers for last-alert state and deduplication statistics.
keep/…/enrichment_helpers.pyExplains how stored enrichment and lifecycle counters are applied to alerts.
keep/…/elastic.pyShows how saved alerts are copied to the search index.