Skip to main content

Prometheus Metrics

Operator v0.2.17 exposes two independent classes of metrics. They must be scraped separately:

TargetDefault endpointDiscovery
Operator controller:9090/metricsServiceMonitor or pod annotations
Backup/restore Job pod:8080/metricsPodMonitor

The operator does not proxy Job metrics. Enabling only serviceMonitor does not collect backup progress.

Enable Prometheus Operator discovery

The ServiceMonitor and PodMonitor require the Prometheus Operator CRDs.

values.yaml
metrics:
enabled: true
serviceMonitor:
enabled: true
interval: 30s
scrapeTimeout: 10s
jobPodMonitor:
enabled: true
interval: 30s
scrapeTimeout: 10s
helm upgrade --install strimzi-backup-operator \
oso-devops/strimzi-backup-operator \
--namespace kafka \
--create-namespace \
--version 0.2.17 \
--values values.yaml

The Job PodMonitor selects pods labelled app.kubernetes.io/managed-by=kafka-backup-operator and kafkabackup.com/metrics=enabled. Its default namespaceSelector.any: true is intentional: custom resources can live outside the Helm release namespace.

If you set a custom spec.metrics.path, also set metrics.jobPodMonitor.path to the same value.

Configure a backup or restore

Metrics are enabled by default for Job pods. For one-shot operations, keep the endpoint alive long enough for Prometheus to scrape the final values. A useful minimum is twice the scrape interval:

spec:
metrics:
enabled: true
port: 8080
bindAddress: "0.0.0.0"
path: /metrics
updateIntervalMs: 500
keepAliveSeconds: 60
maxPartitionLabels: 100

maxPartitionLabels limits unique topic/partition/backup_id label sets, not metric updates. Set it to 0 only if unlimited per-partition cardinality is acceptable. Aggregate lag and snapshot progress remain available when the per-partition limit is reached.

Operator metrics

The controller endpoint currently publishes these populated metric families:

MetricLabelsDescription
strimzi_backup_operator_build_infoversionRunning operator build
strimzi_backup_operator_reconciliations_totalcontroller, resultReconciliations by controller and result
strimzi_backup_operator_reconciliation_duration_secondscontroller, resultReconciliation duration histogram

Check it without Prometheus:

kubectl port-forward -n kafka \
svc/strimzi-backup-operator-metrics 9090:9090
curl --fail http://127.0.0.1:9090/metrics

Job progress metrics

The Job endpoint uses the kafka-backup runtime metrics. Useful v0.15.11 families include:

MetricDescription
kafka_backup_lag_recordsCurrent lag for an admitted topic/partition series
kafka_backup_lag_records_sumCurrent lag summed across all partitions
kafka_backup_snapshot_records_targetRecords in the captured finite-backup offset range
kafka_backup_snapshot_records_remainingRecords left before the finite backup completes
kafka_backup_records_totalRecords backed up
kafka_backup_bytes_totalUncompressed bytes backed up
kafka_backup_errors_totalErrors by backup and category
kafka_restore_progress_percentRestore completion percentage

Example progress query:

100 * (
1 - kafka_backup_snapshot_records_remaining
/ clamp_min(kafka_backup_snapshot_records_target, 1)
)

Use CR status for durable success/failure history. A completed one-shot Job's in-process metrics disappear when its pod exits, even when Prometheus scraped the final sample successfully.