balena-io-experimental / netio-logger

Log metrics on network I/O

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Network I/O Metrics Logger

Log metrics on network I/O with minimal resource use

This fleet (netio-logger) logs network I/O metrics on a configurable interval. It is designed to be a drop-in replacement for Network Metrics Logger (NML) with much reduced resource requirements to support testing with a user's application containers. Like NML, netio-logger generates minimal output to avoid creation of more network I/O itself.

Fleet Resident Memory Disk Containers
NML 224 MB 320 MB 3
netio-logger 39 MB 36 MB 1

Resident memory includes approximately 38 MB per container for the balena-containerd-shim process. The netio-logger executable itself uses 1 MB of resident memory and the executable size is 256 KB.

To be fair, NML emphasizes composability from a generic system metrics container and a separate logging container. The idea with netio-logger is to give users a choice depending on their needs.

Getting Started

Simply click on the Deploy with balena button below to create a fleet from the docker-compose file in this repository. Alternatively, you can copy the directives for the netio-logger service into your own docker-compose.

balena deploy button

By default the fleet publishes bytes transmitted and received every five minutes on the loopback interface lo. Output is formatted as CSV. You should see messages like below.

11.07.22 12:54:36 (+0000)  netio-logger  Received initial loggable message for interface lo; starting publish interval
11.07.22 12:59:36 (+0000)  netio-logger  elapsedRx,elapsedTx
11.07.22 12:59:36 (+0000)  netio-logger  40976,40976
11.07.22 13:04:36 (+0000)  netio-logger  42868,42868

Notice the first message includes the name of the interface. See METRICS_REQUEST configuration below to specify a different interface.

Configuration

Environment variables you may configure are listed in the sections below.

METRICS_REQUEST

The METRICS_REQUEST variable defines the network interface of interest, and defaults to the loopback interface, lo. For example, if you are interested in interface eth0, set METRICS_REQUEST like below.

networkStats/(eth0)

If you don't know the name of the interface, use the ifconfig command to find it. The example below includes an Ethernet interface, eth0, and a cellular interface, wwp1s0u1u1i4.

Click for ifconfig command example

root@abcdef0:~# ifconfig |grep -B 1 inet

balena0   Link encap:Ethernet  HWaddr 02:42:83:5E:26:AC  
          inet addr:10.114.101.1  Bcast:10.114.101.255  Mask:255.255.255.0
--
br-233ab2d0cdb1 Link encap:Ethernet  HWaddr 02:42:DE:0E:DC:2A  
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          inet6 addr: fe80::42:deff:fe0e:dc2a/64 Scope:Link
--
eth0      Link encap:Ethernet  HWaddr DC:A6:32:E8:C9:56  
          inet addr:192.168.1.127  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::aa2f:7f31:b094:9181/64 Scope:Link
          inet6 addr: fd25:36da:e8ec::e1d/128 Scope:Global
          inet6 addr: fd25:36da:e8ec:0:99aa:a2bd:39d5:f53f/64 Scope:Global
--
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
--
resin-dns Link encap:Ethernet  HWaddr 2E:ED:31:EB:05:35  
          inet addr:10.114.102.1  Bcast:0.0.0.0  Mask:255.255.255.0
--
resin-vpn Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.246.34.90  P-t-P:52.4.252.97  Mask:255.255.255.255
          inet6 addr: fe80::a238:945a:e93b:c106/64 Scope:Link
--
supervisor0 Link encap:Ethernet  HWaddr 02:42:58:E8:D0:F7  
          inet addr:10.114.104.1  Bcast:10.114.104.127  Mask:255.255.255.128
--
veth43d6399 Link encap:Ethernet  HWaddr AA:CC:21:F4:A0:E6  
          inet6 addr: fe80::a8cc:21ff:fef4:a0e6/64 Scope:Link
--
wwp1s0u1u1i4 Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:100.56.81.95  P-t-P:100.65.50.81  Mask:255.255.255.252

READING_INTERVAL_SEC

The READING_INTERVAL_SEC variable is the interval between metrics readings, in seconds. The default interval is 300 seconds or 5 minutes.

About

Log metrics on network I/O

License:Apache License 2.0


Languages

Language:Nim 100.0%