From b030e14a7ff622047c66b9dc691df2c6db3ee8cb Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:46:04 +0200 Subject: [PATCH] [8.15] [Telemetry][Security Solution] Always enrich telemetry documents with license info (#188832) (#189256) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.15`: - [[Telemetry][Security Solution] Always enrich telemetry documents with license info (#188832)](https://github.com/elastic/kibana/pull/188832) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Sebastián Zaffarano --- .../server/lib/telemetry/async_sender.ts | 25 +++++-------------- ...remove_time_fields_from_telemetry_stats.ts | 2 ++ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/security_solution/server/lib/telemetry/async_sender.ts b/x-pack/plugins/security_solution/server/lib/telemetry/async_sender.ts index 6c2def2abb61d..edbd5d21e3aea 100644 --- a/x-pack/plugins/security_solution/server/lib/telemetry/async_sender.ts +++ b/x-pack/plugins/security_solution/server/lib/telemetry/async_sender.ts @@ -276,28 +276,15 @@ export class AsyncTelemetryEventsSender implements IAsyncTelemetryEventsSender { private enrich(event: Event): Event { const clusterInfo = this.telemetryReceiver?.getClusterInfo(); - // TODO(szaffarano): generalize the enrichment at channel level to not hardcode the logic here if (typeof event.payload === 'object') { let additional = {}; - if (event.channel !== TelemetryChannel.TASK_METRICS) { - additional = { - cluster_name: clusterInfo?.cluster_name, - cluster_uuid: clusterInfo?.cluster_uuid, - }; - } else { - additional = { - cluster_uuid: clusterInfo?.cluster_uuid, - }; - } - - if (event.channel === TelemetryChannel.ENDPOINT_ALERTS) { - const licenseInfo = this.telemetryReceiver?.getLicenseInfo(); - additional = { - ...additional, - ...(licenseInfo ? { license: copyLicenseFields(licenseInfo) } : {}), - }; - } + const licenseInfo = this.telemetryReceiver?.getLicenseInfo(); + additional = { + cluster_name: clusterInfo?.cluster_name, + cluster_uuid: clusterInfo?.cluster_uuid, + ...(licenseInfo ? { license: copyLicenseFields(licenseInfo) } : {}), + }; event.payload = { ...event.payload, diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/remove_time_fields_from_telemetry_stats.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/remove_time_fields_from_telemetry_stats.ts index 912649862a24f..2d27b375684ba 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/remove_time_fields_from_telemetry_stats.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/telemetry/remove_time_fields_from_telemetry_stats.ts @@ -15,6 +15,8 @@ export const removeExtraFieldsFromTelemetryStats = (stats: any) => { unset(value, `[${i}][${j}].start_time`); unset(value, `[${i}][${j}].end_time`); unset(value, `[${i}][${j}].cluster_uuid`); + unset(value, `[${i}][${j}].cluster_name`); + unset(value, `[${i}][${j}].license`); }); }); });