prometheus/node_exporter · error
Data Size mismatch
Error message
Data Size mismatch
What it means
getData on FreeBSD validates that the sysctl buffer it read for TCP statistics is at least the expected size; a shorter buffer means kernel data layout/length does not match what the collector expects, so it returns 'Data Size mismatch'.
Solutions
- Upgrade node_exporter to a build matching your FreeBSD kernel version.
- Check FreeBSD/node_exporter version compatibility; recompile the exporter on the target FreeBSD release.
- Report/inspect if the kernel sysctl shrinks (feature removed) and disable the affected TCP-state metrics via flags.
Defensive patterns
Strategy: fallback
Try / catch
stats, err := GetData(...)
if err != nil && strings.Contains(err.Error(), "Data Size mismatch") {
logger.Warn("TCP state data layout mismatch; skipping netstat metrics", "err", err)
return nil
} Prevention
- Match exporter build to the FreeBSD release in production.
- Pin node_exporter versions per OS release.
- Test upgrades on canary hosts with matching kernels.
When it happens
Trigger: GetData/getTCPStates on FreeBSD when len(data) < expectedSize after fetching the net.inet.tcp states sysctl — i.e., the kernel returned fewer bytes than the collector's expectedSize.
Common situations: Running an older or newer FreeBSD kernel whose sysctl output layout differs from the exporter's compiled-in expectations; cross-version binaries; partial reads from sysctl.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- invalid TCP states data: expected
- sysctl(vm.stats.vm.v_page_size) failed
- couldn't get memory
- couldn't get sysctl
- could not retrieve CPU times
AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07).
Data as JSON: /api/errors/fdf5406e4e6118f3.
Report an issue: GitHub.
Appendix: source
Thrown at collector/netstat_freebsd.go:250
return NetstatMetrics{
ipv6SendTotal: float64(ipStats.ip6s_localout),
ipv6RawSendTotal: float64(ipStats.ip6s_rawout),
ipv6RecvTotal: float64(ipStats.ip6s_total),
ipv6RecvFragmentsTotal: float64(ipStats.ip6s_fragments),
ipv6ForwardTotal: float64(ipStats.ip6s_forward),
ipv6DeliveredTotal: float64(ipStats.ip6s_delivered),
}, nil
}
func getData(queryString string, expectedSize int) ([]byte, error) {
data, err := sysctlRaw(queryString)
if err != nil {
fmt.Println("Error:", err)
return nil, err
}
if len(data) < expectedSize {
return nil, errors.New("Data Size mismatch")
}
return data, nil
}
func getTCPStates() ([]uint64, error) {
// This sysctl returns an array of uint64
data, err := sysctlRaw("net.inet.tcp.states")
if err != nil {
return nil, err
}
if len(data)/8 != len(tcpStates) {
return nil, fmt.Errorf("invalid TCP states data: expected %d entries, found %d", len(tcpStates), len(data)/8)
}
states := make([]uint64, 0)View on GitHub (pinned to 17ddd77c59)