mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Security Solution] Add Task Metric Collection to New Tasks (#145181)
## Summary Adding task metric collections to the recently added kibana tasks
This commit is contained in:
parent
105e54fe96
commit
24df1db3a5
2 changed files with 20 additions and 2 deletions
|
@ -6,13 +6,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Logger } from '@kbn/core/server';
|
import type { Logger } from '@kbn/core/server';
|
||||||
|
import { TASK_METRICS_CHANNEL } from '../constants';
|
||||||
import type { ITelemetryEventsSender } from '../sender';
|
import type { ITelemetryEventsSender } from '../sender';
|
||||||
import type { TelemetryConfiguration } from '../types';
|
import type { TelemetryConfiguration } from '../types';
|
||||||
import type { ITelemetryReceiver } from '../receiver';
|
import type { ITelemetryReceiver } from '../receiver';
|
||||||
import type { TaskExecutionPeriod } from '../task';
|
import type { TaskExecutionPeriod } from '../task';
|
||||||
import { artifactService } from '../artifact';
|
import { artifactService } from '../artifact';
|
||||||
import { telemetryConfiguration } from '../configuration';
|
import { telemetryConfiguration } from '../configuration';
|
||||||
import { tlog } from '../helpers';
|
import { createTaskMetric, tlog } from '../helpers';
|
||||||
|
|
||||||
export function createTelemetryConfigurationTaskConfig() {
|
export function createTelemetryConfigurationTaskConfig() {
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +29,8 @@ export function createTelemetryConfigurationTaskConfig() {
|
||||||
sender: ITelemetryEventsSender,
|
sender: ITelemetryEventsSender,
|
||||||
taskExecutionPeriod: TaskExecutionPeriod
|
taskExecutionPeriod: TaskExecutionPeriod
|
||||||
) => {
|
) => {
|
||||||
|
const startTime = Date.now();
|
||||||
|
const taskName = 'Security Solution Telemetry Configuration Task';
|
||||||
try {
|
try {
|
||||||
const artifactName = 'telemetry-buffer-and-batch-sizes-v1';
|
const artifactName = 'telemetry-buffer-and-batch-sizes-v1';
|
||||||
const configArtifact = (await artifactService.getArtifact(
|
const configArtifact = (await artifactService.getArtifact(
|
||||||
|
@ -42,10 +45,16 @@ export function createTelemetryConfigurationTaskConfig() {
|
||||||
configArtifact.max_endpoint_telemetry_batch;
|
configArtifact.max_endpoint_telemetry_batch;
|
||||||
telemetryConfiguration.max_security_list_telemetry_batch =
|
telemetryConfiguration.max_security_list_telemetry_batch =
|
||||||
configArtifact.max_security_list_telemetry_batch;
|
configArtifact.max_security_list_telemetry_batch;
|
||||||
|
await sender.sendOnDemand(TASK_METRICS_CHANNEL, [
|
||||||
|
createTaskMetric(taskName, true, startTime),
|
||||||
|
]);
|
||||||
return 0;
|
return 0;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
tlog(logger, `Failed to set telemetry configuration due to ${err.message}`);
|
tlog(logger, `Failed to set telemetry configuration due to ${err.message}`);
|
||||||
telemetryConfiguration.resetAllToDefault();
|
telemetryConfiguration.resetAllToDefault();
|
||||||
|
await sender.sendOnDemand(TASK_METRICS_CHANNEL, [
|
||||||
|
createTaskMetric(taskName, false, startTime, err.message),
|
||||||
|
]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Logger } from '@kbn/core/server';
|
import type { Logger } from '@kbn/core/server';
|
||||||
|
import { TASK_METRICS_CHANNEL } from '../constants';
|
||||||
import type { ITelemetryEventsSender } from '../sender';
|
import type { ITelemetryEventsSender } from '../sender';
|
||||||
import type { TelemetryFilterListArtifact } from '../types';
|
import type { TelemetryFilterListArtifact } from '../types';
|
||||||
import type { ITelemetryReceiver } from '../receiver';
|
import type { ITelemetryReceiver } from '../receiver';
|
||||||
import type { TaskExecutionPeriod } from '../task';
|
import type { TaskExecutionPeriod } from '../task';
|
||||||
import { artifactService } from '../artifact';
|
import { artifactService } from '../artifact';
|
||||||
import { filterList } from '../filterlists';
|
import { filterList } from '../filterlists';
|
||||||
import { tlog } from '../helpers';
|
import { createTaskMetric, tlog } from '../helpers';
|
||||||
|
|
||||||
export function createTelemetryFilterListArtifactTaskConfig() {
|
export function createTelemetryFilterListArtifactTaskConfig() {
|
||||||
return {
|
return {
|
||||||
|
@ -28,6 +29,8 @@ export function createTelemetryFilterListArtifactTaskConfig() {
|
||||||
sender: ITelemetryEventsSender,
|
sender: ITelemetryEventsSender,
|
||||||
taskExecutionPeriod: TaskExecutionPeriod
|
taskExecutionPeriod: TaskExecutionPeriod
|
||||||
) => {
|
) => {
|
||||||
|
const startTime = Date.now();
|
||||||
|
const taskName = 'Security Solution Telemetry Filter List Artifact Task';
|
||||||
try {
|
try {
|
||||||
const artifactName = 'telemetry-filterlists-v1';
|
const artifactName = 'telemetry-filterlists-v1';
|
||||||
const artifact = (await artifactService.getArtifact(
|
const artifact = (await artifactService.getArtifact(
|
||||||
|
@ -36,10 +39,16 @@ export function createTelemetryFilterListArtifactTaskConfig() {
|
||||||
filterList.endpointAlerts = artifact.endpoint_alerts;
|
filterList.endpointAlerts = artifact.endpoint_alerts;
|
||||||
filterList.exceptionLists = artifact.exception_lists;
|
filterList.exceptionLists = artifact.exception_lists;
|
||||||
filterList.prebuiltRulesAlerts = artifact.prebuilt_rules_alerts;
|
filterList.prebuiltRulesAlerts = artifact.prebuilt_rules_alerts;
|
||||||
|
await sender.sendOnDemand(TASK_METRICS_CHANNEL, [
|
||||||
|
createTaskMetric(taskName, true, startTime),
|
||||||
|
]);
|
||||||
return 0;
|
return 0;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
tlog(logger, `Failed to set telemetry filterlist artifact due to ${err.message}`);
|
tlog(logger, `Failed to set telemetry filterlist artifact due to ${err.message}`);
|
||||||
filterList.resetAllToDefault();
|
filterList.resetAllToDefault();
|
||||||
|
await sender.sendOnDemand(TASK_METRICS_CHANNEL, [
|
||||||
|
createTaskMetric(taskName, false, startTime, err.message),
|
||||||
|
]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue