Comments (6)
Yes all gomplate functions are imported
from gnmic.
Unfortunately that's not how event processors function:
- Processors apply only when the output format is set to
event
, the default format isjson
. - Processors should always output a list of event messages (you cannot create an arbitrary json object using them)
In your case, the processor is not being applied at all (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.
from gnmic.
Hello!
Can U put here some basic example of msg-template usage? Thank you!
from gnmic.
I used TCP output to forward raw JSON and processed them with PyJQ. Works great. Thank you 🙂
from gnmic.
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
from gnmic.
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!
from gnmic.
Related Issues (20)
- Slow changing metrics are not published to prometheus output HOT 2
- JQ filtering inconsistency? HOT 1
- Getting response for single subscription when multiple subscriptions are requested through config file with ONCE mode HOT 6
- Session reestablishment issues HOT 5
- Request for Example Configuration for PaloAlto & PAN-OS Environments
- Latest version fails to connect to local Unix socket HOT 1
- K8s Clustering Leader Receives Context Deadline Error on Target HOT 5
- gRPC working fine even if we pass server certificate instead of root CA in --tls-ca parameter. HOT 6
- My Prometheus is unable to scrape any telemetry data from gNMIc although gNMIc is collecting data from the target and exposing it on port 9273. HOT 4
- debug mode outputs password HOT 1
- My Prometheus is unable to scrape any telemetry data from gnmic for BGP operational state although gnmic is collecting data from the target and exposing it on port 9273. HOT 2
- gNMIc generate unknown path item HOT 3
- Question about deleted paths HOT 4
- GET intermittently failing with TLS13(DeadlineExceeded desc = context deadline exceeded) HOT 2
- .
- Unable to integrate Juniper Routers with gnmic HOT 9
- Broken Connection Event/Alert HOT 2
- consul:latest should be hashicorp/consul:latest
- Getting error "String field 'gnmi.PathElem.key' contains invalid UTF-8 data when serializing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes." HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnmic.