Closed ndmitri closed 3 months ago
Unfortunately that's not how event processors function:
event
, the default format is json
.format: event
missing) and even if you set the format it will result in an error because what it returns is not a list of event messages.If your goal is to return an arbitrary message (json or other) you can use the field msg-template:
under your file output. It takes a Gotemplate that rendered with each received message as input.
Hello! Can U put here some basic example of msg-template usage? Thank you!
I used TCP output to forward raw JSON and processed them with PyJQ. Works great. Thank you 🙂
Hello! Can U put here some basic example of msg-template usage? Thank you!
subscriptions: sub1: paths: - /interface/statistics
outputs: out1: type: file format: event msg-template: | {{range .}} {{if index .values "/interface/statistics/in-octets"}} Name: {{.name}} Interface Name: {{(index .tags "interface_name")}} Source: {{(index .tags "source")}} Subscription Name: {{(index .tags "subscription-name")}} InOctets: {{ index .values "/interface/statistics/in-octets" }} {{- end}} {{- end}}
This should print:
```text
Name: sub1
Interface Name: ethernet-1/1
Source: $YOUR_ROUTER_NAME
Subscription Name: sub1
InOctets: 3857
Hello! Can U put here some basic example of msg-template usage? Thank you!
subscriptions: sub1: paths: - /interface/statistics outputs: out1: type: file format: event msg-template: | {{range .}} {{if index .values "/interface/statistics/in-octets"}} Name: {{.name}} Interface Name: {{(index .tags "interface_name")}} Source: {{(index .tags "source")}} Subscription Name: {{(index .tags "subscription-name")}} InOctets: {{ index .values "/interface/statistics/in-octets" }} {{- end}} {{- end}}
This should print:
Name: sub1 Interface Name: ethernet-1/1 Source: $YOUR_ROUTER_NAME Subscription Name: sub1 InOctets: 3857
Thanks a lot! And a small clarification - does the template supports gotemplate functions, string processing, for example? https://docs.gomplate.ca/functions/strings/ Thanks again!
Yes all gomplate functions are imported
I am experiencing an issue with gNMIc where the configured event processor does not seem to apply the specified jq transformation. Despite a straightforward configuration aiming to test the processor functionality, the output remains unchanged from the input, suggesting that the processor might not be triggered or is not applying the transformation correctly.
Configuration Details:
Expected Output:
Actual Output:
Steps to Reproduce:
Additional Information: gNMIc version: 0.36.2 Operating System: Ubuntu 22.04.4 LTS gnmic.log
Expected Behavior: The output should be transformed by the event-jq processor according to the specified expression, showing {"test": "output is working"} instead of the untransformed JSON data from the subscription.
Actual Behavior: The processor does not modify the output as expected. The raw data from the subscription is displayed instead of the transformed data.