Skip to content

Commit ba76476

Browse files
authored
[Ingest Manager] Do not show enrolling and unenrolling agents as online in agent counters (#71921)
1 parent d510263 commit ba76476

File tree

8 files changed

+22
-11
lines changed

8 files changed

+22
-11
lines changed

x-pack/plugins/ingest_manager/common/services/agent_status.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import {
8-
AGENT_POLLING_THRESHOLD_MS,
9-
AGENT_TYPE_PERMANENT,
10-
AGENT_SAVED_OBJECT_TYPE,
11-
} from '../constants';
7+
import { AGENT_POLLING_THRESHOLD_MS, AGENT_SAVED_OBJECT_TYPE } from '../constants';
128
import { Agent, AgentStatus } from '../types';
139

1410
export function getAgentStatus(agent: Agent, now: number = Date.now()): AgentStatus {
@@ -41,16 +37,24 @@ export function getAgentStatus(agent: Agent, now: number = Date.now()): AgentSta
4137
return 'online';
4238
}
4339

40+
export function buildKueryForEnrollingAgents() {
41+
return `not ${AGENT_SAVED_OBJECT_TYPE}.last_checkin:*`;
42+
}
43+
44+
export function buildKueryForUnenrollingAgents() {
45+
return `${AGENT_SAVED_OBJECT_TYPE}.unenrollment_started_at:*`;
46+
}
47+
4448
export function buildKueryForOnlineAgents() {
45-
return `not (${buildKueryForOfflineAgents()}) AND not (${buildKueryForErrorAgents()})`;
49+
return `not (${buildKueryForOfflineAgents()}) AND not (${buildKueryForErrorAgents()}) AND not (${buildKueryForEnrollingAgents()}) AND not (${buildKueryForUnenrollingAgents()})`;
4650
}
4751

4852
export function buildKueryForErrorAgents() {
4953
return `( ${AGENT_SAVED_OBJECT_TYPE}.last_checkin_status:error or ${AGENT_SAVED_OBJECT_TYPE}.last_checkin_status:degraded )`;
5054
}
5155

5256
export function buildKueryForOfflineAgents() {
53-
return `((${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_PERMANENT} AND ${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
57+
return `${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
5458
(4 * AGENT_POLLING_THRESHOLD_MS) / 1000
55-
}s) AND not ( ${buildKueryForErrorAgents()} ))`;
59+
}s AND not (${buildKueryForErrorAgents()})`;
5660
}

x-pack/plugins/ingest_manager/common/types/rest_spec/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,6 @@ export interface GetAgentStatusResponse {
173173
online: number;
174174
error: number;
175175
offline: number;
176+
other: number;
176177
};
177178
}

x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/donut_chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const DonutChart = ({ height, width, data }: DonutChartProps) => {
3131
.ordinal()
3232
// @ts-ignore
3333
.domain(data)
34-
.range(['#017D73', '#98A2B3', '#BD271E']);
34+
.range(['#017D73', '#98A2B3', '#BD271E', '#F5A700']);
3535
const pieGenerator = d3.layout
3636
.pie()
3737
.value(({ value }: any) => value)

x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/list_layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const ListLayout: React.FunctionComponent<{}> = ({ children }) => {
6666
online: agentStatus?.online || 0,
6767
offline: agentStatus?.offline || 0,
6868
error: agentStatus?.error || 0,
69+
other: agentStatus?.other || 0,
6970
}}
7071
/>
7172
</EuiFlexItem>

x-pack/plugins/ingest_manager/server/services/agents/status.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ export async function getAgentStatusForConfig(
2525
soClient: SavedObjectsClientContract,
2626
configId?: string
2727
) {
28-
const [all, error, offline] = await Promise.all(
28+
const [all, online, error, offline] = await Promise.all(
2929
[
3030
undefined,
31+
AgentStatusKueryHelper.buildKueryForOnlineAgents(),
3132
AgentStatusKueryHelper.buildKueryForErrorAgents(),
3233
AgentStatusKueryHelper.buildKueryForOfflineAgents(),
3334
].map((kuery) =>
@@ -47,9 +48,10 @@ export async function getAgentStatusForConfig(
4748
return {
4849
events: await getEventsCount(soClient, configId),
4950
total: all.total,
50-
online: all.total - error.total - offline.total,
51+
online: online.total,
5152
error: error.total,
5253
offline: offline.total,
54+
other: all.total - online.total - error.total - offline.total,
5355
};
5456
}
5557

x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/reducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const initialPolicyDetailsState: () => Immutable<PolicyDetailsState> = ()
2121
offline: 0,
2222
online: 0,
2323
total: 0,
24+
other: 0,
2425
},
2526
});
2627

x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe('policy list store concerns', () => {
152152
offline: 0,
153153
online: 0,
154154
total: 0,
155+
other: 0,
155156
},
156157
});
157158
});

x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/reducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const initialPolicyListState: () => Immutable<PolicyListState> = () => ({
3131
offline: 0,
3232
online: 0,
3333
total: 0,
34+
other: 0,
3435
},
3536
});
3637

0 commit comments

Comments
 (0)