Grafana Dashboard Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Grafana dashboard configuration in Kuberhealthy provides a visual representation of synthetic monitoring results and cluster health states. It integrates with Prometheus as a data source to surface metrics generated by Kuberhealthy checks, enabling operators to monitor continuous process verification in real-time.
The configuration consists of a pre-defined JSON dashboard definition that can be deployed via a Kubernetes ConfigMap using Helm or imported manually. This dashboard translates raw Prometheus gauge metrics into human-readable statuses like "Running", "Healthy", or "Unhealthy".
Sources: README.md:16-20, deploy/grafana/README.md:1-4, deploy/helm/kuberhealthy/templates/grafana-dashboard.yaml:1-20
Architecture and Data Flow
The visualization layer relies on Kuberhealthy's metrics exporter to convert internal state into Prometheus-compatible formats. These metrics are then scraped by Prometheus and queried by Grafana panels using PromQL expressions.
The diagram above shows the flow from Kuberhealthy state generation to visual representation in Grafana.
Sources: pkg/metrics/exporter.go:49-55, deploy/grafana/dashboard.json:80-90, README.md:38-40
Dashboard Components and Metrics
The Kuberhealthy dashboard includes several panels designed to provide both high-level health status and granular check history.
Primary Metrics
The dashboard primarily consumes metrics prefixed with kuberhealthy_. Key metrics used in the configuration include:
| Metric Name | Type | Description | Values |
|---|---|---|---|
kuberhealthy_running | Gauge | Indicates if the Kuberhealthy operator is running error-free. | 1 (Running), 0 (Not Running) |
kuberhealthy_cluster_state | Gauge | Represents the aggregate health of the cluster based on all checks. | 1 (Healthy), 0 (Unhealthy) |
kuberhealthy_check | Gauge | Status of specific individual synthetic checks (e.g., daemonset, deployment). | 1 (OK), 0 (Error) |
Sources: pkg/metrics/exporter.go:53-61, deploy/grafana/dashboard.json:138-144, deploy/helm/kuberhealthy/templates/grafana-dashboard.yaml:89-106
Visualization Panels
- Kuberhealthy Running (Stat Panel): A single-stat panel that monitors the
avg(kuberhealthy_running)metric. It uses value mapping to display "Running" for value 1 and "Not Running" for 0. - Cluster Health (Stat Panel): Monitors
avg(kuberhealthy_cluster_state). It provides an immediate visual indicator of whether the cluster is "Healthy" or "Unhealthy". - Kuberhealthy History (Time Series): Tracks the historical trends of both operator health and cluster state over time.
- Kuberhealthy Check Status (Table): Displays a detailed table of individual checks using
avg(kuberhealthy_check) by(check).
Sources: deploy/grafana/dashboard.json:115-165, deploy/helm/kuberhealthy/templates/grafana-dashboard.yaml:35-85
Helm Deployment Configuration
The dashboard is typically deployed as a Kubernetes ConfigMap labeled for automatic discovery by Grafana's sidecar (often used in the Prometheus-stack).
Values.yaml Configuration
Users can enable the dashboard and customize its metadata through the Helm chart values:
prometheus:
grafanaDashboard:
enabled: true
label: grafana_dashboard
labelValue: "1"
additionalLabels: {}
annotations: {}
namespace: ""
Sources: deploy/helm/kuberhealthy/values.yaml:20-29
ConfigMap Template
The grafana-dashboard.yaml template wraps the dashboard.json content into a ConfigMap. It uses the labels defined in values.yaml to ensure Grafana detects and imports the dashboard.
This flowchart illustrates how Helm values drive the creation of a discoverable ConfigMap for Grafana.
Sources: deploy/helm/kuberhealthy/templates/grafana-dashboard.yaml:1-18
Metric Labels and Mapping
Kuberhealthy's metrics exporter adds metadata labels that are utilized in dashboard tooltips and legend formats.
Label Structure
- check: The name of the specific check (e.g.,
daemonset-check). - namespace: The namespace where the check was executed.
- status: The boolean result of the check.
- error: If
SuppressErrorLabelis false, this contains the concatenated error strings from the check result.
Sources: pkg/metrics/exporter.go:23-45, deploy/grafana/dashboard.json:341-350
Conclusion
The Grafana dashboard configuration for Kuberhealthy serves as the primary visual interface for the operator's synthetic monitoring capabilities. By mapping Prometheus metrics to intuitive statuses and historical graphs, it allows for rapid assessment of cluster integrity and individual check performance. The configuration is flexible, supporting both manual JSON imports and automated discovery via Helm-managed Kubernetes ConfigMaps.