in pkg/metrics/collector/conntrack.go [94:131]
func parseHeader(line string) (*conntrackIndices, error) {
indices := &conntrackIndices{
found: -1,
invalid: -1,
insert: -1,
insertFailed: -1,
drop: -1,
earlyDrop: -1,
searchRestart: -1,
}
nameParts := strings.Split(line, " ")
indices.numFields = len(nameParts)
for i, v := range nameParts {
switch v {
case "found":
indices.found = i
case "invalid":
indices.invalid = i
case "insert":
indices.insert = i
case "insert_failed":
indices.insertFailed = i
case "drop":
indices.drop = i
case "early_drop":
indices.earlyDrop = i
case "search_restart":
indices.searchRestart = i
}
}
if indices.found == -1 || indices.invalid == -1 ||
indices.insert == -1 || indices.insertFailed == -1 ||
indices.drop == -1 || indices.earlyDrop == -1 ||
indices.searchRestart == -1 {
return nil, fmt.Errorf("invalid header %q: doesn't have target fields", line)
}
return indices, nil
}