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

Added IP attribute when interface IP address is available #98

Open
wants to merge 3 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
17 changes: 16 additions & 1 deletion src/main/connector/system/Linux/Linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,32 @@ monitors:
network:
simple:
sources:
networkInformation:
networkPerfs:
# Interface;MTU;State;RX_bytes;RX_packets;RX_errors;RX_dropped;RX_missed;RX_mcast;TX_bytes;TX_packets;TX_errors;TX_dropped;TX_carrier;TX_collsns";
type: commandLine
commandLine: /usr/sbin/ip -s link
computes:
- type: awk
script: ${file::network.awk}
networkInterface:
# Interface;IpAddress;
type: commandLine
commandLine: ip -o -4 addr show
computes:
- type: awk
script: '{print $2";"$4}'
networkInformation:
type: tableJoin
leftTable: ${source::networkPerfs}
rightTable: ${source::networkInterface}
leftKeyColumn: 1
rightKeyColumn: 1
defaultRightLine: ;;
mapping:
source: ${source::networkInformation}
attributes:
id: $1
ip: $17
metrics:
system.network.dropped{network.io.direction="transmit"}: $13
system.network.dropped{network.io.direction="receive"}: $7
Expand Down
50 changes: 40 additions & 10 deletions src/main/connector/system/Windows/Windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ monitors:
simple:
sources:
# Name;PacketsOutboundDiscarded;PacketsReceivedDiscarded;PacketsSentPersec;PacketsReceivedPersec;PacketsOutboundErrors;PacketsReceivedErrors
networkInformation:
networkInterfacePrefs:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
networkInterfacePrefs:
networkInterfacePerfs:

type: wmi
namespace: root\CIMv2
query: >
Expand All @@ -204,19 +204,49 @@ monitors:
BytesSentPerSec,
BytesReceivedPerSec
FROM Win32_PerfRawData_Tcpip_NetworkInterface
computes:
- type: duplicateColumn
column: 1
- type: awk
script: 'BEGIN {FS=OFS=";"} {gsub(/[^a-zA-Z0-9]/, " ", $2); print $0}'
# Name;IpAddress
networkAdapters:
type: wmi
namespace: root\CIMv2
query: >
SELECT Description,
IPAddress
FROM Win32_NetworkAdapterConfiguration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Win32_NetworkAdapterConfiguration lists all network adapters (incl. many WAN and virtual network cards), while Win32_PerfRawData_Tcpip_NetworkInterface lists only network interfaces (Windows makes a slight difference between the 2 concepts).

So:

  1. you either join Win32_NetworkAdapterConfiguration with Win32_PerfRawData_Tcpip_NetworkAdapter, and provide performance information for all "adapters", including WAN miniports and virtual cards,
  2. or join Win32_PerfRawData_Tcpip_NetworkInterface (left) with Win32_NetworkAdapterConfiguration (right) to make sure only the physical interfaces are listed in the result of the join operation

Prometheus' windows_exporter seems to have chosen the 2nd option, so that's our preferred one to!

computes:
- type: duplicateColumn
column: 1
- type: awk
script: 'BEGIN {FS=OFS=";"} {gsub(/[^a-zA-Z0-9]/, " ", $2); print $0}'
- type: duplicateColumn
column: 3
- type: awk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This awk script can be replaced with a simple Replace compute step:

- replace: "|"
- replaceBy: " "
- column: 4

(or you could combine all 4 compute steps into a single AWK script)

script: 'BEGIN {FS=OFS=";"} {gsub(/\|/, " ", $4); print $0}'
networkInformation:
type: tableJoin
leftTable: ${source::networkAdapters}
rightTable: ${source::networkInterfacePrefs}
leftKeyColumn: 2
rightKeyColumn: 2
defaultRightLine: ;;;;;;;;
mapping:
source: ${source::networkInformation}
attributes:
id: $1
id: $2
ip: $4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Otel semantic conventions, the IP addresses is to be represented with the network.local.address attribute.

See: https://opentelemetry.io/docs/specs/semconv/attributes-registry/network/

metrics:
system.network.dropped{network.io.direction="transmit"}: $2
system.network.dropped{network.io.direction="receive"}: $3
system.network.packets{network.io.direction="transmit"}: $4
system.network.packets{network.io.direction="receive"}: $5
system.network.errors{network.io.direction="transmit"}: $6
system.network.errors{network.io.direction="receive"}: $7
system.network.io{network.io.direction="transmit"}: $8
system.network.io{network.io.direction="receive"}: $9
system.network.dropped{network.io.direction="transmit"}: $7
system.network.dropped{network.io.direction="receive"}: $8
system.network.packets{network.io.direction="transmit"}: $9
system.network.packets{network.io.direction="receive"}: $10
system.network.errors{network.io.direction="transmit"}: $11
system.network.errors{network.io.direction="receive"}: $12
system.network.io{network.io.direction="transmit"}: $13
system.network.io{network.io.direction="receive"}: $14
physical_disk:
simple:
sources:
Expand Down