-
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
Enhance filter check in k8s event metricset #29470
Enhance filter check in k8s event metricset #29470
Conversation
Signed-off-by: chrismark <[email protected]>
Pinging @elastic/integrations (Team:Integrations) |
This pull request does not have a backport label. Could you fix it @ChrsMark? 🙏
NOTE: |
@@ -108,8 +108,16 @@ func (m *MetricSet) Run(reporter mb.PushReporter) { | |||
m.watcher.AddEventHandler(kubernetes.FilteringResourceEventHandler{ | |||
FilterFunc: func(obj interface{}) bool { | |||
eve := obj.(*kubernetes.Event) | |||
// if fields are null they are decoded to `0001-01-01 00:00:00 +0000 UTC` | |||
// so we need to check if they are valid first | |||
lastTimestampValid := kubernetes.Time(&eve.LastTimestamp).Year() > 1 |
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.
There is also time.IsZero() which checks if the time is 0001-01-01 00:00:00 +0000 UTC
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.
Good catch, that's a better check :).
Signed-off-by: chrismark <[email protected]>
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
(cherry picked from commit 43ae3c9)
What does this PR do?
Enhance filter check in k8s event metricset by checking
eventTime
field iflastTimestamp
is not a valid one.Why is it important?
Based on research made on #28923
lastTimestamp
is possible to be null and hence we need to fallback to checkingeventTime
in order to filter older events. If both fields are null we cannot apply filtering and hence theskip_older: false
should be used.cc: @MichaelKatsoulis