Closed dshah2012 closed 3 years ago
Hi, I think this is a question for a Nokia representative.
What I can do here is adding a knob under the output config to add a target field to the message based on a template. The config would look something like this:
outputs:
out123:
type: kafka
...
add-target: overwrite # possible values [ 'overwrite', 'if-not-present', '' ]
target-template: {{ index . "source" }}
The template could be either a GoTemplate (like abobe) or a jq
filter if you prefer that,
the template input takes in some metadata of typemap[string]interface{}
that has fields like subscription-name
, source
,... and maybe the target configured under the subscription ( I have to look into how I can do that last one )
So using this template it will be possible to conditionally populate the target field of the received messages.
How does that sound ?
Hi all, do we know if in the subscription defined like this:
nokia_st:
paths:
- dummy_path
stream-mode: sample
sample-interval: 60s
target: "nokia"
we actually set the target in the prefix
field of the SubscriptionList
message and not on the path
field of the Subscription
message?
yes it is set in the prefix
Thanks @karimra for your response. That sounds great. Let me know if i have understood it right. There were will two additional fields in the output add-target which will have multiple options to use. other one would be the target-template. The value for the target-template would be a GO template or a jq filter.
Sorry for asking little trivial question as i am not familiar with go or jq that much, so the GO template or the jq filter will have some fields that will help to add a target field to the received messages.
yes, that's the idea.
I will come back with examples of go templates and jq filters once it's done.
I'm thinking about adding a field under subscription, set-target: true | false
If set to true
, the Subscribe
Request will have the target field set to the target name.
That way a single subscription can be used for multiple targets and still have different target values.
Thank you. That's great.
Hi, can you try the last release v0.15.0 ?
targets:
nokia_router1:57400:
name: nokia_router1 # if this is not set, it will default to `nokia_router1:57400`
...
subscriptions:
sub1:
....
# `set-target` will set the target field in the request to the defined target name
# (nokia_router1 in this example)
# it removes the port number if present
set-target: true
...
outputs:
kafka_out:
type: kafka
...
# add-target, when set to `if-not-present`,
# adds the target name from the subscription
# or from the targets section (if set-target: true) to the gNMI response,
# only if the target field is ""
add-target: if-not-present
Thanks @karimra . Sure will try today and let you know how it goes.
Hello @karimra ,
Yes i try the new docker image and its working as expected. Thanks for adding this feature in a quick time frame. Closing the Issue.
Hello @karimra ,
As we discussed in this issue https://github.com/karimra/gnmic/issues/396#issuecomment-853481628. The target does not appear in the prefix section in the protojson format when collector is sending the message to kafka for nokia, Even tough it is declared in the subscription, as you said that currently it is not supported currently for nokia.
Could you let me know if there is a plan for adding this feature target for nokia is gonna be added in the future release. I am asking this because it is very hard to tell which device the information has been received from the payload without target field. As you can see below output of the collector for nokia in the protojson format.