Skip to content

Commit

Permalink
fix: metrics lost when net interface has invalid speed (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 committed Feb 18, 2024
1 parent 576ea28 commit 3c1d050
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions inputs/net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ func (s *NetIOStats) Gather(slist *types.SampleList) {
if iface.Flags&net.FlagUp == 0 {
continue
}
speed, err := Speed(iface.Name)
if err != nil {
continue
}
if speed < 0 {
continue
}
tags := map[string]string{
"interface": io.Name,
}
Expand All @@ -121,7 +114,12 @@ func (s *NetIOStats) Gather(slist *types.SampleList) {
"err_out": io.Errout,
"drop_in": io.Dropin,
"drop_out": io.Dropout,
"speed": speed,
}
speed, err := Speed(iface.Name)
if err == nil && speed >= 0 {
fields["speed"] = speed
} else {
fields["speed"] = -2
}

slist.PushSamples(inputName, fields, tags)
Expand Down

0 comments on commit 3c1d050

Please sign in to comment.