Skip to content

Longhorn monitoring with grafana and prometheus

Article Number: 000022128

Environment

SUSE Rancher Longhorn

Procedure

Overview

Longhorn integrates seamlessly with Prometheus, providing comprehensive visibility into the health and performance of your storage environment. Prometheus collects a wide range of metrics across Longhorn and related system components, enabling effective monitoring of volumes, disks, and nodes throughout the cluster.

Rancher integrates Prometheus and Grafana to monitor Kubernetes nodes, components, and workloads. To enable Rancher Monitoring refer the official documentation.

If Rancher Monitoring is already enabled, Longhorn metrics can be scraped by deploying a ServiceMonitor in the Longhorn-system namespace.

Step 1: Deploy Longhorn ServiceMonitor

Apply the following manifest:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: longhorn-prometheus-servicemonitor
  namespace: longhorn-system
  labels:
    name: longhorn-prometheus-servicemonitor
spec:
  selector:
    matchLabels:
      app: longhorn-manager
  namespaceSelector:
    matchNames:
    - longhorn-system
  endpoints:
  - port: manager

After deployment, Prometheus will automatically discover and collect Longhorn metrics.

Validation:
Check metrics by running a query such as below in the Prometheus UI or check if the prometheus target is showing UP:

longhorn_disk_usage_bytes

Step 2: Visualizing Metrics in Grafana

Accessing Grafana

  1. In Rancher UI, navigate to your Cluster
  2. Go to Cluster Tools (or Apps depending on Rancher version)
  3. Select Monitoring
  4. Click the Grafana icon/link to open in a new tab
  5. Log in (default credentials if unchanged):

  6. Username: admin

  7. Password: prom-operator

Option A — Import a Prebuilt Longhorn Dashboard

Please refer to the community Grafana dashboard library for Longhorn.

Steps:

  1. Go to Dashboards → New → Import
  2. Select and import one of the available Longhorn dashboards
    Example: Dashboard ID 13032
  3. Select Prometheus as the data source

This provides visualization of common Longhorn storage performance metrics.

Option B — Create Custom Panels

  1. In Grafana: From the sidebar, click → Dashboard → Add new dashboard → Add Visualization
  2. Select Prometheus as the data source
  3. You can either use the Query Builder to construct queries visually, or switch to the Code mode to write PromQL directly.

Example PromQL for node storage utilization percentage:

(longhorn_node_storage_usage_bytes / longhorn_node_storage_capacity_bytes) * 100

Additional recommended metrics:

  • longhorn_node_count_total
  • longhorn_instance_manager_cpu_usage_millicpu
  • longhorn_node_cpu_capacity_millicpu

Adjust panel type, legends, and thresholds as required

Step 3: Save Dashboard

  • Provide a descriptive name in title section and save the dashboard
  • Optionally export as JSON for reuse across environments