Git Product home page Git Product logo

Comments (6)

karimra avatar karimra commented on July 17, 2024 1

Yes all gomplate functions are imported

from gnmic.

karimra avatar karimra commented on July 17, 2024

Unfortunately that's not how event processors function:

  • Processors apply only when the output format is set to event, the default format is json.
  • 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.

dimas-5-1 avatar dimas-5-1 commented on July 17, 2024

Hello!
Can U put here some basic example of msg-template usage? Thank you!

from gnmic.

dnikoliouk-dn avatar dnikoliouk-dn commented on July 17, 2024

I used TCP output to forward raw JSON and processed them with PyJQ. Works great. Thank you 🙂

from gnmic.

karimra avatar karimra commented on July 17, 2024

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.

dimas-5-1 avatar dimas-5-1 commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.