Collect agent telemetry even when fleet server is disabled. (#93198)

This commit is contained in:
Sonja Krause-Harder 2021-03-02 15:09:36 +01:00 committed by GitHub
parent 547600b9b1
commit ca25e5162c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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';
@ -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,

View file

@ -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),
};
},