Skip to content

Longhorn Module API Explanation

The Longhorn module aggregates node storage statistics and available persistent volume capacity.


API Execution Logic

The module locates the service matching the identifier longhorn. The target URL is parsed, and no authentication header is attached.

Request Execution

A GET request is sent to the /v1/nodes API endpoint. The request sets an Accept: application/json header and a 5-second timeout.

Data Parsing and Storage Aggregation

Upon receiving node details, the module iterates through the returned list of storage nodes:

  1. Node Counting: The length of the data array represents the total number of storage nodes.
  2. Disk Capacity Summation: For each node, the module loops through its configured disks map. It sums the storageAvailable byte values across all disks on all nodes.
  3. Unit Conversion: The total accumulated bytes are converted to gigabytes (divided by \(1024^3\)) and rounded to one decimal place.

  4. Primary Metric: The total number of storage nodes.

  5. Secondary Metric: The formatted available storage string (e.g. FREE: 143.2 GB).

Caching Strategy

Due to the overhead of traversing disk configurations, responses are cached for 60 seconds (TTL) with a maximum stale limit of 300 seconds.