-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Skip add_kubernetes_metadata processor if kubernetes metadata are aleady there #27689
Skip add_kubernetes_metadata processor if kubernetes metadata are aleady there #27689
Conversation
Pinging @elastic/integrations (Team:Integrations) |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good. Left 2 minors.
Also consider adding a test if possible.
@@ -251,6 +259,10 @@ func (k *kubernetesAnnotator) Run(event *beat.Event) (*beat.Event, error) { | |||
if !k.kubernetesAvailable { | |||
return event, nil | |||
} | |||
if kubernetesMetadataExist(event) { | |||
k.log.Debug("Skipping add_kubernetes_metadata processor as kubernetes metadata already exist") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be reporting the log for every single event, means that even if it is in debug
level it could become quite overwhelming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only in case user enables debug mode. In this Run
method there are other debug messages as well. Do you think we shouldn't log this at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, since we have already another debug message in the main flow we can preserve this one too. Maybe in the future we can revisit the logging in this method if we see it becomes noisy, but for now we can keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we log each published event in processing/processors.go:203
. So tbh the logging of one line that the processor is skipped is nothing comparing to that
…ady there (elastic#27689) * Skip add_kubernetes_metadata processor if kubernetes metadata are already there
What does this PR do?
This PR prevents
add_kubernetes_metadata
processor from running in cases kubernetes metadata are already present in an event.Why is it important?
This change prevents metadata being overridden by the processor.
Also In cases where the processor is run by
elastic-agent
(enabled by default) it fails since the matchers are not properly configured (see #27216).Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Run filebeat on kubernetes with kubernetes autodiscover provider enabled [(doc)](https://www.elastic.co/guide/en/beats/filebeat/master/configuration-autodiscover.html, the provider adds the metadata) and also
add_kubernetes_metadata
processor enabled.Check in the logs that the processor is being skipped.
Run filebeat on kubernetes with input of type container (doc) and also
add_kubernetes_metadata
enabled.Check in the logs that the processor starts and adds the metadata.
Related issues