Skip to content

fix: host metrics come from a collector in the host's network, so network traffic is the host's - #447

Merged
HardMax71 merged 1 commit into
mainfrom
max/27-host-metrics-agent
Oct 22, 2026
Merged

HardMax71 merged 1 commit into
mainfrom
max/27-host-metrics-agent

Conversation

@HardMax71

@HardMax71 HardMax71 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Found while working on #317. The collector's host_metrics network scraper reported the collector container's own eth0 and lo, not the host's: gopsutil reads /proc/net/dev, and that always shows the reading process's network namespace (net_linux.go). In prod, system_network_io_bytes_total{device="eth0"} said 30.7 KB/s in while the host's real eth0 moved about 300 B/s, and the host's NIC is also called eth0.

Changes

A second collector, host-metrics, runs only the host_metrics receiver with network_mode: host and sends to the main collector on 127.0.0.1:4317. It opens no ports: internal metrics are off and it runs no extensions. The main collector drops the receiver and the host mounts. The System row gets "Network I/O" (without lo and veth*) and "Disk Space Used", the deploy restarts host-metrics when its config changes, and the system diagram shows it.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or tooling changes

Test Plan

  • Backend unit tests pass (cd backend && uv run pytest tests/unit)
  • Frontend unit tests pass (cd frontend && npm run test)
  • Backend E2E tests pass (docker compose exec -T backend sh -c 'uv sync --group test --no-dev --frozen --no-install-project --no-build && pytest tests/e2e')
  • Frontend E2E tests pass (cd frontend && npm run test:e2e)
  • API spec and client regenerated if routes or schemas changed (./deploy.sh openapi, then ./deploy.sh types), never edited by hand
  • Manual testing performed

Validation: locally the agent reported the host's enp1s0f0, wlp2s0, docker0 and bridge, opened no port and used 57 MiB. Both configs pass otelcol validate on 0.163.1, compose config passes, and the disk query gives 40.1% on prod against df's 41%.

Checklist

  • My code follows the project's style guidelines
  • I have run pre-commit run --all-files and all checks pass
  • I have added tests that prove my fix/feature works
  • I have updated documentation if needed
  • My changes don't introduce new warnings

Summary by cubic

Fixes host metrics so network traffic reflects the host's interfaces instead of the collector container's: gopsutil reads /proc/net/dev, which shows the reading process's network namespace. A new host-metrics collector runs the host_metrics receiver with network_mode: host in the host's network namespace and forwards to the main collector on 127.0.0.1:4317.

  • The main collector drops the host_metrics receiver and the /proc and /sys mounts it used for it.
  • Grafana gains "Network I/O" (excluding lo and veth* interfaces) and "Disk Space Used" panels.
  • The deploy restarts host-metrics when its config changes; docs and the system diagram are updated.

Written for commit 363d0e0. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea851d89-75dc-4b49-bc63-1f4b03efe731
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@HardMax71
HardMax71 enabled auto-merge (squash) October 22, 2026 13:31
@github-actions github-actions Bot added documentation Improvements or additions to documentation area: observability Metrics, dashboards, alerts, logs, traces, OTel collector area: deploy Compose, images, release workflow, production host area: ci GitHub workflows, test infrastructure, repo tooling labels Oct 22, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Flag Coverage Δ
backend-e2e 81.95% <ø> (ø)
backend-unit 77.83% <ø> (ø)

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

Components Coverage Δ
Backend 94.54% <ø> (ø)
Frontend 92.19% <ø> (ø)
🚀 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.

@HardMax71
HardMax71 merged commit b489959 into main Oct 22, 2026
22 checks passed
@HardMax71
HardMax71 deleted the max/27-host-metrics-agent branch October 22, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci GitHub workflows, test infrastructure, repo tooling area: deploy Compose, images, release workflow, production host area: observability Metrics, dashboards, alerts, logs, traces, OTel collector documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants