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

[logging] Add deprecation for the default pattern layout. #115316

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/core/server/config/deprecation/core_deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,52 @@ describe('core deprecations', () => {
`);
});
});

describe('using default pattern layout', () => {
it('warns when console appender is used', () => {
const { messages } = applyCoreDeprecations({
logging: {
root: {
appenders: ['default', 'console', 'test'],
},
},
});
expect(messages).toMatchInlineSnapshot(`
Array [
"It looks like you are using Kibana's built-in \`console\` appender, which uses the \\"pattern\\" layout by default. In 8.0, the default layout will switch to JSON, which is ECS-compliant. If you are relying on the default pattern layout for log ingestion, be sure to explicitly configure this in your Kibana configuration to prevent any disruption when upgrading to 8.0.",
]
`);
});

it('does not warn when console appender is not used', () => {
const { messages } = applyCoreDeprecations({
logging: {
root: {
level: 'warn',
},
},
});
expect(messages).toMatchInlineSnapshot(`Array []`);
});

it('does not warn when console appender is overwritten', () => {
const { messages } = applyCoreDeprecations({
logging: {
appenders: {
console: {
type: 'console',
layout: {
type: 'pattern',
pattern: 'testing',
},
},
},
root: {
appenders: ['default', 'console'],
},
},
});
expect(messages).toMatchInlineSnapshot(`Array []`);
});
});
});
40 changes: 40 additions & 0 deletions src/core/server/config/deprecation/core_deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,45 @@ const logFilterDeprecation: ConfigDeprecation = (
}
};

const patternLayoutDefaultLoggingDeprecation: ConfigDeprecation = (
settings,
fromPath,
addDeprecation,
{ branch }
) => {
if (
settings.logging?.root?.appenders?.includes('console') &&
lukeelmers marked this conversation as resolved.
Show resolved Hide resolved
settings.logging?.appenders?.console === undefined
) {
addDeprecation({
configPath: 'logging.root.appenders',
level: 'warning',
documentationUrl: `https://github.com/elastic/kibana/blob/${branch}/src/core/server/logging/README.mdx#configuration`,
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll open a follow-up PR to improve our documentation and can adjust this link at that time. Just wanted to get this PR up first so that we can get it in before FF.

title: i18n.translate('core.deprecations.loggingPatternLayoutDefault.deprecationTitle', {
defaultMessage: `Kibana's default log format is changing to ECS JSON`,
}),
message: i18n.translate('core.deprecations.loggingPatternLayoutDefault.deprecationMessage', {
defaultMessage:
"It looks like you are using Kibana's built-in `console` appender, " +
'which uses the "pattern" layout by default. In 8.0, the default layout ' +
'will switch to JSON, which is ECS-compliant. If you are relying on the ' +
lukeelmers marked this conversation as resolved.
Show resolved Hide resolved
'default pattern layout for log ingestion, be sure to explicitly configure this ' +
'in your Kibana configuration to prevent any disruption when upgrading to 8.0.',
}),
correctiveActions: {
manualSteps: [
i18n.translate('core.deprecations.loggingPatternLayoutDefault.manualSteps1', {
defaultMessage: `[recommended] Update your log ingestion configuration to use ECS format.`,
}),
i18n.translate('core.deprecations.loggingPatternLayoutDefault.manualSteps2', {
defaultMessage: `Alternatively, you can preserve the existing format by configuring a custom appender with \`layout.type: 'pattern'\``,
}),
Comment on lines +630 to +635
Copy link
Member Author

Choose a reason for hiding this comment

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

I struggled with how to phrase these; any feedback is welcomed.

],
},
});
}
};

export const coreDeprecationProvider: ConfigDeprecationProvider = ({
unusedFromRoot,
renameFromRoot,
Expand Down Expand Up @@ -651,4 +690,5 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({
logEventsLogDeprecation,
logEventsErrorDeprecation,
logFilterDeprecation,
patternLayoutDefaultLoggingDeprecation,
];