Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inputs.gnmi tag_only should support arbitrary subscriptionKey #11011

Closed
bewing opened this issue Apr 20, 2022 · 1 comment · Fixed by #11019
Closed

inputs.gnmi tag_only should support arbitrary subscriptionKey #11011

bewing opened this issue Apr 20, 2022 · 1 comment · Fixed by #11019
Labels
area/gnmi feature request Requests for new plugin and for new features to existing plugins

Comments

@bewing
Copy link
Contributor

bewing commented Apr 20, 2022

Feature Request

tag_only subscriptions should be allowed to specify the name of the tag used as the subscription key

Proposal:

Current behavior:

The subscription key is hardcoded to the device name + the name tag of the current update:

// Update tag lookups and discard rest of update
subscriptionKey := tags["source"] + "/" + tags["name"]

Desired behavior:

The subscription key should be specifiable on a per-tag subcription basis, possible as a separate config struct

Use case:

While the initial use cases of tag_only worked well with the prior behavior (oc-interfaces ended up with the interface name as the name tag), more complex, multiple-keyed models such as network-instances run into issues.

As an example, reading BGP session state at

/network-instances/network-instance[name=*]/protocols/protocol[identifier=BGP][name=BGP]/bgp/neighbors/neighbor[neighbor-address=*]/state/session-state

and attempting to add

/network-instances/network-instance[name=*]/protocols/protocol[identifier=BGP][name=BGP]/bgp/neighbors/neighbor[neighbor-address=*]/state/description

as a tag -- we should be using the neighbor_address tag as our key, not the top-level name of the network-instance.

@bewing bewing added the feature request Requests for new plugin and for new features to existing plugins label Apr 20, 2022
@bewing
Copy link
Contributor Author

bewing commented Apr 22, 2022

Tag-only subscriptions are basically subscriptions for gNMI updates that we do not emit as measurements, but instead store in memory. Ideally each tag-only subscription would be for a specific leaf, but trying to enforce that would probably require YANG validation, which is a can of worms I'd prefer not to open. A tag only subscription request should have the same structure as a regular subscription request, but also include rules for what other Updates it should be applied to.

If we introduce the concept of a client struct into each worker thread, we can use that to pass in the device address to dial, and their own struct for storing tags. This eliminates the need for a mutex on a single map for all threads.

Each Update is basically a gNMI Path (with keys) and a gNMI value -- we should store Updates that we receive that exact match the full path of a recorded tag subscription in that format. For Updates that we receive that we will emit as measurements, we should enumerate the application rules for all subscriptions, and for each one that applies, apply the leaf name as the tag name, and the leaf value in string format as the tag value.

bewing added a commit to bewing/telegraf that referenced this issue Apr 27, 2022
bewing added a commit to bewing/telegraf that referenced this issue Apr 27, 2022
bewing added a commit to bewing/telegraf that referenced this issue Apr 27, 2022
bewing added a commit to bewing/telegraf that referenced this issue Apr 27, 2022
bewing added a commit to bewing/telegraf that referenced this issue Apr 27, 2022
bewing added a commit to bewing/telegraf that referenced this issue Apr 27, 2022
bewing added a commit to bewing/telegraf that referenced this issue Jul 7, 2022
srebhan pushed a commit that referenced this issue Jul 11, 2022
srebhan added a commit to srebhan/telegraf that referenced this issue Jan 16, 2023
srebhan added a commit to srebhan/telegraf that referenced this issue Jan 19, 2023
srebhan added a commit to srebhan/telegraf that referenced this issue Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gnmi feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant