Skip to content

Commit

Permalink
Restore docker.network.in.* and docker.network.out.* fields in docker…
Browse files Browse the repository at this point in the history
… module (#40968)

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

* Update CHANGELOG.next.asciidoc

* Change git email

* Trigger tests

* Add pre-commit step to beats pipelines (#40560)

Added pre-commit check to beats pipelines to validate if no merge-conflicts exist

* Remove extra punctuation in some fields description

---------

Co-authored-by: Olga Naydyonock <[email protected]>
  • Loading branch information
MichaelKatsoulis and oakrizan committed Sep 27, 2024
1 parent adbddfe commit fc17d84
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,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

0 comments on commit fc17d84

Please sign in to comment.