goflow2 icon indicating copy to clipboard operation
goflow2 copied to clipboard

Implement /templates HTTP endpoint

Open kellybyrd opened this issue 2 months ago • 4 comments

Provide a JSON output of all templates for all Netflow sources on the configured TemplatePath HTTP endpoint. This will only be active if there is a NetflowPipe and TemplatePath is not null.

The changes to do this work:

  • Implement GetTemplates() for NetFlowTemplateSystem
  • Call the wrapped GetTemplates() for PromTemplateSystem
  • GetTemplatesForAllSources() for NetflowPipe, this does a deep copy of all templates for each source key.

Example output (I restarted my Netflow observer so there are two sources)

{
   "[::ffff:172.16.1.254]:50050": {},
   "[::ffff:172.16.1.254]:50861": {
      "2533274790396160": {
         "template-id": 256,
         "field-count": 20,
         "fields": [...]
      },
      "2533274790396163": {...}
   }
}

kellybyrd avatar Oct 11 '25 18:10 kellybyrd

Any feedback on this?

kellybyrd avatar Oct 15 '25 17:10 kellybyrd

Would like to include this with netflow2ng as being able to view the templates is super useful in debugging.

synfinatic avatar Oct 19 '25 22:10 synfinatic

I see recent comments on issues, but no comments or movement on PRs, it would be great to get some feedback here. I assumed this work was wanted because the cmd/goflow2/main.go code has some hints about the /templates endpoint, so I assumed it was a thing that was wanted but didn't have time for when porting over from the original goflow project.

If it's easier to review or accept, you (or I) could remove the the HTTP endpoint code in cmd/goflow2/main.go from this PR. Then the PR is just exposing GetTemplates() in the template decoders and then providing a function to get a copy of the templates from all sources in pipe.go

kellybyrd avatar Nov 05 '25 17:11 kellybyrd

Catching up on the PRs and issues. Thank you very much for implementing this. Will test and circle back

lspgn avatar Nov 30 '25 03:11 lspgn