Skip to content

Commit

Permalink
[Telemetry][Security Solution] Always enrich telemetry documents with…
Browse files Browse the repository at this point in the history
… license info (elastic#188832)
  • Loading branch information
szaffarano authored Jul 26, 2024
1 parent 3f3713b commit 61ad27e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
});
});
});
Expand Down

0 comments on commit 61ad27e

Please sign in to comment.