Skip to content

network: add new system.net.iface.up metric#19853

Merged
sarah-witt merged 2 commits into
DataDog:masterfrom
antonipp:ai/network-iface-up-metric
Mar 18, 2025
Merged

network: add new system.net.iface.up metric#19853
sarah-witt merged 2 commits into
DataDog:masterfrom
antonipp:ai/network-iface-up-metric

Conversation

@antonipp

@antonipp antonipp commented Mar 17, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

This adds a new metric to the network system check which indicates whether a particular Linux network interface is up.
The metric data comes from the sysfs entry /sys/class/net/<iface>/carrier. Description from the docs:

Indicates the current physical link state of the interface.
Possible values are:

== =====================
0  physical link is down
1  physical link is up
== =====================

Motivation

We are looking for a similar metric which the Prometheus Node Exporter already has:
https://github.com/prometheus/node_exporter/blob/0c10545e8dfb983f4c013281c4904be27f645de2/collector/netclass_linux.go#L91-L96

# curl -s localhost:9100/metrics | grep node_network_up
# HELP node_network_up Value is 1 if operstate is 'up', 0 otherwise.
# TYPE node_network_up gauge
node_network_up{device="cilium_host"} 1
node_network_up{device="cilium_net"} 1
node_network_up{device="ens5"} 1
node_network_up{device="ens6"} 1
node_network_up{device="lo"} 0
node_network_up{device="lxc11a8da8d4613"} 1
node_network_up{device="lxc1a771ce4e0b9"} 1
node_network_up{device="lxcef367b6368ea"} 1
node_network_up{device="nodelocaldns"} 0

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Comment on lines +341 to +342
if metric_name == 'up':
metric_file_name = 'carrier'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to name the metric carrier because it's not user-friendly, so we have to have this translation.

@antonipp
antonipp force-pushed the ai/network-iface-up-metric branch from ec91f6b to 7f704e4 Compare March 17, 2025 14:42
@codecov

codecov Bot commented Mar 18, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.69%. Comparing base (ea404ef) to head (3cb17eb).
Report is 1 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
network 93.89% <100.00%> (∅)
presto ?
solr ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sarah-witt
sarah-witt added this pull request to the merge queue Mar 18, 2025
Merged via the queue into DataDog:master with commit 3fd29a6 Mar 18, 2025
@antonipp
antonipp deleted the ai/network-iface-up-metric branch March 18, 2025 15:21
@clarkb7

clarkb7 commented Apr 7, 2025

Copy link
Copy Markdown
Contributor

are there plans to add this metric to other platforms?

@antonipp

antonipp commented Apr 7, 2025

Copy link
Copy Markdown
Contributor Author

To give some context, I made the PR just for Linux because it's a metric we've been missing at DD and we only run Linux infra.
I think it would make sense to add this metric for other platforms but that's a question for the integrations teams.

@Kyle-Neale

Copy link
Copy Markdown
Contributor

I made a Jira card to track this 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants