Architecture
This document describes the architecture of the Monitoring Extension.
The Monitoring Extension is built on three layers: an Exporter Custom Resource that declares the pipeline, a Crossplane composition that materializes stock Kubernetes resources from the CR, and a stock Telegraf pod that runs the data path.
Exporter
Exporter is a namespace-scoped Crossplane Composite Resource (XR) that serves as the operator-facing API. Each CR represents one independent export pipeline. All composed resources — the ConfigMap, the Helm Release, and the Telegraf pod — are created in the same namespace as the Exporter CR.
The CR schema has three top-level sections:
- spec.deployment — optional image and resource overrides for the Telegraf pod. When omitted, the composition uses its built-in defaults.
- spec.source — PromQL endpoint, authentication, polling parameters, and the list of metrics to export.
- spec.sink — discriminated union selecting the output type. Exactly one sink type must be specified. Currently only
elasticis supported.
Crossplane Composition
The composition processes each Exporter CR through a pipeline:
render-providerconfigs (
function-go-templating) — Creates namespace-scoped ProviderConfigs for the Kubernetes and Helm providers, scoped to the same namespace as theExporterCR.render-telegraf-toml (
function-go-templating) — Renders the full Telegraf TOML configuration from the XR fields using an inline Go template. The output is akubernetes.m.crossplane.io/v1alpha1Object that materializes as a ConfigMap named<name>-telegraf-confin the same namespace.observe-registry-secret + pull-registry-secret (
function-go-templating+function-extra-resources) — Mirrors thecennso-pull-secretas a read-only Object and fetches it into context. The next step uses it to conditionally switch the Telegraf image pull to the private OCI registry.render-helm-release (
function-go-templating) — Creates ahelm.m.crossplane.io/v1beta1Release that installs the official Telegraf chart. The composition wires the XR namespace, the step-2 ConfigMap as a mounted volume, the image override, and the OAuth2 Secret name as anenvFromSecretreference.sequence-creation (
function-sequencer) — Enforces creation order: ProviderConfigs → ConfigMap Object → Helm Release. The Helm Release is withheld from the desired state until the ConfigMap Object is Ready, preventing the Telegraf pod from starting before its configuration volume exists. On deletion, resources are removed in reverse order.auto-ready (
function-auto-ready) — Propagates the readiness of all composed resources to theExporterXR. The XR reportsReady=Trueonly when every composed resource (ProviderConfigs, ConfigMap Object, Helm Release) is Ready.
Telegraf Pod
The Telegraf pod is configured entirely by the rendered ConfigMap. It uses the following plugins:
The OAuth2 credentials Secret is projected as environment variables (client_id, client_secret, token_endpoint, api_endpoint) onto the Telegraf container. The rendered TOML reads them using Telegraf's built-in variable substitution (${client_id}, and so on). The api_endpoint variable holds the Elasticsearch HTTP URL.