Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

[NETOBSERV-44] Consumming goflow2 as a library. #6

Merged
merged 7 commits into from
Oct 15, 2021

Conversation

OlivierCazade
Copy link
Contributor

Using goflow2 as a library to directly receive netflow event with the kube-enricher

Copy link
Member

@jotak jotak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a first-pass superficial review, I still want to review & test more in deep, thanks @OlivierCazade for this PR!

Using goflow2 as a library to directly receive netflow event with the kube-enricher
@OlivierCazade OlivierCazade marked this pull request as ready for review October 11, 2021 16:11
@jotak jotak self-requested a review October 12, 2021 08:42
@jotak jotak self-assigned this Oct 12, 2021
@jotak
Copy link
Member

jotak commented Oct 12, 2021

The linter shows an issue with a lock being copied on RenderMessage (the issue was actually there prior to this PR). The state in goflow's FlowMessage seems to contain a lock that shouldn't be copied. Passing it as a reference in RenderMessage should fix it.

There's also a second lint error about deprecated github.com/golang/protobuf/proto

@jotak
Copy link
Member

jotak commented Oct 12, 2021

Looks good to me for a first approach (there's just the lint error that should be fixed).
As we discussed, there is still protobuf unmarshalling in the process, that perhaps we can try getting rid of in a next iteration.

For a follow-up task, we should probably be able to avoid the unnecessary PB step that happens between Formatter stage and Transport/Enrichment.

If I understand correctly, goflow2 works with a Formatter and a Transporter, and we previously had:
(In goflow) Formatter => Transporter => (in kube-enricher) Enricher => stdout

Now we basically have:
(In kube-enricher) Formatter => Transporter => Enricher => stdout

Next step could be to try having something like:
(In kube-enricher) Enricher => Formatter => Transporter
so that enrichment takes place before there's any encoding, working from goflow's go model directly?

It's unclear yet to me if the Formatter and Transporter stages will still be around when we'll integrate the loki client, or if they will be like no-ops... (it's just an implementation detail anyway).

@OlivierCazade
Copy link
Contributor Author

Yes we could try to implement the enricher as a goflow2 Formatter.

Goflow2 API use []bytes to pass data between the formatter and the transporter so if we want to enrich this datas without having to unmarshal them, we have to do it before passing them to the transporter.

What is not clear to me is if we want to use this enricher only with goflow2, or if other collectors like the eBPF are also going to use it. Keeping the Formatter and Transporter stages will make interactions with goflow2 easier, but I don't know how this is going to work if we also want to use another source.

@jotak
Copy link
Member

jotak commented Oct 13, 2021

I opened https://issues.redhat.com/browse/NETOBSERV-64 for a follow-up

Copy link
Contributor

@mariomac mariomac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Just dropped some comments about few "styling" advices. Feel free to implement or push back them.

- literal strings are now defined as constants
- netflow format internal channel is now buffered
- rename of GoflowDriver to Driver (already in netflow package)
- rename of NewDriver function to StartDriver
- StartDriver now also has a context parameter instead of creating one
- simplification of the internal function of StartDriver
COPY go.mod ./
COPY go.sum ./

RUN go mod download
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will surely change in the future if we want to include vendors in sources as Mario did for the loki client. But we can do that as a follow-up.

@@ -1,15 +1,20 @@
FROM golang:alpine as builder
FROM registry.access.redhat.com/ubi8/go-toolset:1.15.14-10 as builder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting / realizing that if we stick to the redhat-supported tool chain we have to use this older version of go. Generics will wait :)

Copy link
Member

@jotak jotak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but if @mariomac you can take another look, as you wrote most of the comments

@OlivierCazade OlivierCazade merged commit f0494f1 into netobserv:main Oct 15, 2021
jpinsonneau pushed a commit to jpinsonneau/goflow2-kube-enricher that referenced this pull request Nov 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants