telemetry/gnmi-writer: store interface packet-class counters#3731
Merged
Conversation
Collect per-interface unicast/multicast/broadcast packet counters and FCS errors from the gNMI interface state subtree, which already streams them alongside the octet/packet counters we keep. Add the seven columns to interface_state via migration and populate them in the extractor.
packethog
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
interface_statetable — these already stream in the gNMI interface-state subtree alongside the octet/packet counters we keep, so no upstream subscription change is needed.interface_statetable closer to parity with the interface counters already collected in InfluxDB.interface_statevia a ClickHouse migration (ADD COLUMNis metadata-only; existing rows read back 0) and recreate theinterface_state_latestview soSELECT *surfaces them.device_interface_rollup_5m) that consumein_fcs_errorsand multicast PPS metrics.Diff Breakdown
Small, mechanical change: the bulk is tests and a schema migration; the actual logic is seven nil-checked field copies in the extractor.
Key files (click to expand)
telemetry/migrations/20260520000000_interface_state_packet_counters.sql— new migration adding the 7UInt64columns and recreating the_latestview (with full down-migration)telemetry/gnmi-writer/internal/gnmi/processor_test.go— unit test asserting all 16 counters map to the correct record fields (distinct values catch column swaps)telemetry/gnmi-writer/internal/gnmi/processor_integration_test.go— integration test asserting the 7 new columns round-trip through ClickHouse on an active interface with real traffictelemetry/gnmi-writer/internal/gnmi/extractors.go— populate the new counter fields fromiface.State.Counters.*telemetry/gnmi-writer/internal/gnmi/records.go— add the 7 fields toInterfaceStateRecordwithch:column tagsTesting Verification
TestExtractInterfaceState_Counters): builds anoc.Devicewith distinct non-zero values for all 16 counters and asserts the full extractedInterfaceStateRecord, guarding against field-assignment mistakes.verifyInterfaceState): validates the gNMI fixture → extractor → ClickHouse INSERT → query-back path for the new columns against a real ClickHouse container, asserting non-zero values onSwitch1/11/2— this exercises thech:tag and migration column-name mapping end to end.TestIntegrationsuite passes against a containerized ClickHouse with all migrations applied.