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

[HTTP] Add more info to the log.error metadata #169552

Merged

Conversation

afharo
Copy link
Member

@afharo afharo commented Oct 23, 2023

Summary

Adding a few fields to the ECS metadata in the HTTP error logs:

  • error.message: cherry-picking the error message only to avoid unintended leak of information if the error contains too much info in its properties
  • request.method and request.path: so that we know to which handler the error is scoped. Note that the path is the registered path (with variable templates), not the final path

The reason: we need to be able to have a hint of what's the error behind a blind [ERROR][http] 500 Server Error.

For maintainers

@afharo afharo added Feature:http Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels Oct 23, 2023
@afharo afharo self-assigned this Oct 23, 2023
@afharo afharo requested a review from a team as a code owner October 23, 2023 16:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@@ -217,7 +217,11 @@ export class Router<Context extends RequestHandlerContextBase = RequestHandlerCo
// forward 401 errors from ES client
if (isElasticsearchUnauthorizedError(error)) {
this.log.error(`401 Unauthorized`, {
http: { response: { status_code: 401 } },
http: {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can enrich the error logged on line 203 too.

Copy link
Contributor

@gsoldevila gsoldevila left a comment

Choose a reason for hiding this comment

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

LGTM on green! 🚀

@afharo afharo enabled auto-merge (squash) October 24, 2023 09:46
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @afharo

@afharo afharo merged commit 47ade5c into elastic:main Oct 24, 2023
29 checks passed
@afharo afharo deleted the http-route-handler/add-more-info-to-error-log branch October 24, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:http release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants