Skip to content

Conversation

@skartikey
Copy link
Contributor

Summary

The nftables plugin failed to parse JSON output containing named counter references. In nftables, counters can be either:

  • Anonymous (inline objects): {"counter": {"packets": 100, "bytes": 5000}}
  • Named references (strings): {"counter": "my_counter_name"}

The plugin only handled anonymous counters, causing a parse error: "json: cannot unmarshal string into Go struct field"

Add custom UnmarshalJSON to the expr struct that detects and gracefully skips named counter references, since they don't contain inline statistics. Anonymous counters continue to be parsed and reported as before.

Checklist

Related issues

resolves #18135

@telegraf-tiger telegraf-tiger bot added fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Jan 1, 2026
@skartikey skartikey self-assigned this Jan 1, 2026
  The nftables plugin failed to parse JSON output containing named counter
  references. In nftables, counters can be either:
  - Anonymous (inline objects): {"counter": {"packets": 100, "bytes": 5000}}
  - Named references (strings): {"counter": "my_counter_name"}

  The plugin only handled anonymous counters, causing a parse error:
  "json: cannot unmarshal string into Go struct field"

  Add custom UnmarshalJSON to the expr struct that detects and gracefully
  skips named counter references, since they don't contain inline statistics.
  Anonymous counters continue to be parsed and reported as before.
@skartikey skartikey force-pushed the inputs_nftables_named_counter branch from d109235 to d751f82 Compare January 8, 2026 21:16
@skartikey skartikey assigned srebhan and mstrandboge and unassigned skartikey Jan 8, 2026
@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Jan 8, 2026

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

Labels

fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[input.nftables] Fails to parse nft output including named counters

3 participants