Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedot fluentbit filter for labels and annotations #30

Merged
merged 2 commits into from
May 21, 2021

Conversation

nutellinoit
Copy link
Member

Hi team, i added a little lua script on fluentbit to dedot labels and annotations before sending data to fluentd.
Source here: fluent/fluent-bit#1134 (comment)
This way, there will be no conflict on elasticsearch side because everything will be a string instead of an object.

I tested it and it's working, but before merging or do more test (eg on a real cluster) tell me what you think about it

@angelbarrera92
Copy link
Contributor

How it affects current running setups?
I mean... after applying the patch, do we have to perform any ES operations?

The patch LGTM!

@nutellinoit
Copy link
Member Author

No ES operation needed, because the logs are always sent to the same indexes.
The only thing that changes are the annotation/labels keys, no more an object but a single string with underscores.

IDEA:
What if we do some e2e tests on logging, for example, with some sample applications outputting a finite number of logs, and checking that the expected number of entries on ES is the one we are expecting to see?

@angelbarrera92
Copy link
Contributor

No ES operation needed, because the logs are always sent to the same indexes.
The only thing that changes are the annotation/labels keys, no more an object but a single string with underscores.

IDEA:
What if we do some e2e tests on logging, for example, with some sample applications outputting a finite number of logs, and checking that the expected number of entries on ES is the one we are expecting to see?

Not sure if it is "easy" to do. But worth a test

@angelbarrera92
Copy link
Contributor

Can you check the linter? it is complaining about Lua :)
If it is a false positive, or you want to deactivate the Lua linter, take a look to: https://github.com/sighupio/fury-kubernetes-policeman

@nutellinoit
Copy link
Member Author

Hi @angelbarrera92 , can you help me with the linter?

@nutellinoit
Copy link
Member Author

And side note, this change is now running on two clusters

@angelbarrera92
Copy link
Contributor

Hi @angelbarrera92 , can you help me with the linter?

If you copy-pasted the code, maybe could be better to "exclude" it somehow. Is this the case?

@nutellinoit
Copy link
Member Author

Hi @angelbarrera92 , can you help me with the linter?

If you copy-pasted the code, maybe could be better to "exclude" it somehow. Is this the case?

Yes, that's the case

@ralgozino
Copy link
Member

Hi @nutellinoit !

The patch itself lgtm, but I'm missing a piece. What is this patch trying to solve? Is this an issue with our current implementation? if that's the case, is it fixed upstream? should we instead wait for the upstream patch and update the hole module? or is this a backport of a hotfix?

@nutellinoit
Copy link
Member Author

nutellinoit commented May 18, 2021

Hi @ralgozino , the patch is solving the problem that causes issue if in the same cluster you have a deployment with a labels for example app and another deployment having the label app.something ( for example, if you deploy stuff with kustomize and with helm). This cause a mapping conflict on ES side.

I did this workaround because the dedot filter on fluentbit is present only on elasticsearch output, but we are not directly sending logs to ES, we are sending logs to fluentd.

Also it's easier to manage fluentbit configuration instead of fluentd.

If you want we can pair and i will show you the patch up&running

@angelbarrera92
Copy link
Contributor

Hi @angelbarrera92 , can you help me with the linter?

Done here: 7cb863e

@nutellinoit
Copy link
Member Author

Hi @angelbarrera92 , can you help me with the linter?

Done here: 7cb863e

Thank you @angelbarrera92 !

@ralgozino
Copy link
Member

Hi @ralgozino , the patch is solving the problem that causes issue if in the same cluster you have a deployment with a labels for example app and another deployment having the label app.something ( for example, if you deploy stuff with kustomize and with helm). This cause a mapping conflict on ES side.

I did this workaround because the dedot filter on fluentbit is present only on elasticsearch output, but we are not directly sending logs to ES, we are sending logs to fluentd.

Also it's easier to manage fluentbit configuration instead of fluentd.

If you want we can pair and i will show you the patch up&running

Thank you for the explanation Samu, there's no need to pair but thanks for offering it!

Copy link
Member

@ralgozino ralgozino left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@angelbarrera92 angelbarrera92 left a comment

Choose a reason for hiding this comment

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

LGTM!

@angelbarrera92 angelbarrera92 merged commit 2720b34 into master May 21, 2021
@angelbarrera92 angelbarrera92 deleted the add-dedot-on-fluentbit branch May 21, 2021 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants