Skip to content

Commit 1cb0356

Browse files
[9.1] Standardize how to log errors (#245030) (#245403)
# Backport This will backport the following commits from `main` to `9.1`: - [Standardize how to log errors (#245030)](#245030) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Sebastián Zaffarano","email":"sebastian.zaffarano@elastic.co"},"sourceCommit":{"committedDate":"2025-12-05T15:03:38Z","message":"Standardize how to log errors (#245030)\n\n## Summary\n\nUpdates how we log within the security solution telemetry code. It's\nmainly to use the same object types in the `LogMeta`.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"cab156c3ba4e4a42fcaff4faf8be563ae1d94235","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Logging","Team: SecuritySolution","backport:all-open","ci:build-cloud-image","ci:build-serverless-image","v9.3.0"],"title":"Standardize how to log errors","number":245030,"url":"https://github.com/elastic/kibana/pull/245030","mergeCommit":{"message":"Standardize how to log errors (#245030)\n\n## Summary\n\nUpdates how we log within the security solution telemetry code. It's\nmainly to use the same object types in the `LogMeta`.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"cab156c3ba4e4a42fcaff4faf8be563ae1d94235"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/245030","number":245030,"mergeCommit":{"message":"Standardize how to log errors (#245030)\n\n## Summary\n\nUpdates how we log within the security solution telemetry code. It's\nmainly to use the same object types in the `LogMeta`.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"cab156c3ba4e4a42fcaff4faf8be563ae1d94235"}}]}] BACKPORT--> Co-authored-by: Sebastián Zaffarano <sebastian.zaffarano@elastic.co>
1 parent 4ea9f58 commit 1cb0356

20 files changed

Lines changed: 122 additions & 81 deletions

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/async_sender.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { type Nullable, TelemetryChannel, TelemetryCounter } from './types';
2121
import * as collections from './collections_helpers';
2222
import { CachedSubject, retryOnError$ } from './rxjs_helpers';
2323
import { SenderUtils } from './sender_helpers';
24-
import { copyLicenseFields, newTelemetryLogger } from './helpers';
24+
import { copyLicenseFields, newTelemetryLogger, withErrorMessage } from './helpers';
2525
import { type TelemetryLogger } from './telemetry_logger';
2626

2727
export const DEFAULT_QUEUE_CONFIG: QueueConfig = {
@@ -113,7 +113,7 @@ export class AsyncTelemetryEventsSender implements IAsyncTelemetryEventsSender {
113113
this.logger.warn('Failure! Unable to send events to channel', {
114114
events: result.events,
115115
channel: result.channel,
116-
error: result.message,
116+
error_message: result.message,
117117
} as LogMeta);
118118
this.senderUtils?.incrementCounter(
119119
TelemetryCounter.DOCS_LOST,
@@ -133,7 +133,7 @@ export class AsyncTelemetryEventsSender implements IAsyncTelemetryEventsSender {
133133
}
134134
},
135135
error: (error) => {
136-
this.logger.warn('Unexpected error sending events to channel', { error });
136+
this.logger.warn('Unexpected error sending events to channel', withErrorMessage(error));
137137
},
138138
complete: () => {
139139
this.logger.debug('Shutting down');
@@ -379,7 +379,7 @@ export class AsyncTelemetryEventsSender implements IAsyncTelemetryEventsSender {
379379
channel
380380
);
381381

382-
this.logger.warn('Runtime error', { error });
382+
this.logger.warn('Runtime error', withErrorMessage(error));
383383
throw newFailure(`Error posting events: ${error}`, channel, events.length);
384384
});
385385
} catch (err: unknown) {

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/diagnostic/health_diagnostic_receiver.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
} from './health_diagnostic_circuit_breakers.types';
3434
import { type HealthDiagnosticQuery, QueryType } from './health_diagnostic_service.types';
3535
import type { TelemetryLogger } from '../telemetry_logger';
36-
import { newTelemetryLogger } from '../helpers';
36+
import { newTelemetryLogger, withErrorMessage } from '../helpers';
3737

3838
export class CircuitBreakingQueryExecutorImpl implements CircuitBreakingQueryExecutor {
3939
private readonly logger: TelemetryLogger;
@@ -160,7 +160,7 @@ export class CircuitBreakingQueryExecutorImpl implements CircuitBreakingQueryExe
160160

161161
finalize(() => {
162162
this.client.closePointInTime({ id: pitId }).catch((error) => {
163-
this.logger.warn('>> closePointInTime error', { error });
163+
this.logger.warn('>> closePointInTime error', withErrorMessage(error));
164164
});
165165
})
166166
);
@@ -252,7 +252,10 @@ export class CircuitBreakingQueryExecutorImpl implements CircuitBreakingQueryExe
252252
return indices.filter((indexName) => indexName !== '');
253253
})
254254
.catch((error) => {
255-
this.logger.info('Error while checking ILM status, assuming serverless', { error });
255+
this.logger.info(
256+
'Error while checking ILM status, assuming serverless',
257+
withErrorMessage(error)
258+
);
256259
return [query.index];
257260
});
258261
}

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/diagnostic/health_diagnostic_service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ describe('Security Solution - Health Diagnostic Queries - HealthDiagnosticServic
213213

214214
expect(result).toEqual([]);
215215
expect(mockLogger.warn).toHaveBeenCalledWith(
216-
'Error getting health diagnostic queries: Artifact not found',
216+
'Error getting health diagnostic queries',
217217
expect.any(Object)
218218
);
219219
});

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/diagnostic/health_diagnostic_service.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
TELEMETRY_HEALTH_DIAGNOSTIC_QUERY_STATS_EVENT,
4242
} from '../event_based/events';
4343
import { artifactService } from '../artifact';
44-
import { newTelemetryLogger } from '../helpers';
44+
import { newTelemetryLogger, withErrorMessage } from '../helpers';
4545
import { telemetryConfiguration } from '../configuration';
4646
import { RssGrowthCircuitBreaker } from './circuit_breakers/rss_growth_circuit_breaker';
4747
import { TimeoutCircuitBreaker } from './circuit_breakers/timeout_circuit_breaker';
@@ -165,7 +165,7 @@ export class HealthDiagnosticServiceImpl implements HealthDiagnosticService {
165165
message: error.message,
166166
reason: error instanceof ValidationError ? error.result : undefined,
167167
};
168-
this.logger.error('Error running query', { error });
168+
this.logger.error('Error running query', withErrorMessage(error));
169169
resolve({
170170
...queryStats,
171171
failure,
@@ -296,7 +296,7 @@ export class HealthDiagnosticServiceImpl implements HealthDiagnosticService {
296296
try {
297297
this.analytics.reportEvent(eventTypeOpts.eventType, eventData as object);
298298
} catch (error) {
299-
this.logger.warn('Error sending EBT', { error });
299+
this.logger.warn('Error sending EBT', withErrorMessage(error));
300300
}
301301
}
302302

@@ -312,7 +312,12 @@ export class HealthDiagnosticServiceImpl implements HealthDiagnosticService {
312312

313313
return enabled && isDueForExecution(lastExecutedAt, now, scheduleCron);
314314
} catch (error) {
315-
this.logger.warn('Error processing health query', { error, name: query.name });
315+
this.logger.warn(
316+
'Error processing health query',
317+
withErrorMessage(error, {
318+
name: query.name,
319+
} as LogMeta)
320+
);
316321
return false;
317322
}
318323
});
@@ -323,7 +328,7 @@ export class HealthDiagnosticServiceImpl implements HealthDiagnosticService {
323328
const artifact = await artifactService.getArtifact(QUERY_ARTIFACT_ID);
324329
return parseDiagnosticQueries(artifact.data);
325330
} catch (error) {
326-
this.logger.warn(`Error getting health diagnostic queries: ${error.message}`, { error });
331+
this.logger.warn('Error getting health diagnostic queries', withErrorMessage(error));
327332
return [];
328333
}
329334
}

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/helpers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ export function unflatten<T extends AnyObject = AnyObject>(object: AnyObject): T
557557
}, {}) as T;
558558
}
559559

560+
export function withErrorMessage(error?: Error, meta?: LogMeta): LogMeta {
561+
return {
562+
error,
563+
error_message: error?.message,
564+
...(meta ?? {}),
565+
} as LogMeta;
566+
}
567+
560568
function _set(object: AnyObject, key: string, value: unknown) {
561569
if (key.startsWith('.') || key.endsWith('.') || contiguousDotRegex.test(key)) {
562570
// Preserve original keys with dots used in non-path representations (e.g. '.kibana_field_name')

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/receiver.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
ruleExceptionListItemToTelemetryEvent,
6565
setClusterInfo,
6666
newTelemetryLogger,
67+
withErrorMessage,
6768
} from './helpers';
6869
import { Fetcher } from '../../endpoint/routes/resolver/tree/utils/fetch';
6970
import type { TreeOptions, TreeResponse } from '../../endpoint/routes/resolver/tree/utils/fetch';
@@ -631,8 +632,8 @@ export class TelemetryReceiver implements ITelemetryReceiver {
631632

632633
this.logger.debug('Diagnostic alerts to return', { numOfHits } as LogMeta);
633634
fetchMore = numOfHits > 0 && numOfHits < telemetryConfiguration.telemetry_max_buffer_size;
634-
} catch (e) {
635-
this.logger.warn('Error fetching alerts', { error_message: e.message } as LogMeta);
635+
} catch (error) {
636+
this.logger.warn('Error fetching alerts', withErrorMessage(error));
636637
fetchMore = false;
637638
}
638639

@@ -1017,10 +1018,10 @@ export class TelemetryReceiver implements ITelemetryReceiver {
10171018

10181019
yield alerts;
10191020
}
1020-
} catch (e) {
1021+
} catch (error) {
10211022
// to keep backward compatibility with the previous implementation, silent return
10221023
// once we start using `paginate` this error should be managed downstream
1023-
this.logger.warn('Error fetching alerts', { error_message: e.message } as LogMeta);
1024+
this.logger.warn('Error fetching alerts', withErrorMessage(error));
10241025
return;
10251026
} finally {
10261027
await this.closePointInTime(pitId);
@@ -1044,10 +1045,12 @@ export class TelemetryReceiver implements ITelemetryReceiver {
10441045
try {
10451046
await this.esClient().closePointInTime({ id: pitId });
10461047
} catch (error) {
1047-
this.logger.warn('Error trying to close point in time', {
1048-
pit: pitId,
1049-
error_message: error.message,
1050-
} as LogMeta);
1048+
this.logger.warn(
1049+
'Error trying to close point in time',
1050+
withErrorMessage(error, {
1051+
pit: pitId,
1052+
} as LogMeta)
1053+
);
10511054
}
10521055
}
10531056

@@ -1287,8 +1290,8 @@ export class TelemetryReceiver implements ITelemetryReceiver {
12871290
})) as { license: ESLicense };
12881291

12891292
return ret.license;
1290-
} catch (err) {
1291-
this.logger.warn('failed retrieving license', { error_message: err.message } as LogMeta);
1293+
} catch (error) {
1294+
this.logger.warn('failed retrieving license', withErrorMessage(error));
12921295
return undefined;
12931296
}
12941297
}
@@ -1378,9 +1381,9 @@ export class TelemetryReceiver implements ITelemetryReceiver {
13781381

13791382
yield data;
13801383
} while (esQuery.search_after !== undefined);
1381-
} catch (e) {
1382-
this.logger.warn('Error running paginated query', { error_message: e.message } as LogMeta);
1383-
throw e;
1384+
} catch (error) {
1385+
this.logger.warn('Error running paginated query', withErrorMessage(error));
1386+
throw error;
13841387
} finally {
13851388
await this.closePointInTime(pit.id);
13861389
}
@@ -1439,7 +1442,7 @@ export class TelemetryReceiver implements ITelemetryReceiver {
14391442
})
14401443
)
14411444
.catch((error) => {
1442-
this.logger.warn('Error fetching indices', { error_message: error } as LogMeta);
1445+
this.logger.warn('Error fetching indices', withErrorMessage(error));
14431446
throw error;
14441447
});
14451448
}
@@ -1480,7 +1483,7 @@ export class TelemetryReceiver implements ITelemetryReceiver {
14801483
})
14811484
)
14821485
.catch((error) => {
1483-
this.logger.warn('Error fetching datastreams', { error_message: error } as LogMeta);
1486+
this.logger.warn('Error fetching datastreams', withErrorMessage(error));
14841487
throw error;
14851488
});
14861489
}
@@ -1545,7 +1548,7 @@ export class TelemetryReceiver implements ITelemetryReceiver {
15451548
} as IndexStats;
15461549
}
15471550
} catch (error) {
1548-
this.logger.warn('Error fetching indices stats', { error_message: error } as LogMeta);
1551+
this.logger.warn('Error fetching indices stats', withErrorMessage(error));
15491552
throw error;
15501553
}
15511554
}
@@ -1583,7 +1586,7 @@ export class TelemetryReceiver implements ITelemetryReceiver {
15831586
yield entry;
15841587
}
15851588
} catch (error) {
1586-
this.logger.warn('Error fetching ilm stats', { error_message: error } as LogMeta);
1589+
this.logger.warn('Error fetching ilm stats', withErrorMessage(error));
15871590
throw error;
15881591
}
15891592
}
@@ -1632,7 +1635,7 @@ export class TelemetryReceiver implements ITelemetryReceiver {
16321635
})
16331636
)
16341637
.catch((error) => {
1635-
this.logger.warn('Error fetching index templates', { error_message: error } as LogMeta);
1638+
this.logger.warn('Error fetching index templates', withErrorMessage(error));
16361639
throw error;
16371640
});
16381641
}
@@ -1688,9 +1691,7 @@ export class TelemetryReceiver implements ITelemetryReceiver {
16881691
} as IlmPolicy;
16891692
}
16901693
} catch (error) {
1691-
this.logger.warn('Error fetching ilm policies', {
1692-
error_message: error.message,
1693-
} as LogMeta);
1694+
this.logger.warn('Error fetching ilm policies', withErrorMessage(error));
16941695
throw error;
16951696
}
16961697
}
@@ -1761,9 +1762,7 @@ export class TelemetryReceiver implements ITelemetryReceiver {
17611762
});
17621763
})
17631764
.catch((error) => {
1764-
this.logger.warn('Error fetching ingest pipelines stats', {
1765-
error_message: error,
1766-
} as LogMeta);
1765+
this.logger.warn('Error fetching ingest pipelines stats', withErrorMessage(error));
17671766
throw error;
17681767
});
17691768
}

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/sender.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ import type { ExperimentalFeatures } from '../../../common';
2323
import type { ITelemetryReceiver } from './receiver';
2424
import { copyAllowlistedFields, filterList } from './filterlists';
2525
import { createTelemetryTaskConfigs } from './tasks';
26-
import { copyLicenseFields, createUsageCounterLabel, newTelemetryLogger } from './helpers';
26+
import {
27+
copyLicenseFields,
28+
createUsageCounterLabel,
29+
newTelemetryLogger,
30+
withErrorMessage,
31+
} from './helpers';
2732
import { type TelemetryLogger } from './telemetry_logger';
2833
import type { TelemetryChannel, TelemetryEvent } from './types';
2934
import type { SecurityTelemetryTaskConfig } from './task';
@@ -284,7 +289,7 @@ export class TelemetryEventsSender implements ITelemetryEventsSender {
284289

285290
return false;
286291
} catch (error) {
287-
this.logger.warn('Error pinging telemetry services', { error });
292+
this.logger.warn('Error pinging telemetry services', withErrorMessage(error));
288293

289294
return false;
290295
}
@@ -347,8 +352,8 @@ export class TelemetryEventsSender implements ITelemetryEventsSender {
347352
licenseInfo?.uid,
348353
axiosInstance
349354
);
350-
} catch (err) {
351-
this.logger.warn(`Error sending telemetry events data: ${err}`);
355+
} catch (error) {
356+
this.logger.warn('Error sending telemetry events data', withErrorMessage(error));
352357
this.queue = [];
353358
}
354359
this.isSending = false;
@@ -394,8 +399,8 @@ export class TelemetryEventsSender implements ITelemetryEventsSender {
394399
licenseInfo?.uid,
395400
axiosInstance
396401
);
397-
} catch (err) {
398-
this.logger.warn(`Error sending telemetry events data: ${err}`);
402+
} catch (error) {
403+
this.logger.warn('Error sending telemetry events data', withErrorMessage(error));
399404
}
400405
}
401406

@@ -496,7 +501,7 @@ export class TelemetryEventsSender implements ITelemetryEventsSender {
496501
});
497502
this.logger.debug('Events sent!. Response', { status: resp.status } as LogMeta);
498503
} catch (error) {
499-
this.logger.warn('Error sending events', { error });
504+
this.logger.warn('Error sending events', withErrorMessage(error));
500505
const errorStatus = error?.response?.status;
501506
if (errorStatus !== undefined && errorStatus !== null) {
502507
this.telemetryUsageCounter?.incrementCounter({

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/task.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { ITelemetryReceiver } from './receiver';
1616
import type { ITelemetryEventsSender } from './sender';
1717
import type { ITaskMetricsService } from './task_metrics.types';
1818
import { stateSchemaByVersion, emptyState, type LatestTaskStateSchema } from './task_state';
19-
import { newTelemetryLogger } from './helpers';
19+
import { newTelemetryLogger, withErrorMessage } from './helpers';
2020
import { type TelemetryLogger } from './telemetry_logger';
2121

2222
export interface SecurityTelemetryTaskConfig {
@@ -136,7 +136,7 @@ export class SecurityTelemetryTask {
136136
params: { version: this.config.version },
137137
});
138138
} catch (error) {
139-
this.logger.error('Error scheduling task', { error });
139+
this.logger.error('Error scheduling task', withErrorMessage(error));
140140
}
141141
};
142142

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/tasks/configuration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { TaskExecutionPeriod } from '../task';
1313
import type { ITaskMetricsService } from '../task_metrics.types';
1414
import { artifactService } from '../artifact';
1515
import { telemetryConfiguration } from '../configuration';
16-
import { newTelemetryLogger } from '../helpers';
16+
import { newTelemetryLogger, withErrorMessage } from '../helpers';
1717

1818
export function createTelemetryConfigurationTaskConfig() {
1919
const taskName = 'Security Solution Telemetry Configuration Task';
@@ -143,7 +143,7 @@ export function createTelemetryConfigurationTaskConfig() {
143143
log.debug('Updated TelemetryConfiguration');
144144
return 0;
145145
} catch (error) {
146-
log.warn('Failed to set telemetry configuration', { error });
146+
log.warn('Failed to set telemetry configuration', withErrorMessage(error));
147147
telemetryConfiguration.resetAllToDefault();
148148
await taskMetricsService.end(trace, error);
149149
return 0;

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/tasks/custom_response_actions_rule.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
newTelemetryLogger,
1414
createUsageCounterLabel,
1515
safeValue,
16+
withErrorMessage,
1617
} from '../helpers';
1718
import type { ITelemetryEventsSender } from '../sender';
1819
import type { ITelemetryReceiver } from '../receiver';
@@ -146,8 +147,9 @@ export function createTelemetryCustomResponseActionRulesTaskConfig(maxTelemetryB
146147
} as LogMeta);
147148

148149
return totalCount;
149-
} catch (err) {
150-
await taskMetricsService.end(trace, err);
150+
} catch (error) {
151+
log.warn('Error running custom response actions rule task', withErrorMessage(error));
152+
await taskMetricsService.end(trace, error);
151153
return 0;
152154
}
153155
},

0 commit comments

Comments
 (0)