From e6965bb339858d100b96551f443a3a81b543e68e Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Tue, 13 Apr 2021 19:54:11 -0400 Subject: [PATCH] Telemetry for preconfigured alert history config enabled --- x-pack/plugins/actions/server/plugin.ts | 1 + .../actions/server/usage/actions_usage_collector.ts | 8 +++++++- x-pack/plugins/actions/server/usage/types.ts | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/actions/server/plugin.ts b/x-pack/plugins/actions/server/plugin.ts index 3c754d90c4af5..1d941617789b7 100644 --- a/x-pack/plugins/actions/server/plugin.ts +++ b/x-pack/plugins/actions/server/plugin.ts @@ -224,6 +224,7 @@ export class ActionsPlugin implements Plugin taskManager) ); } diff --git a/x-pack/plugins/actions/server/usage/actions_usage_collector.ts b/x-pack/plugins/actions/server/usage/actions_usage_collector.ts index baa82a880ecaf..0164c6b195f50 100644 --- a/x-pack/plugins/actions/server/usage/actions_usage_collector.ts +++ b/x-pack/plugins/actions/server/usage/actions_usage_collector.ts @@ -9,6 +9,7 @@ import { MakeSchemaFrom, UsageCollectionSetup } from 'src/plugins/usage_collecti import { get } from 'lodash'; import { TaskManagerStartContract } from '../../../task_manager/server'; import { ActionsUsage } from './types'; +import { ActionsConfig } from '../config'; const byTypeSchema: MakeSchemaFrom['count_by_type'] = { // TODO: Find out an automated way to populate the keys or reformat these into an array (and change the Remote Telemetry indexer accordingly) @@ -28,6 +29,7 @@ const byTypeSchema: MakeSchemaFrom['count_by_type'] = { export function createActionsUsageCollector( usageCollection: UsageCollectionSetup, + config: ActionsConfig, taskManager: Promise ) { return usageCollection.makeUsageCollector({ @@ -37,6 +39,7 @@ export function createActionsUsageCollector( return true; }, schema: { + alert_history_connector_enabled: { type: 'boolean' }, count_total: { type: 'long' }, count_active_total: { type: 'long' }, count_active_alert_history_connectors: { type: 'long' }, @@ -51,9 +54,11 @@ export function createActionsUsageCollector( return { ...state, + alert_history_connector_enabled: config.preconfiguredAlertHistoryEsIndex, }; } catch (err) { return { + alert_history_connector_enabled: false, count_total: 0, count_active_total: 0, count_active_alert_history_connectors: 0, @@ -86,8 +91,9 @@ async function getLatestTaskState(taskManager: TaskManagerStartContract) { export function registerActionsUsageCollector( usageCollection: UsageCollectionSetup, + config: ActionsConfig, taskManager: Promise ) { - const collector = createActionsUsageCollector(usageCollection, taskManager); + const collector = createActionsUsageCollector(usageCollection, config, taskManager); usageCollection.registerCollector(collector); } diff --git a/x-pack/plugins/actions/server/usage/types.ts b/x-pack/plugins/actions/server/usage/types.ts index 73d93a75c399c..9221ba8ea5688 100644 --- a/x-pack/plugins/actions/server/usage/types.ts +++ b/x-pack/plugins/actions/server/usage/types.ts @@ -6,6 +6,7 @@ */ export interface ActionsUsage { + alert_history_connector_enabled: boolean; count_total: number; count_active_total: number; count_active_alert_history_connectors: number;