Skip to content

Commit

Permalink
[Fleet] Rename usage collection object to 'fleet'. (#83407)
Browse files Browse the repository at this point in the history
* Rename usage collection object to 'fleet'.

* Update telemetry mapping.

* Adjust naming.

* Rename ingestManager -> fleet in telemetry collector
  • Loading branch information
skh authored Nov 24, 2020
1 parent 0bd9201 commit aa07f5c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

import { FleetConfigType } from '..';

export const getIsFleetEnabled = (config: FleetConfigType) => {
export const getIsAgentsEnabled = (config: FleetConfigType) => {
return config.agents.enabled;
};
16 changes: 8 additions & 8 deletions x-pack/plugins/fleet/server/collectors/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,19 +30,19 @@ export function registerIngestManagerUsageCollector(
}

// create usage collector
const ingestManagerCollector = usageCollection.makeUsageCollector<Usage>({
type: 'ingest_manager',
const fleetCollector = usageCollection.makeUsageCollector<Usage>({
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' },
Expand All @@ -61,5 +61,5 @@ export function registerIngestManagerUsageCollector(
});

// register usage collector
usageCollection.registerCollector(ingestManagerCollector);
usageCollection.registerCollector(fleetCollector);
}
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1778,9 +1778,9 @@
}
}
},
"ingest_manager": {
"fleet": {
"properties": {
"fleet_enabled": {
"agents_enabled": {
"type": "boolean"
},
"agents": {
Expand Down

0 comments on commit aa07f5c

Please sign in to comment.