From aa07f5c1d0868a7103e0dd5730776b205b6a868a Mon Sep 17 00:00:00 2001 From: Sonja Krause-Harder Date: Tue, 24 Nov 2020 10:11:58 +0100 Subject: [PATCH] [Fleet] Rename usage collection object to 'fleet'. (#83407) * Rename usage collection object to 'fleet'. * Update telemetry mapping. * Adjust naming. * Rename ingestManager -> fleet in telemetry collector --- .../fleet/server/collectors/config_collectors.ts | 2 +- .../plugins/fleet/server/collectors/register.ts | 16 ++++++++-------- x-pack/plugins/fleet/server/plugin.ts | 4 ++-- .../schema/xpack_plugins.json | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/fleet/server/collectors/config_collectors.ts b/x-pack/plugins/fleet/server/collectors/config_collectors.ts index 8fb4924a2ccf0..f26e4261d573e 100644 --- a/x-pack/plugins/fleet/server/collectors/config_collectors.ts +++ b/x-pack/plugins/fleet/server/collectors/config_collectors.ts @@ -6,6 +6,6 @@ import { FleetConfigType } from '..'; -export const getIsFleetEnabled = (config: FleetConfigType) => { +export const getIsAgentsEnabled = (config: FleetConfigType) => { return config.agents.enabled; }; diff --git a/x-pack/plugins/fleet/server/collectors/register.ts b/x-pack/plugins/fleet/server/collectors/register.ts index e7d95a7e83773..35517e6a7a700 100644 --- a/x-pack/plugins/fleet/server/collectors/register.ts +++ b/x-pack/plugins/fleet/server/collectors/register.ts @@ -6,19 +6,19 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { CoreSetup } from 'kibana/server'; -import { getIsFleetEnabled } from './config_collectors'; +import { getIsAgentsEnabled } from './config_collectors'; import { AgentUsage, getAgentUsage } from './agent_collectors'; import { getInternalSavedObjectsClient } from './helpers'; import { PackageUsage, getPackageUsage } from './package_collectors'; import { FleetConfigType } from '..'; interface Usage { - fleet_enabled: boolean; + agents_enabled: boolean; agents: AgentUsage; packages: PackageUsage[]; } -export function registerIngestManagerUsageCollector( +export function registerFleetUsageCollector( core: CoreSetup, config: FleetConfigType, usageCollection: UsageCollectionSetup | undefined @@ -30,19 +30,19 @@ export function registerIngestManagerUsageCollector( } // create usage collector - const ingestManagerCollector = usageCollection.makeUsageCollector({ - type: 'ingest_manager', + const fleetCollector = usageCollection.makeUsageCollector({ + type: 'fleet', isReady: () => true, fetch: async () => { const soClient = await getInternalSavedObjectsClient(core); return { - fleet_enabled: getIsFleetEnabled(config), + agents_enabled: getIsAgentsEnabled(config), agents: await getAgentUsage(soClient), packages: await getPackageUsage(soClient), }; }, schema: { - fleet_enabled: { type: 'boolean' }, + agents_enabled: { type: 'boolean' }, agents: { total: { type: 'long' }, online: { type: 'long' }, @@ -61,5 +61,5 @@ export function registerIngestManagerUsageCollector( }); // register usage collector - usageCollection.registerCollector(ingestManagerCollector); + usageCollection.registerCollector(fleetCollector); } diff --git a/x-pack/plugins/fleet/server/plugin.ts b/x-pack/plugins/fleet/server/plugin.ts index 90fb34efd4817..716939c28bf1e 100644 --- a/x-pack/plugins/fleet/server/plugin.ts +++ b/x-pack/plugins/fleet/server/plugin.ts @@ -71,7 +71,7 @@ import { } from './services/agents'; import { CloudSetup } from '../../cloud/server'; import { agentCheckinState } from './services/agents/checkin/state'; -import { registerIngestManagerUsageCollector } from './collectors/register'; +import { registerFleetUsageCollector } from './collectors/register'; import { getInstallation } from './services/epm/packages'; export interface FleetSetupDeps { @@ -216,7 +216,7 @@ export class FleetPlugin const config = await this.config$.pipe(first()).toPromise(); // Register usage collection - registerIngestManagerUsageCollector(core, config, deps.usageCollection); + registerFleetUsageCollector(core, config, deps.usageCollection); // Always register app routes for permissions checking registerAppRoutes(router); diff --git a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json index 8936cdafa3827..e1b5f4cb9c3ae 100644 --- a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json +++ b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @@ -1778,9 +1778,9 @@ } } }, - "ingest_manager": { + "fleet": { "properties": { - "fleet_enabled": { + "agents_enabled": { "type": "boolean" }, "agents": {