prometheus/node_exporter · error

zpool path did not return at least two elements

Error message

zpool path did not return at least two elements

What it means

Validation guard in parsePoolProcfsFile: the given zpool procfs path split on "/" produced fewer than two elements, so the pool name (second-to-last element) and kstat file name (last element) cannot be extracted. The zpoolPath argument passed by updatePoolStats was malformed (missing the <pool>/<file> tail).

Solutions

  1. Check that the pool's procfs path looks like /proc/spl/kstat/zfs/<pool>/<file>; a single-element path means the caller found a bad path while walking the zfs kstat directory.
  2. Re-scan the pool list; a pool disappearing mid-scan can produce truncated paths — retry the scrape.
  3. Ensure /proc/spl/kstat/zfs is a real kstat directory and not a flat or odd mount.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at collector/zfs_linux.go:278 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/871fb2ccf06b2ade. Report an issue: GitHub.

Appendix: source

Thrown at collector/zfs_linux.go:278

	var fields []string
	for scanner.Scan() {
		line := strings.Fields(scanner.Text())

		if !parseLine && len(line) >= 12 && line[0] == "nread" {
			//Start parsing from here.
			parseLine = true
			fields = make([]string, len(line))
			copy(fields, line)
			continue
		}
		if !parseLine {
			continue
		}

		zpoolPathElements := strings.Split(zpoolPath, "/")
		pathLen := len(zpoolPathElements)
		if pathLen < 2 {
			return fmt.Errorf("zpool path did not return at least two elements")
		}
		zpoolName := zpoolPathElements[pathLen-2]
		zpoolFile := zpoolPathElements[pathLen-1]

		for i, field := range fields {
			key := fmt.Sprintf("kstat.zfs.misc.%s.%s", zpoolFile, field)

			value, err := strconv.ParseUint(line[i], 10, 64)
			if err != nil {
				return fmt.Errorf("could not parse expected integer value for %q: %w", key, err)
			}
			handler(zpoolName, zfsSysctl(key), value)
		}
	}

	return scanner.Err()
}

View on GitHub (pinned to 17ddd77c59)