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

x-pack/filebeat/input/cel: fix handling of non-200/non-429 status codes #34002

Merged
merged 2 commits into from
Dec 9, 2022

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Dec 8, 2022

What does this PR do?

Previously, non-200/non-429 status codes would cause an immediate retry, resulting in spamming the server. Treat these responses as an error and wait until the next event period.

Why is it important?

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works — manually tested see [Filebeat] cel input - non HTTP 200 status_code causes rapid retry #33999 for approach
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 self-assigned this Dec 8, 2022
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Dec 8, 2022
Previously, non-200/non-429 status codes would cause an immediate retry,
resulting in spamming the server. Treat these responses as an error and
wait until the next event period.
return false, waitUntil, nil
default:
Copy link
Contributor Author

@efd6 efd6 Dec 8, 2022

Choose a reason for hiding this comment

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

We should consider stratifying these.

@efd6 efd6 marked this pull request as ready for review December 8, 2022 22:13
@efd6 efd6 requested a review from a team as a code owner December 8, 2022 22:13
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 8, 2022

💚 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: 2022-12-09T00:53:53.952+0000

  • Duration: 77 min 51 sec

Test stats 🧪

Test Results
Failed 0
Passed 2514
Skipped 167
Total 2681

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the 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!)

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM. I tested it. Just a minor issue with the "dot" in the field name.

if status == "" {
status = "unknown status code"
}
state["events"] = map[string]interface{}{"error.message": fmt.Sprintf("failed http request with %s: %d", status, statusCode)}
Copy link
Member

Choose a reason for hiding this comment

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

The error.message will result in a key containing a dot. Can you please change that to produce {"error":{"message":....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should happen in the other error.message constructions too then.

Also make error.message structured to avoid dotted field names.
Comment on lines +879 to +881
func errorMessage(msg string) map[string]interface{} {
return map[string]interface{}{"error": map[string]interface{}{"message": msg}}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Query whether this should be

func errorMessage(msg ...string) map[string]interface{} {
	return map[string]interface{}{"error": map[string]interface{}{"message": msg}}
}

@sonarcloud
Copy link

sonarcloud bot commented Dec 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@efd6 efd6 merged commit 64691d3 into elastic:main Dec 9, 2022
mergify bot pushed a commit that referenced this pull request Dec 9, 2022
…es (#34002)

Previously, non-200/non-429 status codes would cause an immediate retry,
resulting in spamming the server. Treat these responses as an error and
wait until the next event period.

Also make error.message structured to avoid dotted field names.

(cherry picked from commit 64691d3)
efd6 added a commit that referenced this pull request Dec 9, 2022
…es (#34002) (#34006)

Previously, non-200/non-429 status codes would cause an immediate retry,
resulting in spamming the server. Treat these responses as an error and
wait until the next event period.

Also make error.message structured to avoid dotted field names.

(cherry picked from commit 64691d3)

Co-authored-by: Dan Kortschak <[email protected]>
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
…es (#34002)

Previously, non-200/non-429 status codes would cause an immediate retry,
resulting in spamming the server. Treat these responses as an error and
wait until the next event period.

Also make error.message structured to avoid dotted field names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.7-candidate backport-v8.6.0 Automated backport with mergify bug Filebeat Filebeat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Filebeat] cel input - non HTTP 200 status_code causes rapid retry
3 participants