Telegraf nftables plugin - unmarshall error in set

I’m unable to use the nftables plugin in telegraf, getting this error message:

Error in plugin: parsing command output failed: unable to parse set: json: cannot unmarshal string into Go struct field namedSet.elem of type nftables.elem

I have this set defined:

set AllowedIPs {
  type ipv4_addr
  elements = { 10.47.55.250, 10.47.56.232 }
}

the nft --json list table firewall output:

    {
      "set": {
        "family": "inet",
        "name": "AllowedIPs",
        "table": "firewall",
        "type": "ipv4_addr",
        "handle": 18,
        "flags": [
          "interval"
        ],
        "elem": [
          "10.47.55.250",
          "10.47.56.232"
        ]
      }
    }

This issue looks to be because it’s expecting the element to be more like

"elem": [{ "val": "10.47.55.250" }]

Any ideas?

Looks like it’s plausibly a bug, and it’d be good to open a GitHub issue in the Telegraf repo to report it. You’re welcome to do so yourself (include your Telegraf configuration), or if you’d rather just reply here with your config, I’d be happy to open an issue.

Thank you, wasn’t fully confident i knew what I was doing! I submitted an issue here: Telegraf nftables plugin - unmarshall error in set · Issue #18685 · influxdata/telegraf · GitHub

1 Like

Looks like there’s already a pull request open to fix the issue, so this should hopefully be patched in the next release!

Wow that pull request was fast, and the fix genius! I added that code and rebuilt telegraf and it works. I learned so much about go/nftables/json coming down this rabbit hole but glad to see it’s fixed.

1 Like