Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore docker.network.in.* and docker.network.out.* fields in docker module #40968

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add `metrics_count` to Prometheus module if `metrics_count: true` is set. {pull}40411[40411]
- Added Cisco Meraki module {pull}40836[40836]
- Added Palo Alto Networks module {pull}40686[40686]
- Restore docker.network.in.* and docker.network.out.* fields in docker module {pull}40968[40968]

*Metricbeat*

Expand Down
98 changes: 98 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14500,6 +14500,104 @@ type: keyword

--

[float]
=== in

Incoming network stats per second.



*`docker.network.in.bytes`*::
+
--
Incoming bytes per seconds.


type: long

format: bytes

--

*`docker.network.in.dropped`*::
+
--
Dropped incoming packets per second..


type: scaled_float

--

*`docker.network.in.errors`*::
+
--
Errors on incoming packets per second..


type: long

--

*`docker.network.in.packets`*::
+
--
Incoming packets per second..


type: long

--

[float]
=== out

Outgoing network stats per second.



*`docker.network.out.bytes`*::
+
--
Outgoing bytes per second.


type: long

format: bytes

--

*`docker.network.out.dropped`*::
+
--
Dropped outgoing packets per second..


type: scaled_float

--

*`docker.network.out.errors`*::
+
--
Errors on outgoing packets per second..


type: long

--

*`docker.network.out.packets`*::
+
--
Outgoing packets per second..


type: long

--

[float]
=== inbound

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions metricbeat/module/docker/network/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,50 @@
type: keyword
description: >
Network interface name.
- name: in
type: group
description: >
Incoming network stats per second.
fields:
- name: bytes
type: long
format: bytes
description: >
Incoming bytes per seconds.
- name: dropped
type: scaled_float
description: >
Dropped incoming packets per second..
- name: errors
type: long
description: >
Errors on incoming packets per second..
- name: packets
type: long
description: >
Incoming packets per second..
- name: out
type: group
description: >
Outgoing network stats per second.
fields:
- name: bytes
type: long
format: bytes
description: >
Outgoing bytes per second.
- name: dropped
type: scaled_float
description: >
Dropped outgoing packets per second..
- name: errors
type: long
description: >
Errors on outgoing packets per second..
- name: packets
type: long
description: >
Outgoing packets per second..
- name: inbound
type: group
description: >
Expand Down
12 changes: 12 additions & 0 deletions metricbeat/module/docker/network/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ func eventMapping(r mb.ReporterV2, stats *NetStats) {
RootFields: rootFields,
MetricSetFields: mapstr.M{
"interface": stats.NameInterface,
"in": mapstr.M{
"bytes": stats.RxBytes,
"dropped": stats.RxDropped,
"errors": stats.RxErrors,
"packets": stats.RxPackets,
},
"out": mapstr.M{
"bytes": stats.TxBytes,
"dropped": stats.TxDropped,
"errors": stats.TxErrors,
"packets": stats.TxPackets,
},
"inbound": mapstr.M{
"bytes": stats.Total.RxBytes,
"dropped": stats.Total.RxDropped,
Expand Down
11 changes: 3 additions & 8 deletions metricbeat/module/docker/network/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ func (n *NetService) getNetworkStats(nameInterface string, rawNetStats types.Net
netStats.TxErrors = n.getTxErrorsPerSecond(&newNetworkStats, &oldNetworkStat)
netStats.TxPackets = n.getTxPacketsPerSecond(&newNetworkStats, &oldNetworkStat)
} else {
n.NetworkStatPerContainer[myRawstats.Container.ID] = make(map[string]NetRaw)
if _, conExists := n.NetworkStatPerContainer[myRawstats.Container.ID]; !conExists {
n.NetworkStatPerContainer[myRawstats.Container.ID] = make(map[string]NetRaw)
}
}

n.NetworkStatPerContainer[myRawstats.Container.ID][nameInterface] = newNetworkStats
Expand All @@ -121,13 +123,6 @@ func createNetRaw(time time.Time, stats *types.NetworkStats) NetRaw {
}
}

func (n *NetService) checkStats(containerID string, nameInterface string) bool {
if _, exist := n.NetworkStatPerContainer[containerID][nameInterface]; exist {
return true
}
return false
}

func (n *NetService) getRxBytesPerSecond(newStats *NetRaw, oldStats *NetRaw) float64 {
duration := newStats.Time.Sub(oldStats.Time)
return n.calculatePerSecond(duration, oldStats.RxBytes, newStats.RxBytes)
Expand Down
Loading