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

Add Appender.receiveAllLevels option to fix LegacyAppender #55752

Merged
merged 2 commits into from
Jan 28, 2020

Conversation

joshdover
Copy link
Contributor

Summary

Fixes #55456

The legacy logger & logging configuration work on the concept of log "tags" where each log entry can have a number of tags. In legacy, log levels are not treated special and are really just a tag.

In legacy, this allows logging configurations like:

logging.events.log: ['warning', 'error', 'fatal', 'info', 'testbed']

Any logs that match any of the tags in this array will be logged. This allows the Kibana admin to add the "testbed" tag to the configuration, and get all "testbed" logs regardless of the log level.

In the Platform logger, we filter all logs based on the configured log level, before sending logs to each appender. Since the legacy logger is integrated as a appender in the Platform logger, all Platform logs will be filtered by log level before they can be processed by the legacy logger. This means a configuration like the one above will not forward logs at the debug level to the legacy logger at all.

This change adds a new receiveAllLevels property to the Appender interface that allows us to bypass this filtering for the LegacyAppender and allow the existing tag filtering mechanism in legacy to continue to work the same.

I've opened this PR as a draft before writing tests to make sure we're ok with this temporary approach. Once #41956 is done, we may be able to fix this at the configuration level instead, transforming the legacy config into the appropriate Platform config to get the same behavior.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@joshdover joshdover added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform labels Jan 23, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM as a temporary solution

@joshdover
Copy link
Contributor Author

Added tests. I was going to add some e2e tests but we don't have a great way of inspecting legacy logs without parsing stdout. In the past, these have been really brittle tests.

Since this is somewhat of an edge case and this behavior will be removed in 8.x, I decided against adding yet another brittle test.

@joshdover joshdover added release_note:skip Skip the PR/issue when compiling release notes v7.6.0 labels Jan 24, 2020
@joshdover joshdover marked this pull request as ready for review January 24, 2020 20:36
@joshdover joshdover requested a review from a team as a code owner January 24, 2020 20:36
Comment on lines 414 to 425
test('passes log record to appender with receiveAllLevels: true, regardless if log level is supported', () => {
const receiveAllAppender = { append: jest.fn(), receiveAllLevels: true };
const warnLogger = new BaseLogger(context, LogLevel.Warn, [receiveAllAppender], factory);

warnLogger.trace('trace-message');
expect(receiveAllAppender.append).toHaveBeenCalledTimes(1);
warnLogger.debug('debug-message');
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT:

  • (probably covered in other tests, but) would probably check the call argument after each (or after last call of) expect(receiveAllAppender.append).toHaveBeenCalledTimes(1);
  • Maybe an opposite test with receiveAllLevels : false

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@joshdover joshdover merged commit 7d2074a into elastic:master Jan 28, 2020
@joshdover joshdover deleted the np/debug-logging-fix branch January 28, 2020 14:34
joshdover added a commit to joshdover/kibana that referenced this pull request Jan 28, 2020
@joshdover joshdover added v7.7.0 and removed v7.6.0 labels Jan 28, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 28, 2020
* master: (21 commits)
  [SIEM][Detection Engine] critical blocker updates to latest ECS version
  [Monitoring] Fix inaccuracies in logstash pipeline listing metrics (elastic#55868)
  Resetting errors and removing duplicates (elastic#56054)
  Add flag to opt out from sub url tracking (elastic#55672)
  [SIEM][Detection Engine] critical bug, fixes duplicate tags
  [ML] Anomaly Detection: Fix persist/restore of refreshInterval in globalState. (elastic#56113)
  [ML] Single Metric Viewer: Fix annnotations refresh. (elastic#56107)
  adapt ObjectToConfigAdapter.getFlattenedPaths to consider arrays as final values (elastic#56105)
  Add Appender.receiveAllLevels option to fix LegacyAppender (elastic#55752)
  [ML] Process delimited files like semi-structured text (elastic#56038)
  Charts plugin (combining ui/color_maps and EuiUtils) (elastic#55469)
  fix tutorial documentation (elastic#55996)
  [ML] Fix persist/restore of time/refreshInterval in data visualizer. (elastic#56122)
  [Index Management] Fix errors with validation (elastic#56072)
  [Index Management] Add try/catch when parsing index filter from URI (elastic#56051)
  [NP] add HTTP resources testing strategies (elastic#54908)
  [ML] Single Metric Viewer: Fix brush update on short recent timespans. (elastic#56125)
  [Uptime] Add timeout for slow process to skipped functional tests (elastic#56065)
  refactor (elastic#56121)
  Move tests in dashboard into appropriate folders (elastic#55304)
  ...
@joshdover joshdover mentioned this pull request Feb 3, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform 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 v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Platform / LoggerFactory] Debug messages are not appearing
4 participants