Skip to content

Commit

Permalink
Collect agent telemetry even when fleet server is disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
skh committed Mar 2, 2021
1 parent c116477 commit 8c9c0a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion x-pack/plugins/fleet/server/collectors/agent_collectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { ElasticsearchClient, SavedObjectsClient } from 'kibana/server';
import { FleetConfigType } from '../../common/types';
import * as AgentService from '../services/agents';
import { isFleetServerSetup } from '../services/fleet_server';

Expand All @@ -17,11 +18,13 @@ export interface AgentUsage {
}

export const getAgentUsage = async (
config: FleetConfigType,
soClient?: SavedObjectsClient,
esClient?: ElasticsearchClient
): Promise<AgentUsage> => {
// TODO: unsure if this case is possible at all.
if (!soClient || !esClient || !(await isFleetServerSetup())) {
const fleetServerMissing = config.agents.fleetServerEnabled && !(await isFleetServerSetup());
if (!soClient || !esClient || fleetServerMissing) {
return {
total: 0,
online: 0,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/server/collectors/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function registerFleetUsageCollector(
const [soClient, esClient] = await getInternalClients(core);
return {
agents_enabled: getIsAgentsEnabled(config),
agents: await getAgentUsage(soClient, esClient),
agents: await getAgentUsage(config, soClient, esClient),
packages: await getPackageUsage(soClient),
};
},
Expand Down

0 comments on commit 8c9c0a3

Please sign in to comment.