henrygd/beszel · warning
size field not found in arcstats
Error message
size field not found in arcstats
What it means
ARCSize scans arcstats for a line prefixed with `size`; if the whole file is scanned without finding one, it returns this error. It means the ZFS ARC statistics file exists but exposes no `size` kstat entry.
Source
Thrown at agent/zfs/zfs_linux.go:33
file, err := os.Open("/proc/spl/kstat/zfs/arcstats")
if err != nil {
return 0, err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "size") {
fields := strings.Fields(line)
if len(fields) < 3 {
return 0, fmt.Errorf("unexpected arcstats size format: %s", line)
}
return strconv.ParseUint(fields[2], 10, 64)
}
}
return 0, fmt.Errorf("size field not found in arcstats")
}
View on GitHub (pinned to b38fb7dafa)
Solutions
- Confirm `grep size /proc/spl/kstat/zfs/arcstats` returns a line; if not, check `lsmod | grep zfs` and load the ZFS kernel module.
- On newer OpenZFS, check for renamed/moved stats files and point the reader at the correct path.
- Inside a container, ensure /proc/spl is mounted/visible from the host.
- Gracefully degrade: treat missing ARC stats as metric-unavailable if ZFS is not installed.
Example fix
// before
return 0, fmt.Errorf("size field not found in arcstats")
// after
if _, err := os.Stat("/proc/spl/kstat/zfs/arcstats"); err != nil {
return 0, nil // ZFS not present — metric unavailable
}
return 0, fmt.Errorf("size field not found in arcstats") Defensive patterns
Strategy: fallback
Validate before calling
if data, err := os.ReadFile("/proc/spl/kstat/zfs/arcstats"); err != nil || !strings.Contains(string(data), "\nsize ") {
// ZFS stats unavailable — skip ARC metric entirely
} Type guard
func arcstatsHasSize(data []byte) bool {
for _, line := range strings.Split(string(data), "\n") {
if strings.HasPrefix(line, "size") { return true }
}
return false
} Try / catch
size, err := zfs.ARCSize()
if err != nil {
log.Printf("ARC size unavailable, reporting 0: %v", err)
size = 0
} Prevention
- Feature-detect /proc/spl/kstat/zfs/arcstats before enabling ZFS metrics.
- Handle renamed kstat entries across OpenZFS versions.
- Distinguish 'ZFS not installed' from 'stats malformed' in logs.
- Degrade to zero/absent metric rather than failing collection.
When it happens
Trigger: The opened path exists but is not a populated arcstats file (empty or filtered procfs), or a ZFS build where the `size` kstat was renamed/removed, or /proc/spl not properly mounted.
Common situations: ZFS userspace tools present but kernel module not loaded (empty stats); OpenZFS variants that moved stats to a different kstat file; containers where procfs is restricted.
Related errors
- unexpected arcstats size format: %s
- system missing required fields
- system exists
- system not found
- ${resp.Error}
AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31).
Data as JSON: /api/errors/b3b7b337a96c8b33.
Report an issue: GitHub.