[Telemetry][Security Solution] Always enrich telemetry documents with license info (#188832)

This commit is contained in:
Sebastián Zaffarano 2024-07-26 11:02:56 +02:00 committed by GitHub
parent 3f3713b567
commit 61ad27e863
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 19 deletions

View file

@ -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,

View file

@ -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`);
});
});
});