Skip to content

Commit 2a70dc9

Browse files
committed
Gracefully handle zero buffer-limit
1 parent c45dc68 commit 2a70dc9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugins/outputs/heartbeat/statistics.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ func (s *statistics) snapshot() *statistics {
8383
entry[k] = v
8484
}
8585
}
86-
entry["buffer_fullness"] = float64(entry["buffer_size"].(int64)) / float64(entry["buffer_limit"].(int64))
86+
if limit := entry["buffer_limit"].(int64); limit != 0 {
87+
entry["buffer_fullness"] = float64(entry["buffer_size"].(int64)) / float64(limit)
88+
} else {
89+
entry["buffer_fullness"] = float64(1.0) // output 100% if no limit
90+
}
8791
out.currentOutputs[name] = append(out.currentOutputs[name], entry)
8892
case "agent":
8993
out.currentAgent = m.Fields()

0 commit comments

Comments
 (0)