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

Enhance filter check in k8s event metricset #29470

Merged
merged 2 commits into from
Dec 16, 2021

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Dec 16, 2021

What does this PR do?

Enhance filter check in k8s event metricset by checking eventTime field if lastTimestamp 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 checking eventTime in order to filter older events. If both fields are null we cannot apply filtering and hence the skip_older: false should be used.

cc: @MichaelKatsoulis

Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark ChrsMark self-assigned this Dec 16, 2021
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 16, 2021
@ChrsMark ChrsMark added Team:Integrations Label for the Integrations team and removed needs_team Indicates that the issue/PR needs a Team:* label labels Dec 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@mergify
Copy link
Contributor

mergify bot commented Dec 16, 2021

This pull request does not have a backport label. Could you fix it @ChrsMark? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Dec 16, 2021
@@ -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
Copy link
Contributor

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

Copy link
Member Author

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 <chrismarkou92@gmail.com>
@ChrsMark ChrsMark added the backport-v8.0.0 Automated backport with mergify label Dec 16, 2021
@mergify mergify bot removed the backport-skip Skip notification from the automated backport with mergify label Dec 16, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 16, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-12-16T14:20:07.092+0000

  • Duration: 127 min 21 sec

  • Commit: b96f541

Test stats 🧪

Test Results
Failed 0
Passed 48046
Skipped 4148
Total 52194

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@ChrsMark ChrsMark merged commit 43ae3c9 into elastic:master Dec 16, 2021
mergify bot pushed a commit that referenced this pull request Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.0.0 Automated backport with mergify Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants