From 7f73ef86a064040a4a2e0ef8edf4ba43b8355133 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Tue, 19 Nov 2024 00:30:16 +0200 Subject: [PATCH] [ResponseOps][Cases] Remove deprecated date format from telemetry (#200331) ## Summary The Cases telemetry uses a deprecated date format that will not be supported in 9.0. This PR changes the format of the date set in the `format` field as suggested here https://www.elastic.co/blog/locale-changes-elasticsearch-8-16-jdk-23. Specifically, it changes `Y` to `y`. From the docs: > In particular, if you are using the Y specifier as part of a calendar date format, you are probably using it erroneously; Joda time uses Y to represent year-of-era, but the JDK uses Y to represent week-years. You need to modify your format to use y instead, or change to a built-in format. Fixes: https://github.com/elastic/kibana-team/issues/1188 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit 7ace26213d6e7e493144c70a4f408cb9939d1fb0) --- .../plugins/cases/server/telemetry/queries/alerts.test.ts | 2 +- .../plugins/cases/server/telemetry/queries/cases.test.ts | 8 ++++---- .../cases/server/telemetry/queries/comments.test.ts | 2 +- .../cases/server/telemetry/queries/user_actions.test.ts | 2 +- .../plugins/cases/server/telemetry/queries/utils.test.ts | 6 +++--- x-pack/plugins/cases/server/telemetry/queries/utils.ts | 4 ++-- .../security_and_spaces/tests/common/telemetry.ts | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/cases/server/telemetry/queries/alerts.test.ts b/x-pack/plugins/cases/server/telemetry/queries/alerts.test.ts index fd00aea939dc8..af300cb80ad54 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/alerts.test.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/alerts.test.ts @@ -62,7 +62,7 @@ describe('alerts', () => { counts: { date_range: { field: 'cases-comments.attributes.created_at', - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', diff --git a/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts b/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts index fdfe39f940e9b..b33b588fd951b 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts @@ -469,7 +469,7 @@ describe('getCasesTelemetryData', () => { "counts": Object { "date_range": Object { "field": "cases.attributes.created_at", - "format": "dd/MM/YYYY", + "format": "dd/MM/yyyy", "ranges": Array [ Object { "from": "now-1d", @@ -501,7 +501,7 @@ describe('getCasesTelemetryData', () => { "counts": Object { "date_range": Object { "field": "cases.attributes.created_at", - "format": "dd/MM/YYYY", + "format": "dd/MM/yyyy", "ranges": Array [ Object { "from": "now-1d", @@ -547,7 +547,7 @@ describe('getCasesTelemetryData', () => { "counts": Object { "date_range": Object { "field": "cases.attributes.created_at", - "format": "dd/MM/YYYY", + "format": "dd/MM/yyyy", "ranges": Array [ Object { "from": "now-1d", @@ -605,7 +605,7 @@ describe('getCasesTelemetryData', () => { "counts": Object { "date_range": Object { "field": "cases.attributes.created_at", - "format": "dd/MM/YYYY", + "format": "dd/MM/yyyy", "ranges": Array [ Object { "from": "now-1d", diff --git a/x-pack/plugins/cases/server/telemetry/queries/comments.test.ts b/x-pack/plugins/cases/server/telemetry/queries/comments.test.ts index d3104bd9a79ad..71ee6af56194a 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/comments.test.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/comments.test.ts @@ -62,7 +62,7 @@ describe('comments', () => { counts: { date_range: { field: 'cases-comments.attributes.created_at', - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', diff --git a/x-pack/plugins/cases/server/telemetry/queries/user_actions.test.ts b/x-pack/plugins/cases/server/telemetry/queries/user_actions.test.ts index b6c45d8da3efc..a749dadb8ccd2 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/user_actions.test.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/user_actions.test.ts @@ -62,7 +62,7 @@ describe('user_actions', () => { counts: { date_range: { field: 'cases-user-actions.attributes.created_at', - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', diff --git a/x-pack/plugins/cases/server/telemetry/queries/utils.test.ts b/x-pack/plugins/cases/server/telemetry/queries/utils.test.ts index b4b18f231eb6a..5aa5ac5b39ce3 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/utils.test.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/utils.test.ts @@ -817,7 +817,7 @@ describe('utils', () => { counts: { date_range: { field: 'test.attributes.created_at', - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', to: 'now' }, { from: 'now-1w', to: 'now' }, @@ -1132,7 +1132,7 @@ describe('utils', () => { counts: { date_range: { field: 'test.attributes.created_at', - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', @@ -1261,7 +1261,7 @@ describe('utils', () => { counts: { date_range: { field: 'cases-comments.attributes.created_at', - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', diff --git a/x-pack/plugins/cases/server/telemetry/queries/utils.ts b/x-pack/plugins/cases/server/telemetry/queries/utils.ts index 6992ed8f7ac06..fdff93bd24154 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/utils.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/utils.ts @@ -38,7 +38,7 @@ export const getCountsAggregationQuery = (savedObjectType: string) => ({ counts: { date_range: { field: `${savedObjectType}.attributes.created_at`, - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', to: 'now' }, { from: 'now-1w', to: 'now' }, @@ -52,7 +52,7 @@ export const getAlertsCountsAggregationQuery = () => ({ counts: { date_range: { field: `${CASE_COMMENT_SAVED_OBJECT}.attributes.created_at`, - format: 'dd/MM/YYYY', + format: 'dd/MM/yyyy', ranges: [ { from: 'now-1d', to: 'now' }, { from: 'now-1w', to: 'now' }, diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/telemetry.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/telemetry.ts index c83210e51e5d5..10dc3d617c582 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/telemetry.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/telemetry.ts @@ -52,7 +52,7 @@ export default ({ getService }: FtrProviderContext): void => { }); }); - it('should return the corect total number of alerts attached to cases', async () => { + it('should return the correct total number of alerts attached to cases', async () => { const firstCase = await createCase(supertest, getPostCaseRequest()); const secondCase = await createCase(supertest, getPostCaseRequest());