[Fleet] Match telemetry key names to UI agent states (#95567)
This commit is contained in:
parent
d2e2209cf2
commit
f7caf44876
|
@ -13,10 +13,11 @@ import * as AgentService from '../services/agents';
|
|||
import { isFleetServerSetup } from '../services/fleet_server';
|
||||
|
||||
export interface AgentUsage {
|
||||
total: number;
|
||||
online: number;
|
||||
error: number;
|
||||
total_enrolled: number;
|
||||
healthy: number;
|
||||
unhealthy: number;
|
||||
offline: number;
|
||||
total_all_statuses: number;
|
||||
}
|
||||
|
||||
export const getAgentUsage = async (
|
||||
|
@ -27,21 +28,26 @@ export const getAgentUsage = async (
|
|||
// TODO: unsure if this case is possible at all.
|
||||
if (!soClient || !esClient || !(await isFleetServerSetup())) {
|
||||
return {
|
||||
total: 0,
|
||||
online: 0,
|
||||
error: 0,
|
||||
total_enrolled: 0,
|
||||
healthy: 0,
|
||||
unhealthy: 0,
|
||||
offline: 0,
|
||||
total_all_statuses: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const { total, online, error, offline } = await AgentService.getAgentStatusForAgentPolicy(
|
||||
soClient,
|
||||
esClient
|
||||
);
|
||||
return {
|
||||
const {
|
||||
total,
|
||||
inactive,
|
||||
online,
|
||||
error,
|
||||
offline,
|
||||
} = await AgentService.getAgentStatusForAgentPolicy(soClient, esClient);
|
||||
return {
|
||||
total_enrolled: total,
|
||||
healthy: online,
|
||||
unhealthy: error,
|
||||
offline,
|
||||
total_all_statuses: total + inactive,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -49,10 +49,36 @@ export function registerFleetUsageCollector(
|
|||
schema: {
|
||||
agents_enabled: { type: 'boolean' },
|
||||
agents: {
|
||||
total: { type: 'long' },
|
||||
online: { type: 'long' },
|
||||
error: { type: 'long' },
|
||||
offline: { type: 'long' },
|
||||
total_enrolled: {
|
||||
type: 'long',
|
||||
_meta: {
|
||||
description: 'The total number of enrolled agents, in any state',
|
||||
},
|
||||
},
|
||||
healthy: {
|
||||
type: 'long',
|
||||
_meta: {
|
||||
description: 'The total number of enrolled agents in a healthy state',
|
||||
},
|
||||
},
|
||||
unhealthy: {
|
||||
type: 'long',
|
||||
_meta: {
|
||||
description: 'The total number of enrolled agents in an unhealthy state',
|
||||
},
|
||||
},
|
||||
offline: {
|
||||
type: 'long',
|
||||
_meta: {
|
||||
description: 'The total number of enrolled agents currently offline',
|
||||
},
|
||||
},
|
||||
total_all_statuses: {
|
||||
type: 'long',
|
||||
_meta: {
|
||||
description: 'The total number of agents in any state, both enrolled and inactive',
|
||||
},
|
||||
},
|
||||
},
|
||||
packages: {
|
||||
type: 'array',
|
||||
|
|
|
@ -55,17 +55,18 @@ export async function getAgentStatusForAgentPolicy(
|
|||
agentPolicyId?: string,
|
||||
filterKuery?: string
|
||||
) {
|
||||
const [all, online, error, offline, updating] = await pMap(
|
||||
const [all, allActive, online, error, offline, updating] = await pMap(
|
||||
[
|
||||
undefined,
|
||||
undefined, // All agents, including inactive
|
||||
undefined, // All active agents
|
||||
AgentStatusKueryHelper.buildKueryForOnlineAgents(),
|
||||
AgentStatusKueryHelper.buildKueryForErrorAgents(),
|
||||
AgentStatusKueryHelper.buildKueryForOfflineAgents(),
|
||||
AgentStatusKueryHelper.buildKueryForUpdatingAgents(),
|
||||
],
|
||||
(kuery) =>
|
||||
(kuery, index) =>
|
||||
getAgentsByKuery(esClient, {
|
||||
showInactive: false,
|
||||
showInactive: index === 0,
|
||||
perPage: 0,
|
||||
page: 1,
|
||||
kuery: joinKuerys(
|
||||
|
@ -84,7 +85,8 @@ export async function getAgentStatusForAgentPolicy(
|
|||
|
||||
return {
|
||||
events: await getEventsCount(soClient, agentPolicyId),
|
||||
total: all.total,
|
||||
total: allActive.total,
|
||||
inactive: all.total - allActive.total,
|
||||
online: online.total,
|
||||
error: error.total,
|
||||
offline: offline.total,
|
||||
|
|
|
@ -1837,17 +1837,35 @@
|
|||
},
|
||||
"agents": {
|
||||
"properties": {
|
||||
"total": {
|
||||
"type": "long"
|
||||
"total_enrolled": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "The total number of enrolled agents, in any state"
|
||||
}
|
||||
},
|
||||
"online": {
|
||||
"type": "long"
|
||||
"healthy": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "The total number of enrolled agents in a healthy state"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"type": "long"
|
||||
"unhealthy": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "The total number of enrolled agents in an unhealthy state"
|
||||
}
|
||||
},
|
||||
"offline": {
|
||||
"type": "long"
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "The total number of enrolled agents currently offline"
|
||||
}
|
||||
},
|
||||
"total_all_statuses": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "The total number of agents in any state, both enrolled and inactive"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1978,6 +1996,42 @@
|
|||
"xy_layer_added": {
|
||||
"type": "long"
|
||||
},
|
||||
"open_field_editor_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to edit a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_editor_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to add a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user edited a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user added a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_delete_modal": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the field delete modal from within Lens."
|
||||
}
|
||||
},
|
||||
"delete_field": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user deleted a field from within Lens."
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_terms": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
|
@ -2034,70 +2088,50 @@
|
|||
},
|
||||
"indexpattern_dimension_operation_range": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the range function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the range function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_median": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the median function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the median function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_percentile": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the percentile function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the percentile function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_last_value": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the last value function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the last value function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_cumulative_sum": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the cumulative sum function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the cumulative sum function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_counter_rate": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the counter rate function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the counter rate function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_derivative": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the derivative function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the derivative function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_moving_average": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the moving average function was selected" }
|
||||
},
|
||||
"open_field_editor_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to edit a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_editor_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to add a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user edited a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user added a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_delete_modal": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the field delete modal from within Lens."
|
||||
}
|
||||
},
|
||||
"delete_field": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user deleted a field from within Lens."
|
||||
"description": "Number of times the moving average function was selected"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2185,6 +2219,42 @@
|
|||
"xy_layer_added": {
|
||||
"type": "long"
|
||||
},
|
||||
"open_field_editor_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to edit a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_editor_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to add a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user edited a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user added a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_delete_modal": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the field delete modal from within Lens."
|
||||
}
|
||||
},
|
||||
"delete_field": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user deleted a field from within Lens."
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_terms": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
|
@ -2241,70 +2311,50 @@
|
|||
},
|
||||
"indexpattern_dimension_operation_range": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the range function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the range function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_median": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the median function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the median function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_percentile": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the percentile function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the percentile function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_last_value": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the last value function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the last value function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_cumulative_sum": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the cumulative sum function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the cumulative sum function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_counter_rate": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the counter rate function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the counter rate function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_derivative": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the derivative function was selected" }
|
||||
"_meta": {
|
||||
"description": "Number of times the derivative function was selected"
|
||||
}
|
||||
},
|
||||
"indexpattern_dimension_operation_moving_average": {
|
||||
"type": "long",
|
||||
"_meta": { "description": "Number of times the moving average function was selected" }
|
||||
},
|
||||
"open_field_editor_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to edit a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_editor_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the editor flyout to add a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_edit": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user edited a field from within Lens."
|
||||
}
|
||||
},
|
||||
"save_field_add": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user added a field from within Lens."
|
||||
}
|
||||
},
|
||||
"open_field_delete_modal": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user opened the field delete modal from within Lens."
|
||||
}
|
||||
},
|
||||
"delete_field": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "Number of times the user deleted a field from within Lens."
|
||||
"description": "Number of times the moving average function was selected"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
offline: 1,
|
||||
updating: 1,
|
||||
other: 1,
|
||||
inactive: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue