Provider configuration and provisioning
Provider configuration and provisioning give Keep a repeatable way to connect a tenant to an external provider. A provider type defines the expected connection data and checks it when Keep creates the provider; the service then stores that data as a secret and keeps only its reference in the provider record. Provisioning can create, update, and remove these connections from startup configuration, while lifecycle APIs support direct changes.
This page covers the configuration side of provider integrations. For the runtime path after a provider is configured, see provider implementation and dispatch.
Configuration model
The provider configuration is a small object with a provider name and an authentication map. The authentication map carries the values needed by one provider, such as a URL, token, or account setting. ProviderConfig is the shared shape used when Keep turns this object into a provider instance (keep/…/provider_config.py• L34-57).
Each provider may declare an authentication model. The model describes the fields shown to users and applies the field rules when the provider starts. The provider catalog exposes these fields as config, so the same contract can guide setup in the UI and validation at runtime (keep/…/providers_factory.py• L145-171, keep/…/providers_factory.py• L363-369).
The installed provider record is separate from its configuration values. It identifies the tenant, name, type, owner, install time, pull setting, scope results, and a configuration_key that points to the secret holding the full configuration (keep/…/provider.py• L8-28). Provider names are unique within a tenant, which prevents two installed connections from using the same name (keep/…/provider.py• L8-10).
Provider-specific models make the connection contract explicit. Cilium needs a Hubble Relay endpoint and can use TLS with certificate files. Sentry needs an API key and organization slug, uses the Sentry API URL by default, and can limit access to one project. Kubernetes exposes an API server URL, a bearer token, TLS verification, and in-cluster configuration settings for cluster access (keep/…/cilium_provider.py• L14-70, keep/…/sentry_provider.py• L22-55, keep/…/kubernetes_provider.py• L14-55).
Configuration validation
Validation occurs when Keep builds a provider instance and when it checks the provider's access scopes. A configuration error stops provider creation; scope checks return a map in which each scope is either valid or has an error message. Installation rejects the request when a mandatory scope is not valid (keep/…/providers_service.py• L55-91).
Provider fields can also enforce shared value rules. For example, URL field types normalize supported input and reject a wrong scheme, bad port, or invalid host form (keep/…/fields.py• L6-47, keep/…/fields.py• L50-163). Cilium requires a base endpoint without a URL scheme. Its TLS and certificate settings are optional (keep/…/cilium_provider.py• L18-69). Sentry requires an API key and organization slug, defaults its API URL to https://sentry.io/api/0, and rejects a user token when an API token is required (keep/…/sentry_provider.py• L26-46, keep/…/sentry_provider.py• L118-127). Kubernetes accepts an HTTP API server URL and an optional bearer token. When both are present, it uses that manual connection path; otherwise it tries in-cluster configuration and then the local kubeconfig. The insecure setting controls TLS verification for manual access (keep/…/kubernetes_provider.py• L17-55, keep/…/kubernetes_provider.py• L92-122).
Providers declare the external access scopes that Keep checks before installation. Sentry requires event read and project read access. Project write access is optional for normal use but is required for webhook setup (keep/…/sentry_provider.py• L61-80). Cilium has no declared scope checks because its connection is validated through its configured relay endpoint (keep/…/cilium_provider.py• L85-94). Kubernetes declares one mandatory connection scope, so installation depends on a successful connection through its configured or runtime cluster access path (keep/…/kubernetes_provider.py• L64-71, keep/…/kubernetes_provider.py• L124-141).
Scope results are saved with the installed provider. A later scope check reads the current secret, tests the connection again, and updates the saved result when it changes (keep/…/providers_service.py• L372-398). This lets the system show a connection that was once installed but later lost access without changing the stored provider identity.
Secret references
Keep stores provider credentials outside the provider database record. During installation it writes a JSON object containing the provider name and authentication map to a secret manager, then stores the generated secret name in configuration_key (keep/…/providers_service.py• L166-210). Later reads use that key to rebuild the provider, so provider execution does not depend on credentials in ordinary provider metadata (keep/…/providers_factory.py• L560-609).
The secret manager is selected by SECRET_MANAGER_TYPE. The common contract supports read, write, and delete operations, with JSON parsing when a provider configuration is read (keep/…/secretmanager.py• L7-41, keep/…/secretmanagerfactory.py• L8-56). Keep supports file, database, Google Cloud, Kubernetes, Vault, and AWS backends through this contract (keep/…/secretmanagerfactory.py• L28-53).
Configuration references can also use environment values before the provider is built. A value written as $(NAME) is replaced with the value of NAME while Keep reads provider configuration from environment input (keep/…/parser.py• L307-380). YAML examples use this form for tokens, which keeps the token out of the file itself (examples/…/telegram-bot.yaml• L1-5). A missing environment value remains unresolved and is logged as a warning, so the later provider validation can fail with a configuration or connection error (keep/…/parser.py• L369-379).
Lifecycle APIs
The provider API exposes separate actions for discovery, creation, change, removal, and scope checks. These actions use tenant identity from the authenticated request and protect each operation with a provider permission (keep/…/providers.py• L68-110, keep/…/providers.py• L367-427).
| Operation | Interface | Result |
|---|---|---|
| Install | POST /providers/install | Creates a provider, validates mandatory scopes, writes its secret, and returns its ID and scope results (keep/…/providers.py• L470-534). |
| OAuth install | POST /providers/install/oauth2/{provider_type} | Converts the OAuth response into provider configuration, validates scopes, stores the provider, and can install its webhook (keep/…/providers.py• L537-623). |
| Update | PUT /providers/{provider_id} | Rebuilds the provider with the new values, validates scopes, replaces the secret, and updates the saved owner and pull setting (keep/…/providers.py• L430-467, keep/…/providers_service.py• L249-315). |
| Delete | DELETE /providers/{provider_type}/{provider_id} | Removes the secret and database record, unregisters an event consumer when needed, and asks the provider to clean up external state (keep/…/providers.py• L367-384, keep/…/providers_service.py• L317-369). |
| Scope check | POST /providers/{provider_id}/scopes | Reads the saved configuration and refreshes its scope result (keep/…/providers.py• L387-427). |
The install path returns a conflict when a tenant already has the same provider name. The update path accepts JSON or form data and converts uploaded file values to text before it validates the new configuration (keep/…/providers.py• L445-467).
YAML provisioning
Startup provisioning turns declarative provider input into installed providers for the single tenant. It accepts either a JSON value in KEEP_PROVIDERS or a directory named by KEEP_PROVIDERS_DIRECTORY; using both at once is an error. The broader startup sequence runs provider provisioning only when PROVISION_RESOURCES is enabled (keep/…/config.py• L19-44, keep/…/providers_service.py• L474-519).
Directory files use YAML with name, type, optional authentication, and optional webhook or deduplication settings. For example, examples/…/telegram-bot.yaml declares a Telegram connection and an environment-backed token (examples/…/telegram-bot.yaml• L1-5). Keep reads only .yaml and .yml files, installs valid entries as provisioned providers, and applies any file-level deduplication rules to the same provider (keep/…/providers_service.py• L608-712).
The provisioning cycle has a desired-state meaning. Each input entry is installed when absent and updated when its name already exists. A provisioned provider that is no longer present in the selected JSON input or directory is deleted. If no provisioning source is configured, all existing provisioned providers are removed (keep/…/providers_service.py• L487-504, keep/…/providers_service.py• L531-607, keep/…/providers_service.py• L719-730).
This diagram shows how startup input becomes provider state and how a later input change replaces the old desired state.
flowchart TD
A[Startup] --> B{Provisioning enabled?}
B -- No --> C[Keep existing state]
B -- Yes --> D{JSON or YAML directory}
D --> E[Parse provider entries]
E --> F[Install missing providers]
E --> G[Update named providers]
E --> H[Remove old provisioned providers]
F --> I[Write configuration secret]
G --> I
I --> J[Provider database record]
J --> K[Provider available to workflows and APIs]
Malformed YAML or an entry without its required type does not call provider installation for that file. Provisioning logs the error and continues with other files, so a deployment can start with some providers missing unless the surrounding startup checks those logs (tests/test_providers_yaml_provisioning.py• L135-185).
Reconfiguration behavior
Reconfiguration keeps the provider identity when the provider name remains the same. On the next provisioning run, Keep reads the new values, rebuilds the provider, validates its scopes only through the update path's provider check, and overwrites the existing secret. The database record keeps the provider ID and marks the source as provisioned (keep/…/providers_service.py• L547-583, keep/…/providers_service.py• L631-663).
Changing the desired set has a different effect. A new name creates a new provider, while a name removed from the JSON or YAML source removes the old provisioned provider and its secret. Direct API users cannot update or delete a provisioned provider unless the operation is performed by the provisioning path (keep/…/providers_service.py• L265-269, keep/…/providers_service.py• L331-335).
Provider creation can change authentication during initialization. This supports providers that receive a new token during an OAuth flow: if the provider changes the authentication map, the factory writes the changed map back to the provider secret even when initialization raises an error (keep/…/providers_factory.py• L110-142).
Webhook setup is optional during provisioning. The per-provider install_webhook value takes priority over the global KEEP_PROVIDERS_INSTALL_WEBHOOKS setting; if enabled, setup can add provider-generated values back into the same authentication secret (keep/…/providers_service.py• L547-601, keep/…/providers_service.py• L623-684). For Sentry, setup needs a public Keep URL and project write access. It adds the Keep webhook to the selected project or to all projects when no project is configured (keep/…/sentry_provider.py• L312-385).
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the provider authentication model, the catalog field metadata, and the provider's expected input names aligned. The catalog and runtime use the same provider-specific contract.
- Preserve
configuration_keyas the source for secret reads. Code that rebuilds an installed provider must not derive a different secret name from only its type and ID. - Keep the JSON and directory provisioning paths aligned when adding a supported provisioning option. They have different default values for webhook installation.
- Preserve the name-based desired-state rule. A rename is a delete-and-create operation for provisioned providers, not an update of the existing provider record.
- If a provider changes authentication during setup, keep the factory's write-back path compatible with the secret manager selected for the deployment.
- Keep provider-declared mandatory scopes aligned with the permissions needed by its optional webhook setup. Sentry needs project write access for webhook setup, while Cilium has no scope contract and depends on relay connectivity.
- Keep provider field metadata aligned with the values used by validation and webhook setup. Cilium certificate fields must remain file-based sensitive values, and Sentry's project scope must continue to control the webhook target.
- For Kubernetes, keep the manual API server and token path, the in-cluster fallback, and the mandatory connection scope aligned. A change to one path changes which configurations can pass installation.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A mandatory provider scope is missing or invalid | Installation returns 412 and no installed provider is created | Validate mandatory scopes before saving the provider record (keep/…/providers_service.py• L67-87). |
| A provider name already exists for the tenant | Installation returns 409; a temporary secret is removed | Use update for an existing name or choose a unique tenant-level name (keep/…/providers_service.py• L212-233). |
KEEP_PROVIDERS and KEEP_PROVIDERS_DIRECTORY are both set | Provisioning stops with a source-selection error | Configure one provisioning source only (keep/…/providers_service.py• L506-512). |
| A provisioned provider disappears from the desired source | The provider and its stored secret are deleted on the next cycle | Keep the entry in the selected source or accept deprovisioning (keep/…/providers_service.py• L719-730). |
| A provider secret cannot be read | The installed provider cannot be rebuilt or shown with details | Restore the configured secret manager entry and its configuration_key (keep/…/providers_factory.py• L488-537). |
| A URL or other typed field has an invalid value | Provider initialization fails before use | Use the provider's declared field rules and correct the input (keep/…/fields.py• L9-47). |
| Cilium receives an endpoint with a URL scheme or incomplete TLS material | Cilium initialization or relay access fails before topology can be read | Use the required no-scheme endpoint and provide matching certificate values when TLS is enabled (keep/…/cilium_provider.py• L18-69). |
| Kubernetes cannot connect through its manual or runtime cluster configuration | Its mandatory connection scope fails, so installation or a later scope check reports an error | Supply a valid API server and bearer token, or provide working in-cluster or kubeconfig access (keep/…/kubernetes_provider.py• L92-141). |
| Kubernetes receives only one part of the manual API server and token pair | The manual path is not used; cluster fallback may fail if no runtime configuration exists | Provide both manual values or ensure the runtime cluster configuration is available (keep/…/kubernetes_provider.py• L96-122). |
| Sentry receives a user token instead of an API token | Sentry provider initialization fails before scope checks or use | Supply an API token and the required organization slug (keep/…/sentry_provider.py• L118-127). |
| Sentry lacks project write access or Keep has a local-only URL during webhook setup | Webhook setup fails even when alert reads work | Grant the webhook scope and use a public Keep URL (keep/…/sentry_provider.py• L74-80, keep/…/sentry_provider.py• L312-325). |
| Zabbix configuration omits its frontend URL or authentication token | Zabbix provider initialization fails before scope checks or use | Supply both required authentication fields and keep the token in the configured secret reference (keep/…/zabbix_provider.py• L27-57, keep/…/zabbix_provider.py• L393-399). |
Key files
| File | Why to read it |
|---|---|
| keep/…/providers_service.py | Main lifecycle and desired-state flow for install, update, delete, scope checks, webhook setup, and provisioning. |
| keep/…/providers.py | HTTP contract and permission boundary for provider lifecycle actions. |
| keep/…/provider_config.py | Shared provider configuration and scope shapes. |
| keep/…/provider.py | Persistent provider identity, secret reference, scope result, and provisioned state. |
| keep/…/providers_factory.py | Bridge between provider type, authentication model, secret reference, and runtime provider instance. |
| keep/…/cilium_provider.py | Example of endpoint validation and optional TLS certificate configuration for a topology provider. |
| keep/…/sentry_provider.py | Example of token validation, project-scoped configuration, mandatory scopes, and public webhook setup. |
| keep/…/kubernetes_provider.py | Example of dual manual or cluster-based authentication, mandatory connection validation, and provider configuration metadata. |
| keep/…/zabbix_provider.py | Example of provider-specific required fields, mandatory scopes, and external webhook setup. |
| keep/…/parser.py | Environment and file input rules, including provider references used by workflows. |
| keep/…/secretmanagerfactory.py | Secret backend selection and the supported storage boundary. |
| keep/…/config.py | Startup order and the switch that enables resource provisioning. |
| keep/…/fields.py | Shared URL and host value rules used by provider authentication models. |
| examples/…/telegram-bot.yaml | Small example of YAML provider input with a secret supplied by an environment reference. |