Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { isBoom } from '@hapi/boom';
import type { SavedObjectsClient, ElasticsearchClient } from 'kibana/server';

import { packagePolicyService, settingsService } from '../services';
Expand Down Expand Up @@ -38,11 +40,18 @@ export const getFleetServerUsage = async (
return DEFAULT_USAGE;
}

const numHostsUrls =
(await settingsService.getSettings(soClient)).fleet_server_hosts?.length ?? 0;
const numHostsUrls = await settingsService
.getSettings(soClient)
.then((settings) => settings.fleet_server_hosts?.length ?? 0)
.catch((err) => {
if (isBoom(error) && error.output.statusCode === 404) {
return 0;
}

// Find all policies with Fleet server than query agent status
throw err;
});

// Find all policies with Fleet server than query agent status
let hasMore = true;
const policyIds = new Set<string>();
let page = 1;
Expand Down