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 / provider-implementation-and-dispatch

Provider implementation and dispatch

Providers are the adapter layer that lets Keep read data from external systems, send actions to them, and turn incoming events into Keep alerts or incidents. A shared provider contract keeps these tasks consistent while each provider package handles the rules and API shape of one external system. For the wider integration model, see Provider integrations; for installation and stored configuration, see Provider configuration and provisioning.

Provider contract

The provider contract gives workflow execution and event intake one common way to use different services. A provider instance carries the tenant context, provider identity, validated configuration, and state needed during one operation.

Common provider lifecycle

BaseProvider defines the shared boundary for provider packages. A provider validates its configuration when it starts, derives its provider type from the provider class, and then exposes common operations for queries, notifications, alert conversion, scope checks, cleanup, and optional webhook setup (keep/…/base_provider.py• L47-181, keep/…/base_provider.py• L183-202).

The public query and notify methods add Keep behavior around provider-specific work. They remove Keep-only parameters, call the provider implementation, retain results in the provider context, and apply requested alert enrichment. The query path also records result types as workflow dependencies. The provider-specific _query and _notify methods focus on the external system (keep/…/base_provider.py• L183-202, keep/…/base_provider.py• L371-408).

References: keep/…/base_provider.py• L47-181 keep/…/base_provider.py• L183-202 keep/…/base_provider.py• L371-408

Capability families

Provider capabilities are optional. The base contract supports these broad families:

  • Read and write operations: _query reads data and _notify sends a message or performs a change.
  • Alert intake: _format_alert maps a source event to one or more Keep alerts. format_alert adds provider identity and applies custom fingerprint rules.
  • Alert polling: _get_alerts supplies alerts for providers that pull from a source instead of waiting for a webhook.
  • Topology and incidents: BaseTopologyProvider adds topology pulls. BaseIncidentProvider adds incident reads, event conversion, and incident webhook setup.
  • Provider methods: PROVIDER_METHODS exposes named provider-specific views or actions outside the basic query and notify pair.

The factory uses these capabilities to describe what a provider can do. It marks whether the provider can query, notify, pull alerts, pull topology, receive incidents, install webhooks, or report health (keep/…/providers_factory.py• L304-400). Cilium is an example of a topology provider. It turns Hubble Relay flow data into service relationships, including links to external destinations and application relations (keep/…/cilium_provider.py• L73-89, keep/…/cilium_provider.py• L125-327). Graylog illustrates a monitoring provider that combines searchable data, pulled alerts, a named search action, and webhook intake (keep/…/graylog_provider.py• L69-122, keep/…/graylog_provider.py• L549-662, keep/…/graylog_provider.py• L780-829). Kubernetes illustrates a query-and-action provider. It exposes cluster reads through query and operational changes through notify (keep/…/kubernetes_provider.py• L143-281).

References: keep/…/base_provider.py• L392-507 keep/…/base_provider.py• L560-664 keep/…/base_provider.py• L883-1001 keep/…/providers_factory.py• L304-400 keep/…/cilium_provider.py• L73-89 keep/…/cilium_provider.py• L125-327 keep/…/graylog_provider.py• L69-122 keep/…/graylog_provider.py• L549-662 keep/…/graylog_provider.py• L780-829 keep/…/kubernetes_provider.py• L58-71 keep/…/kubernetes_provider.py• L143-281 keep/…/zabbix_provider.py• L60-206 keep/…/zabbix_provider.py• L523-718

Provider selection

Provider selection turns a provider type and a tenant installation into a live provider instance. The factory owns class lookup and instance construction. The service layer coordinates that factory with tenant records and the secret store.

Provider class lookup

Provider types follow a package naming convention. A type such as prometheus maps to the prometheus_provider package and its provider module. A dotted type uses the first part for the package and the later part to select a subtype class, which lets one package serve related provider variants (keep/…/providers_factory.py• L63-91).

The factory also discovers provider packages to build the provider catalog. It reads class-level metadata to describe display names, categories, tags, scopes, methods, webhook support, alert examples, health support, and available pull features. This catalog is cached for reuse and is separate from the list of providers installed for a tenant (keep/…/providers_factory.py• L252-476).

References: keep/…/providers_factory.py• L63-91 keep/…/providers_factory.py• L252-476

Tenant provider instances

An installed provider is selected by tenant ID, provider ID, and provider type. The factory reads the installation's configuration from the secret manager, wraps it in ProviderConfig, finds the provider class, and constructs the instance with a ContextManager (keep/…/providers_factory.py• L560-609).

This separation lets the same provider class serve many tenants and many installations. The database identifies the installation and its secret key. The provider instance receives the resulting configuration and tenant context for the duration of the request or workflow (keep/…/providers_factory.py• L478-537, keep/…/providers_service.py• L145-247).

The main provider API follows the same path. It lists the catalog with installed and linked provider views, and it rebuilds a provider instance before provider-specific reads, writes, logs, tests, or alert deployment (keep/…/providers.py• L68-110, keep/…/providers.py• L159-220, keep/…/providers.py• L285-320).

References: keep/…/providers_factory.py• L478-537 keep/…/providers_factory.py• L560-609 keep/…/providers_service.py• L145-247 keep/…/providers.py• L68-110 keep/…/providers.py• L159-220 keep/…/providers.py• L285-320

Authentication conventions

Authentication is provider-owned but follows a shared shape. Installation passes a configuration object with an authentication map. Each provider validates that map with its own typed authentication configuration and uses the result for later calls.

Authentication configuration

An AuthConfig class is the provider's contract for credentials and connection settings. Its fields define required values, safe defaults, sensitive values, input hints, and basic validation metadata. The factory reads this metadata to build the provider configuration shown to users (keep/…/provider_config.py• L34-57, keep/…/providers_factory.py• L145-171, keep/…/providers_factory.py• L363-368). Kubernetes uses the same contract for either a remote API server and bearer token or a cluster-provided identity. It also exposes TLS verification as a connection choice (keep/…/kubernetes_provider.py• L13-55).

The base ProviderConfig keeps authentication separate from the provider name and description. It also expands supported {{env.*}} values before the provider validates the configuration. The provider then converts the authentication map to its typed configuration during initialization (keep/…/provider_config.py• L34-57). Sentry illustrates an API-token convention. Its auth config requires an API key and organization slug, uses the Sentry API as the default endpoint, and can narrow access to one project (keep/…/sentry_provider.py• L22-55). Cilium illustrates a connection convention rather than a bearer token. It requires a Hubble Relay endpoint and can use a CA certificate plus client certificate and key for TLS (keep/…/cilium_provider.py• L14-71). Graylog uses a user name, access token, deployment URL, and an SSL verification choice. It sends the token through the external service's token authentication form (keep/…/graylog_provider.py• L30-66, keep/…/graylog_provider.py• L274-283).

References: keep/…/provider_config.py• L12-57 keep/…/providers_factory.py• L145-171 keep/…/providers_factory.py• L363-368 keep/…/cilium_provider.py• L14-71 keep/…/kubernetes_provider.py• L13-55 keep/…/sentry_provider.py• L22-55 keep/…/slack_provider.py• L20-66 keep/…/zabbix_provider.py• L27-57 keep/…/zabbix_provider.py• L393-399 keep/…/graylog_provider.py• L30-66 keep/…/graylog_provider.py• L274-283

Scope validation

Scopes are named checks that show whether an installation has the access needed for a capability. A provider declares its scopes with ProviderScope values and returns a result for each check. Installation rejects the provider when a mandatory scope does not validate (keep/…/provider_config.py• L12-31, keep/…/providers_service.py• L55-91).

The check is provider-specific. Prometheus tests access to its alert endpoint, SSH checks an authenticated connection, and GCP Monitoring checks access to logs. Sentry checks event and project read access, with project write access required for webhook setup. Graylog checks that the configured user can authenticate and has the required admin role. Kubernetes treats a successful client connection as its mandatory access check. The result can be True or a readable error string, so the caller can show which access check failed (keep/…/prometheus_provider.py• L92-118, keep/…/ssh_provider.py• L136-152, keep/…/gcpmonitoring_provider.py• L86-132, keep/…/kubernetes_provider.py• L124-141, keep/…/sentry_provider.py• L57-80, keep/…/sentry_provider.py• L168-223, keep/…/graylog_provider.py• L303-339, keep/…/zabbix_provider.py• L71-156, keep/…/zabbix_provider.py• L401-424). Cilium has no remote scope check because its connection is validated by its configured endpoint and channel setup (keep/…/cilium_provider.py• L85-94).

References: keep/…/provider_config.py• L12-31 keep/…/providers_service.py• L55-91 keep/…/prometheus_provider.py• L92-118 keep/…/ssh_provider.py• L136-152 keep/…/gcpmonitoring_provider.py• L86-132 keep/…/kubernetes_provider.py• L82-141 keep/…/cilium_provider.py• L85-94 keep/…/sentry_provider.py• L57-80 keep/…/sentry_provider.py• L168-223 keep/…/graylog_provider.py• L303-339 keep/…/zabbix_provider.py• L71-156 keep/…/zabbix_provider.py• L401-424

OAuth authentication

OAuth is an alternate installation path for providers that set an OAuth URL and implement oauth2_logic. The route passes the callback payload to the provider. The provider exchanges the authorization data for credentials, returns the authentication map, and then enters the same instance, scope, secret, and database flow as a direct installation (keep/…/providers.py• L537-623, keep/…/base_provider.py• L732-740).

The provider can return a name from the remote service so the installation gets a stable user-facing name. Slack follows this pattern and stores the returned access token as provider authentication data (keep/…/slack_provider.py• L74-109). If a provider refreshes or changes authentication data while it starts, the factory writes the changed authentication map back to the installation secret (keep/…/providers_factory.py• L110-143).

References: keep/…/providers.py• L537-623 keep/…/base_provider.py• L732-740 keep/…/slack_provider.py• L74-109 keep/…/providers_factory.py• L110-143

Action dispatch

Action dispatch connects workflow steps and provider API calls to the correct provider operation. The dispatch path renders workflow values, applies workflow controls, and then calls the common provider entry point or a declared special method.

Workflow query and notification flow

For a workflow step, Keep selects query mode or action mode before execution. It renders provider parameters from the workflow context, checks conditions and throttling, and calls provider.query for a step or provider.notify for an action. A successful result is placed back into the step context for later workflow use (keep/…/step.py• L162-243, keep/…/step.py• L304-386).

The flow below shows the boundary between workflow control and provider-specific behavior.

flowchart LR
    A[Workflow step] --> B[Render parameters]
    B --> C{Condition and throttle pass?}
    C -- No --> D[Skip operation]
    C -- Yes --> E{Step type}
    E -- Query step --> F[provider.query]
    E -- Action step --> G[provider.notify]
    F --> H[Provider _query]
    G --> I[Provider _notify]
    H --> J[Step context]
    I --> J

Retries belong to the workflow step boundary. A provider failure is retried according to the step policy. If all tries fail, the step raises an action error instead of hiding the provider failure (keep/…/step.py• L331-386).

References: keep/…/step.py• L162-243 keep/…/step.py• L304-386 keep/…/base_provider.py• L183-202 keep/…/base_provider.py• L371-408

Special method dispatch

Special methods are named provider operations that need more specific inputs than a general query or notification. A provider declares each method with a display name, function name, description, category, type, and required scopes. The factory inspects the function signature and adds parameter information for the caller (keep/…/provider_method.py• L20-40, keep/…/providers_factory.py• L212-250).

The provider API resolves the installed instance, finds the requested method by name, and passes the request body as keyword arguments. This supports read-only views and state-changing actions while preserving provider-owned validation and error handling. ServiceNow illustrates the split between incident views and an incident activity action (keep/…/providers.py• L672-753, keep/…/servicenow_provider.py• L121-143). Zabbix uses the same contract for problem actions such as acknowledge, suppress, close, and change severity, plus a view for problem messages (keep/…/zabbix_provider.py• L157-206, keep/…/zabbix_provider.py• L246-391). Graylog exposes a Search method through this path. It accepts query text, query mode, time range, and paging values, then returns matching log messages (keep/…/graylog_provider.py• L114-122, keep/…/graylog_provider.py• L157-234).

References: keep/…/provider_method.py• L20-40 keep/…/providers_factory.py• L212-250 keep/…/providers.py• L672-753 keep/…/servicenow_provider.py• L121-143 keep/…/zabbix_provider.py• L157-206 keep/…/zabbix_provider.py• L246-391 keep/…/graylog_provider.py• L114-122 keep/…/graylog_provider.py• L157-234

Provider package capabilities

Each provider package adapts one external service to the shared contract. The package owns remote API calls, source-to-Keep field mapping, provider-specific validation, and any extra capability it declares.

Read and write adapters

Read providers implement _query and return data that workflow steps can use. Write providers implement _notify and accept action parameters from a workflow. A provider can implement both, as WebhookProvider and KubernetesProvider do, or only one, as PrometheusProvider does for queries and alert reads (keep/…/webhook_provider.py• L148-181, keep/…/kubernetes_provider.py• L143-281, keep/…/prometheus_provider.py• L120-169, keep/…/prometheus_provider.py• L244-248).

The shared wrapper does not force one remote protocol. A package can use an HTTP API, a client library, a database connection, or another service-specific transport. The important contract is the direction of the capability and the shape of the result that Keep receives. Graylog supports both direct log search and alert-oriented reads. A query with search text uses its log search action, while a query without search text returns recent alert events (keep/…/graylog_provider.py• L157-234, keep/…/graylog_provider.py• L780-829). Kubernetes follows the same boundary for cluster operations. Its query side reads logs, events, and common cluster resources, while its notify side performs restarts, node scheduling changes, scaling, eviction, and pod command execution (keep/…/kubernetes_provider.py• L143-281).

References: keep/…/webhook_provider.py• L148-181 keep/…/kubernetes_provider.py• L143-281 keep/…/prometheus_provider.py• L120-169 keep/…/prometheus_provider.py• L244-248 keep/…/ssh_provider.py• L154-166 keep/…/graylog_provider.py• L780-829

Alert and incident adapters

Incoming source data must become Keep alert or incident models before it enters the alert system. Provider packages implement the mapping from source fields to status, severity, service, labels, message, and fingerprint inputs. The base class then adds provider identity and applies tenant-specific deduplication rules (keep/…/base_provider.py• L428-581).

Providers can support push intake through webhook templates or pull intake through _get_alerts. Incident-capable packages use the incident base contract instead of treating incidents as ordinary alerts. Sentry supports both intake patterns. It maps Sentry event fields to Keep alert status, severity, service, environment, tags, and fingerprint values for pushed events. Its pull path reads events and related issues across one project or an organization (keep/…/base_provider.py• L603-633, keep/…/sentry_provider.py• L225-310, keep/…/sentry_provider.py• L443-548). Zabbix also supports both paths. Its pull path reads recent problems, while its push path maps event fields, tags, status, severity, and event links into Keep alerts. It uses the event ID as a stable fingerprint field (keep/…/prometheus_provider.py• L171-236, keep/…/servicenow_provider.py• L344-367, keep/…/servicenow_provider.py• L664-681, keep/…/zabbix_provider.py• L65-66, keep/…/zabbix_provider.py• L489-566, keep/…/zabbix_provider.py• L719-787). Graylog maps each event to a firing alert. The event ID forms the fingerprint because Graylog sends an alert instance once and its event-definition ID can repeat across alert instances (keep/…/graylog_provider.py• L124-133, keep/…/graylog_provider.py• L664-689, keep/…/graylog_provider.py• L780-808).

References: keep/…/base_provider.py• L428-581 keep/…/base_provider.py• L603-633 keep/…/base_provider.py• L928-1001 keep/…/prometheus_provider.py• L171-236 keep/…/sentry_provider.py• L225-310 keep/…/sentry_provider.py• L443-548 keep/…/servicenow_provider.py• L344-367 keep/…/servicenow_provider.py• L664-681 keep/…/zabbix_provider.py• L65-66 keep/…/zabbix_provider.py• L489-566 keep/…/zabbix_provider.py• L719-787 keep/…/graylog_provider.py• L124-133 keep/…/graylog_provider.py• L664-689 keep/…/graylog_provider.py• L780-808

Topology adapters

Topology providers turn service or flow data from an external system into Keep's service graph. They return services with dependencies and context such as namespace, category, tags, and application relations so downstream topology views can connect runtime behavior to owned services.

Cilium reads flow data from Hubble Relay and groups the observed source and destination endpoints into service relationships. It treats external destinations as internet services, uses workload and Kubernetes label data to name services, and links services to applications marked by Keep labels (keep/…/cilium_provider.py• L96-123, keep/…/cilium_provider.py• L125-327).

References: keep/…/base_provider.py• L928-1001 keep/…/cilium_provider.py• L96-123 keep/…/cilium_provider.py• L125-327

Webhook and consumer adapters

Webhook support lets an external service push events to Keep. A provider can supply webhook setup logic and templates. The service creates the Keep webhook endpoint and API key, calls the provider setup method, and saves any provider-specific values returned by that method (keep/…/providers_service.py• L405-472, keep/…/providers.py• L756-833).

Sentry uses this setup path to add Keep's callback URL to each selected project, enable the remote webhook plugin, and create an alert rule that sends events to the webhook (keep/…/sentry_provider.py• L312-441). The configured API key then lets the pushed event enter the provider's alert formatter. Graylog uses the same setup boundary for a different remote model. It whitelists the Keep URL, replaces any prior Keep notification, creates a version-specific HTTP notification, and attaches it to Graylog event definitions (keep/…/graylog_provider.py• L549-662).

Consumer providers use a separate long-running event path. A provider signals this capability by overriding start_consume; installation then registers the instance with the event subscriber. This allows event sources such as queues to feed Keep without changing the workflow query and notification contract (keep/…/base_provider.py• L782-812, keep/…/providers_service.py• L197-240). Zabbix uses webhook setup to create or update a remote script and an action. The script forwards event data to Keep, and the provider reuses its API access to manage that remote setup (keep/…/zabbix_provider.py• L568-718).

References: keep/…/providers_service.py• L405-472 keep/…/providers.py• L756-833 keep/…/base_provider.py• L689-812 keep/…/providers_service.py• L197-240 keep/…/sentry_provider.py• L312-441 keep/…/graylog_provider.py• L549-662 keep/…/zabbix_provider.py• L568-718

Change checklist

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

  • A provider type change must stay aligned with its package name, module name, class name, installation records, and any dotted subtype name used by the factory.
  • An authentication field change must keep the typed auth config, its metadata, OAuth output, secret contents, and provider validation in agreement.
  • A capability change must update the provider class metadata and the implementation that backs the catalog's capability flags.
  • A special method change must keep its declared function name, callable signature, scope names, and request body contract aligned.
  • An alert mapping or fingerprint change must be checked against both webhook formatting and pulled-alert handling because both paths apply provider identity and deduplication.
  • A topology mapping change must preserve service names, dependency direction, namespace values, and application relations expected by the topology model.
  • Webhook setup changes must preserve the endpoint form, API-key use, returned authentication fields, and the saved provider secret.
  • A provider API compatibility change must preserve any version fallback that supports the external service versions accepted by the provider.
  • A Graylog webhook or alert change must preserve the event-definition notification link, Graylog version-specific URL and notification forms, and the event ID fingerprint contract.
  • A Kubernetes authentication change must keep the remote API-server path and the cluster-identity path valid, including the TLS verification choice used by each path.
  • A Kubernetes query or action change must keep the public command_type or action value aligned with its required inputs and result shape.

Important failure modes

TriggerConsequenceGuard
Provider type does not match the package or class naming conventionThe factory cannot load or construct the providerKeep the type, package, module, and class names aligned with factory lookup
Required authentication field is missing or invalidProvider initialization fails before an installation or action can runDefine the field in the provider auth config and validate it at initialization
A mandatory scope returns false or an error stringProvider installation or scope validation is rejectedMake scope names match the declared ProviderScope values and test the real remote access
A special method is not declared or its request parameters differ from its signatureThe invoke request returns “Method not found” or a parameter errorKeep ProviderMethod.func_name and the callable signature aligned
Alert formatting produces unstable or non-unique fingerprint inputsAlerts split into duplicates or merge unrelated eventsMap stable source fields and review custom fingerprint rules
Topology data has no usable service name or loses dependency directionThe service graph contains unknown nodes or incorrect relationshipsKeep workload, label, pod, and external-destination fallbacks aligned with the topology model
Provider setup returns new webhook credentials but does not expose them to the serviceThe remote webhook may work once but later instances lack its required dataReturn extra authentication values from setup and persist them through the service
A Sentry token is a user token or lacks project write access for webhook setupSentry validation or webhook installation fails even when read access worksUse an API token and validate the scope required by the selected capability
Graylog user authentication succeeds without the required admin roleScope validation rejects the installation or webhook setup cannot manage Graylog resourcesKeep the authorized scope tied to the configured user's admin role
A Graylog version receives the wrong webhook URL or notification shapeEvents do not reach Keep or remote notification setup failsKeep the version-specific API-key placement and notification type aligned with the supported Graylog version
Graylog alert mapping uses a repeated event-definition value as the fingerprintSeparate alert instances merge and later alerts are suppressedUse the unique Graylog event ID for the fingerprint
An external API version rejects a request field used by a providerScope checks, alert reads, actions, or webhook setup fail even when the token is validKeep the provider's compatibility fallback and verify the request against supported service versions
Kubernetes has neither usable remote credentials nor cluster configurationScope validation and every later query or action fail before the provider can reach the clusterProvide an API server with a bearer token or a working cluster identity and kubeconfig fallback
A Kubernetes action receives the wrong resource name, namespace, or required argumentThe requested cluster change fails or targets a different resource than intendedKeep each action's input contract explicit and validate the target resource before the change
Kubernetes drain meets a disruption budget or protected emptyDir dataThe result reports partial success and some pods remain on the nodeReview force, ignore_daemonsets, and delete_emptydir_data before using a drain action

Key files

FileWhy to read it
keep/…/base_provider.pyDefines the shared provider lifecycle, query and notify wrappers, alert conversion, topology and incident extensions, webhook hooks, and consumer signals.
keep/…/providers_factory.pyShows provider type lookup, catalog discovery, tenant instance construction, scope metadata, and method parameter discovery.
keep/…/providers_service.pyConnects provider instances to installation, scope checks, secrets, webhooks, consumer registration, and tenant state.
keep/…/providers.pyShows the external API paths for listing, installing, testing, invoking, updating, and dispatching provider operations.
keep/…/step.pyShows how workflow steps render inputs and dispatch queries or actions through the common provider interface.
keep/…/provider_config.pyDefines the shared authentication container and provider scope model.
keep/…/provider_method.pyDefines the metadata contract for provider-specific views and actions.
keep/…/cilium_provider.pyIllustrates a topology provider that authenticates to Hubble Relay and maps flow data into service dependencies and application relations.
keep/…/graylog_provider.pyIllustrates a monitoring provider with typed token authentication, role-based scope checks, log search, pulled and pushed alerts, a named search method, and version-aware webhook setup.
keep/…/kubernetes_provider.pyIllustrates a query-and-action provider with remote or in-cluster authentication, connection scope validation, resource reads, and cluster operations.
keep/…/prometheus_provider.pyIllustrates a monitoring provider that validates access, queries data, pulls alerts, and maps source alerts into Keep alerts.
keep/…/sentry_provider.pyIllustrates a monitoring provider with API-token authentication, read and webhook scopes, pulled and pushed alerts, and remote webhook setup.
keep/…/slack_provider.pyIllustrates a notification provider with typed credentials, direct webhook or token auth, and OAuth installation.
keep/…/webhook_provider.pyIllustrates a general-purpose provider that supports both query and notify paths with several auth forms.
keep/…/servicenow_provider.pyIllustrates a provider with incident and topology capabilities plus declared special methods.
keep/…/zabbix_provider.pyIllustrates a monitoring provider with token authentication, scope checks, pulled and pushed alerts, problem actions, and remote webhook setup.