-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[core.logging] Add response logs to the KP logging system. #87939
Conversation
380ec1b
to
8b4a686
Compare
38066d4
to
3abc700
Compare
ed5c79a
to
cbba96a
Compare
// To avoid duplicate logs, we explicitly disable these in verbose | ||
// mode as they are already provided by the new logging config under | ||
// the `http.server.Kibana.response` context. | ||
request: '!', | ||
response: '!', |
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.
We had discussed doing this as a means of preventing duplicate log entries where possible, however I just wanted to call it out before merging as technically it's a breaking change since the new log format is slightly different from the old one.
Folks using logging.verbose
will still get response logs, they'll just look a bit different.
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.
to call it out before merging as technically it's a breaking change since the new log format is slightly different from the old one.
it is not necessarily so. you can declare a custom pattern
for http request / response context so that the format is as close to the old version as possible.
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 is not necessarily so
Yea, but that would require manual configuration change from the user, so unsure this is good enough to not consider that breaking?
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.
that would require manual configuration change from the user, so unsure this is good enough to not consider that breaking?
Yeah this is the question I was getting at. Totally agree there are workarounds to minimize disruption (custom pattern
, or manually setting logging.events.response
) - the question is whether we are okay forcing users to make a manual configuration change to restore the old format (even if the message contents are essentially the same).
Or I guess what we are really asking: Is it worse to inconvenience users with duplicate log messages (which are already quite chatty), or to break a log message format (which they could manually fix)?
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.
Yea, but that would require manual configuration change from the user
we can leverage logging service API to customize the pattern. WDYT ?
kibana/x-pack/plugins/security/server/audit/audit_service.ts
Lines 222 to 240 in 2b5071f
export const createLoggingConfig = (config: ConfigType['audit']) => | |
map<Pick<SecurityLicenseFeatures, 'allowAuditLogging'>, LoggerContextConfigInput>((features) => ({ | |
appenders: { | |
auditTrailAppender: config.appender ?? { | |
kind: 'console', | |
layout: { | |
kind: 'pattern', | |
highlight: true, | |
}, | |
}, | |
}, | |
loggers: [ | |
{ | |
context: 'audit.ecs', | |
level: config.enabled && config.appender && features.allowAuditLogging ? 'info' : 'off', | |
appenders: ['auditTrailAppender'], | |
}, | |
], | |
})); |
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.
@restrry Just to be clear, you mean apply a custom pattern to the http services response logs to format them in a way that's BWC with legacy logs, but only when using verbose logs & stdout?
I guess the tradeoff would then be that users relying on the new http response logs would suddenly have a different message format when verbose=true, which wouldn't technically be breaking as it is a new set of logs, but might be confusing nonetheless.
FWIW, I don't think introducing duplication would be the end of the world if we needed to go that route... I really could go either way on this.
Pinging @elastic/kibana-core (Team:Core) |
@elasticmachine merge upstream |
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.
Overall, the implementation LGTM and works as expected. We have a few questions to iron out but it's a huge step closer to feature parity!
f92cf1b
to
5d87516
Compare
@restrry Agree - I had thought something similar, it feels like having the
I think this is a viable option too - the only caveat being creating an additional step for support when it comes to debugging problems. ("Can you enable verbose logs, and if you aren't using json, also create a custom console appender with a pattern that includes the meta?"). Not a huge deal if we have examples in kibana.yml, but worth considering. I guess if someone is enabling EDIT: I misread your comment on this the first time around. I like the approach of having per-context default appenders... I could see this being a good solution as well. 👍 |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Closes #13241
Also fixes #80544
Summary
This introduces response logging to the new logging system, one of the planned improvements needed to bring us to feature parity with legacy logging.
Legacy response logs are provided by the
@hapi/good
plugin, but since we are aiming to get rid of that dependency, we need to do some of the work ourselves in the new logging system.Details
In legacy logging, response logs can be enabled either by setting
logging.verbose: true
, or by enabling one of the specificevent
filters which are passed to the@hapi/good
configuration:This results in a response log like this (when logging to stdout):
This PR introduces a new logger context in the
http
server:http.server.response
. All requests/responses are logged at thedebug
level, meaning that, as in the legacy world, they are not shown by default. To see them, you need to allowdebug
logs for the logger:The logs look like this (again, logging to console):
Note that we've added ECS-compatible structured
LogMeta
, in addition to the log message (which remains the same as legacy).Changes
on('response')
event.logging.events.request
andlogging.events.response
& updates docs.logging.verbose: true
, as this results in duplicate data with the new http logs.Plugin API Changes
We are deprecating the legacy response logs which were enabled when
logging.verbose: true
or when usinglogging.events.request
andlogging.events.response
. They will be removed completely in8.0
, and have been replaced with new response logs which are provided under thehttp.server.response
context at thedebug
level:Before
After
For more information, check out the section on logging config migration in the logging README.