Skip to content

Commit

Permalink
[8.15] [Telemetry][Security Solution] Always enrich telemetry documen…
Browse files Browse the repository at this point in the history
…ts with license info (#188832) (#189256)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Telemetry][Security Solution] Always enrich telemetry documents with
license info (#188832)](#188832)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sebastián
Zaffarano","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-26T09:02:56Z","message":"[Telemetry][Security
Solution] Always enrich telemetry documents with license info
(#188832)","sha":"61ad27e8632b1fa60256ffb6f0878fda96665cf5","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:
SecuritySolution","v8.15.0","v8.16.0"],"title":"[Telemetry][Security
Solution] Always enrich telemetry documents with license
info","number":188832,"url":"https://github.com/elastic/kibana/pull/188832","mergeCommit":{"message":"[Telemetry][Security
Solution] Always enrich telemetry documents with license info
(#188832)","sha":"61ad27e8632b1fa60256ffb6f0878fda96665cf5"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188832","number":188832,"mergeCommit":{"message":"[Telemetry][Security
Solution] Always enrich telemetry documents with license info
(#188832)","sha":"61ad27e8632b1fa60256ffb6f0878fda96665cf5"}}]}]
BACKPORT-->

Co-authored-by: Sebastián Zaffarano <[email protected]>
  • Loading branch information
kibanamachine and szaffarano authored Jul 26, 2024
1 parent 975b710 commit b030e14
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 b030e14

Please sign in to comment.