Skip to content

Fix interface metric types and fix interface dashboard panels - #22

Open
cheethoe wants to merge 2 commits into
pfrest:mainfrom
cheethoe:fix-interface-metric-types
Open

cheethoe wants to merge 2 commits into
pfrest:mainfrom
cheethoe:fix-interface-metric-types

Conversation

@cheethoe

@cheethoe cheethoe commented Sep 7, 2026

Copy link
Copy Markdown
  • Interface byte, packet, error, and collision metrics are cumulative counters from the FreeBSD kernel (via get_interface_info()), but were exposed as gauges. This changes the Prometheus metric type annotation from gauge to counter using prometheus.Desc + MustNewConstMetric with CounterValue. Metric names are unchanged so as to not cause breaking changes, but the names probably should be changed.

  • This also fixes a race condition in the existing GaugeVec + Reset() + Set() pattern when multiple targets are scraped concurrently, one goroutine's Reset() could wipe metrics while another is mid-Collect(). MustNewConstMetric creates ephemeral values per scrape, so there's no shared state to race on. See https://prometheus.io/docs/instrumenting/writing_exporters/#collectors

  • Updates the Grafana dashboard to use rate() queries, adds units to panels (Bps for bytes, pps for packets), and sets
    tooltips to show all series.

  • interface_up remains a gauge.

Interface stats from pfSense are cumulative counters (from FreeBSD
kernel), not point-in-time gauges. Switch from GaugeVec to
prometheus.Desc + MustNewConstMetric with CounterValue to correctly
expose the metric type. This also fixes a race condition when
multiple targets are scraped concurrently.

Update the Grafana dashboard to use rate() queries and add units
(Bps, pps) to panels.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant