- Exposing FluxCD metrics via
/metrics - Leveraging the Prometheus Operator for auto-discovery
- Configuring a
PodMonitorfor Flux controllers - Inspecting generated Prometheus scrape configs
- Building a Grafana dashboard for FluxCD health and performance
1. FluxCD Metrics Overview
Flux controllers expose Prometheus metrics on port 8080 at the/metrics endpoint. By deploying the Prometheus Operator, you can manage Prometheus, Alertmanager, and Grafana components using Kubernetes custom resources.
2. Prometheus Operator and Auto-Discovery
The Prometheus Operator discovers scrape targets via theServiceMonitor and PodMonitor CRDs. To include Flux controllers:
- Deploy a
PodMonitorthat targets Flux pods in theflux-systemnamespace - Ensure each controller pod is annotated for Prometheus scraping
3. Inspecting Prometheus Configuration
After installing the Prometheus Operator, you can verify the scrape configuration that gets generated:scrape_configs:
4. Enabling Flux Controller Metrics
4.1 Annotate Flux Pods
Verify that each Flux controller pod is annotated for Prometheus. For example, inspect thesource-controller pod:
4.2 Create a PodMonitor
Make sure the
targetPort matches the container port (default is 8080) and the path is /metrics.PodMonitor to enable Prometheus scraping for all Flux controllers:
5. Visualizing Metrics in Grafana
Import or build a Grafana dashboard to monitor:| Metric Category | Description |
|---|---|
| Health Checks | Number of successful vs. failed reconciliations |
| Reconciliation Latency | Time taken per reconciliation cycle |
| Event Counts | Total events processed by each controller |
| Errors & Warnings | Count and rate of errors in FluxCD controllers |
- Open your Grafana UI.
- Create a new dashboard or import a JSON template.
- Add panels for FluxCD metrics, e.g.,
flux_reconcile_duration_secondsflux_reconcile_errors_totalflux_reconcile_success_total