Skip to content

Commit

Permalink
Add deprecation for the default pattern layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers committed Oct 18, 2021
1 parent f1d320f commit d2f217c
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
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') &&
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`,
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 ' +
'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'\``,
}),
],
},
});
}
};

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

0 comments on commit d2f217c

Please sign in to comment.