diff --git a/docs/migration/migrate_7_0.asciidoc b/docs/migration/migrate_7_0.asciidoc index 60272acc8ad28..7a9dd5ebae21e 100644 --- a/docs/migration/migrate_7_0.asciidoc +++ b/docs/migration/migrate_7_0.asciidoc @@ -56,3 +56,8 @@ considered unique based on its persistent UUID, which is written to the path.dat *Details:* The `/shorten` API has been deprecated since 6.5, when it was replaced by the `/api/shorten_url` API. *Impact:* The '/shorten' API has been removed. Use the '/api/shorten_url' API instead. + +=== Deprecated kibana.yml setting logging.useUTC has been replaced with logging.timezone +*Details:* Any timezone can now be specified by canonical id. + +*Impact:* The logging.useUTC flag will have to be replaced with a timezone id. If set to true the id is `UTC`. diff --git a/docs/setup/settings.asciidoc b/docs/setup/settings.asciidoc index 1f09e5dc6e2a6..7a21705336313 100644 --- a/docs/setup/settings.asciidoc +++ b/docs/setup/settings.asciidoc @@ -73,7 +73,7 @@ error messages. [[logging-verbose]]`logging.verbose:`:: *Default: false* Set the value of this setting to `true` to log all events, including system usage information and all requests. Supported on Elastic Cloud Enterprise. -`logging.useUTC`:: *Default: true* Set the value of this setting to `false` to log events using the timezone of the server, rather than UTC. +`logging.timezone`:: *Default: UTC* Set to the canonical timezone id (e.g. `US/Pacific`) to log events using that timezone. A list of timezones can be referenced at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. `map.includeElasticMapsService:`:: *Default: true* Turns on or off whether layers from the Elastic Maps Service should be included in the vector and tile layer option list. By turning this off, only the layers that are configured here will be included. diff --git a/src/server/config/schema.js b/src/server/config/schema.js index 6fa09a400cc09..3648e88fac2e8 100644 --- a/src/server/config/schema.js +++ b/src/server/config/schema.js @@ -186,7 +186,7 @@ export default () => Joi.object({ then: Joi.default(!process.stdout.isTTY), otherwise: Joi.default(true) }), - useUTC: Joi.boolean().default(true), + timezone: Joi.string().allow(false).default('UTC') }).default(), ops: Joi.object({ diff --git a/src/server/config/transform_deprecations.js b/src/server/config/transform_deprecations.js index 44571cee6c58d..d15e171f031ff 100644 --- a/src/server/config/transform_deprecations.js +++ b/src/server/config/transform_deprecations.js @@ -17,8 +17,9 @@ * under the License. */ -import _, { partial } from 'lodash'; +import _, { partial, set } from 'lodash'; import { createTransform, Deprecations } from '../../deprecation'; +import { unset } from '../../utils'; const { rename, unused } = Deprecations; @@ -55,6 +56,15 @@ const rewriteBasePath = (settings, log) => { } }; +const loggingTimezone = (settings, log) => { + if (_.has(settings, 'logging.useUTC')) { + const timezone = settings.logging.useUTC ? 'UTC' : false; + set('logging.timezone', timezone); + unset(settings, 'logging.UTC'); + log(`Config key "logging.useUTC" is deprecated. It has been replaced with "logging.timezone"`); + } +}; + const deprecations = [ //server rename('server.ssl.cert', 'server.ssl.certificate'), @@ -68,6 +78,7 @@ const deprecations = [ serverSslEnabled, savedObjectsIndexCheckTimeout, rewriteBasePath, + loggingTimezone, ]; export const transformDeprecations = createTransform(deprecations); diff --git a/src/server/logging/configuration.js b/src/server/logging/configuration.js index beec30b54bccb..59019ad873129 100644 --- a/src/server/logging/configuration.js +++ b/src/server/logging/configuration.js @@ -61,7 +61,7 @@ export default function loggingConfiguration(config) { config: { json: config.get('logging.json'), dest: config.get('logging.dest'), - useUTC: config.get('logging.useUTC'), + timezone: config.get('logging.timezone'), // I'm adding the default here because if you add another filter // using the commandline it will remove authorization. I want users diff --git a/src/server/logging/log_format.js b/src/server/logging/log_format.js index 43ffca7fd39c6..994b5af8b89f4 100644 --- a/src/server/logging/log_format.js +++ b/src/server/logging/log_format.js @@ -18,7 +18,7 @@ */ import Stream from 'stream'; -import moment from 'moment'; +import moment from 'moment-timezone'; import { get, _ } from 'lodash'; import numeral from '@elastic/numeral'; import chalk from 'chalk'; @@ -66,10 +66,10 @@ export default class TransformObjStream extends Stream.Transform { } extractAndFormatTimestamp(data, format) { - const { useUTC } = this.config; + const { timezone } = this.config; const date = moment(data['@timestamp']); - if (useUTC) { - date.utc(); + if (timezone) { + date.tz(timezone); } return date.format(format); } diff --git a/src/server/logging/log_format_json.test.js b/src/server/logging/log_format_json.test.js index b9878e63f0898..1632b2b401c8a 100644 --- a/src/server/logging/log_format_json.test.js +++ b/src/server/logging/log_format_json.test.js @@ -196,10 +196,10 @@ describe('KbnLoggerJsonFormat', () => { }); }); - describe('useUTC', () => { - it('logs in UTC when useUTC is true', async () => { + describe('timezone', () => { + it('logs in UTC', async () => { const format = new KbnLoggerJsonFormat({ - useUTC: true + timezone: 'UTC' }); const result = await createPromiseFromStreams([ @@ -211,10 +211,8 @@ describe('KbnLoggerJsonFormat', () => { expect(timestamp).toBe(moment.utc(time).format()); }); - it('logs in local timezone when useUTC is false', async () => { - const format = new KbnLoggerJsonFormat({ - useUTC: false - }); + it('logs in local timezone timezone is undefined', async () => { + const format = new KbnLoggerJsonFormat({}); const result = await createPromiseFromStreams([ createListStream([makeEvent('log')]), diff --git a/src/server/logging/log_format_string.test.js b/src/server/logging/log_format_string.test.js index ca572f8c03e66..e20b5eb59b76c 100644 --- a/src/server/logging/log_format_string.test.js +++ b/src/server/logging/log_format_string.test.js @@ -37,9 +37,9 @@ const makeEvent = () => ({ }); describe('KbnLoggerStringFormat', () => { - it('logs in UTC when useUTC is true', async () => { + it('logs in UTC', async () => { const format = new KbnLoggerStringFormat({ - useUTC: true + timezone: 'UTC' }); const result = await createPromiseFromStreams([ @@ -51,10 +51,8 @@ describe('KbnLoggerStringFormat', () => { .toContain(moment.utc(time).format('HH:mm:ss.SSS')); }); - it('logs in local timezone when useUTC is false', async () => { - const format = new KbnLoggerStringFormat({ - useUTC: false - }); + it('logs in local timezone when timezone is undefined', async () => { + const format = new KbnLoggerStringFormat({}); const result = await createPromiseFromStreams([ createListStream([makeEvent()]),