mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Fleet] Fix agent status updating count, and mitigate performance issue (#88019)
This commit is contained in:
parent
66129efc15
commit
28d61bf5fa
5 changed files with 29 additions and 22 deletions
|
@ -49,7 +49,7 @@ export function buildKueryForUnenrollingAgents() {
|
|||
}
|
||||
|
||||
export function buildKueryForOnlineAgents() {
|
||||
return `not (${buildKueryForOfflineAgents()}) AND not (${buildKueryForErrorAgents()}) AND not (${buildKueryForEnrollingAgents()}) AND not (${buildKueryForUnenrollingAgents()})`;
|
||||
return `not (${buildKueryForOfflineAgents()}) AND not (${buildKueryForErrorAgents()}) AND not (${buildKueryForUpdatingAgents()})`;
|
||||
}
|
||||
|
||||
export function buildKueryForErrorAgents() {
|
||||
|
@ -59,11 +59,11 @@ export function buildKueryForErrorAgents() {
|
|||
export function buildKueryForOfflineAgents() {
|
||||
return `${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
|
||||
(4 * AGENT_POLLING_THRESHOLD_MS) / 1000
|
||||
}s AND not (${buildKueryForErrorAgents()})`;
|
||||
}s AND not (${buildKueryForErrorAgents()}) AND not ( ${buildKueryForUpdatingAgents()} )`;
|
||||
}
|
||||
|
||||
export function buildKueryForUpgradingAgents() {
|
||||
return `${AGENT_SAVED_OBJECT_TYPE}.upgrade_started_at:*`;
|
||||
return `(${AGENT_SAVED_OBJECT_TYPE}.upgrade_started_at:*) and not (${AGENT_SAVED_OBJECT_TYPE}.upgraded_at:*)`;
|
||||
}
|
||||
|
||||
export function buildKueryForUpdatingAgents() {
|
||||
|
|
|
@ -219,5 +219,6 @@ export interface GetAgentStatusResponse {
|
|||
error: number;
|
||||
offline: number;
|
||||
other: number;
|
||||
updating: number;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import { AgentTableHeader } from './components/table_header';
|
|||
import { SelectionMode } from './components/bulk_actions';
|
||||
import { SearchAndFilterBar } from './components/search_and_filter_bar';
|
||||
|
||||
const REFRESH_INTERVAL_MS = 10000;
|
||||
const REFRESH_INTERVAL_MS = 30000;
|
||||
|
||||
const RowActions = React.memo<{
|
||||
agent: Agent;
|
||||
|
@ -282,7 +282,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
|
|||
healthy: agentsStatusRequest.data.results.online,
|
||||
unhealthy: agentsStatusRequest.data.results.error,
|
||||
offline: agentsStatusRequest.data.results.offline,
|
||||
updating: agentsStatusRequest.data.results.other,
|
||||
updating: agentsStatusRequest.data.results.updating,
|
||||
inactive: agentsRequest.data.totalInactive,
|
||||
});
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import { SavedObjectsClientContract } from 'src/core/server';
|
||||
import pMap from 'p-map';
|
||||
import { getAgent, listAgents } from './crud';
|
||||
import { AGENT_EVENT_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE } from '../../constants';
|
||||
import { AgentStatus } from '../../types';
|
||||
|
@ -21,18 +22,32 @@ export async function getAgentStatusById(
|
|||
|
||||
export const getAgentStatus = AgentStatusKueryHelper.getAgentStatus;
|
||||
|
||||
function joinKuerys(...kuerys: Array<string | undefined>) {
|
||||
return kuerys
|
||||
.filter((kuery) => kuery !== undefined)
|
||||
.reduce((acc, kuery) => {
|
||||
if (acc === '') {
|
||||
return `(${kuery})`;
|
||||
}
|
||||
|
||||
return `${acc} and (${kuery})`;
|
||||
}, '');
|
||||
}
|
||||
|
||||
export async function getAgentStatusForAgentPolicy(
|
||||
soClient: SavedObjectsClientContract,
|
||||
agentPolicyId?: string,
|
||||
filterKuery?: string
|
||||
) {
|
||||
const [all, online, error, offline] = await Promise.all(
|
||||
const [all, online, error, offline, updating] = await pMap(
|
||||
[
|
||||
undefined,
|
||||
AgentStatusKueryHelper.buildKueryForOnlineAgents(),
|
||||
AgentStatusKueryHelper.buildKueryForErrorAgents(),
|
||||
AgentStatusKueryHelper.buildKueryForOfflineAgents(),
|
||||
].map((kuery) =>
|
||||
AgentStatusKueryHelper.buildKueryForUpdatingAgents(),
|
||||
],
|
||||
(kuery) =>
|
||||
listAgents(soClient, {
|
||||
showInactive: false,
|
||||
perPage: 0,
|
||||
|
@ -44,28 +59,19 @@ export async function getAgentStatusForAgentPolicy(
|
|||
agentPolicyId ? `${AGENT_SAVED_OBJECT_TYPE}.policy_id:"${agentPolicyId}"` : undefined,
|
||||
]
|
||||
),
|
||||
})
|
||||
)
|
||||
}),
|
||||
{
|
||||
concurrency: 1,
|
||||
}
|
||||
);
|
||||
|
||||
function joinKuerys(...kuerys: Array<string | undefined>) {
|
||||
return kuerys
|
||||
.filter((kuery) => kuery !== undefined)
|
||||
.reduce((acc, kuery) => {
|
||||
if (acc === '') {
|
||||
return `(${kuery})`;
|
||||
}
|
||||
|
||||
return `${acc} and (${kuery})`;
|
||||
}, '');
|
||||
}
|
||||
|
||||
return {
|
||||
events: await getEventsCount(soClient, agentPolicyId),
|
||||
total: all.total,
|
||||
online: online.total,
|
||||
error: error.total,
|
||||
offline: offline.total,
|
||||
updating: updating.total,
|
||||
other: all.total - online.total - error.total - offline.total,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ export interface PolicyDetailsState {
|
|||
/** current location of the application */
|
||||
location?: Immutable<AppLocation>;
|
||||
/** A summary of stats for the agents associated with a given Fleet Agent Policy */
|
||||
agentStatusSummary?: GetAgentStatusResponse['results'];
|
||||
agentStatusSummary?: Omit<GetAgentStatusResponse['results'], 'updating'>;
|
||||
/** Status of an update to the policy */
|
||||
updateStatus?: {
|
||||
success: boolean;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue