Skip to content

Commit

Permalink
[Fleet] agent_status total deprecated, added all and active (#151564)
Browse files Browse the repository at this point in the history
## Summary

Fixes #135980

Marked `total` deprecated in `/agent_status` API response, instead added
`all` (all agents) and `active` (all - inactive - unenrolled).

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
juliaElastic authored Feb 22, 2023
1 parent 355f77b commit 9ddb989
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
13 changes: 11 additions & 2 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -1308,10 +1308,17 @@
"type": "integer"
},
"total": {
"type": "integer"
"type": "integer",
"deprecated": true
},
"updating": {
"type": "integer"
},
"all": {
"type": "integer"
},
"active": {
"type": "integer"
}
},
"required": [
Expand All @@ -1322,7 +1329,9 @@
"online",
"other",
"total",
"updating"
"updating",
"all",
"active"
]
}
}
Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,13 @@ paths:
type: integer
total:
type: integer
deprecated: true
updating:
type: integer
all:
type: integer
active:
type: integer
required:
- error
- events
Expand All @@ -835,6 +840,8 @@ paths:
- other
- total
- updating
- all
- active
operationId: get-agent-status
parameters:
- schema:
Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/fleet/common/openapi/paths/agent_status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ get:
type: integer
total:
type: integer
deprecated: true
updating:
type: integer
all:
type: integer
active:
type: integer
required:
- error
- events
Expand All @@ -36,6 +41,8 @@ get:
- other
- total
- updating
- all
- active
operationId: get-agent-status
parameters:
- schema:
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/fleet/common/types/rest_spec/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export interface GetAgentStatusRequest {
export interface GetAgentStatusResponse {
results: {
events: number;
// deprecated
total: number;
online: number;
error: number;
Expand All @@ -193,6 +194,8 @@ export interface GetAgentStatusResponse {
updating: number;
inactive: number;
unenrolled: number;
all: number;
active: number;
};
}

Expand Down
10 changes: 6 additions & 4 deletions x-pack/plugins/fleet/server/services/agents/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,18 @@ export async function getAgentStatusForAgentPolicy(

const { healthy: online, unhealthy: error, ...otherStatuses } = agentStatusesToSummary(statuses);
const combinedStatuses = { online, error, ...otherStatuses };
const allStatuses = Object.values(statuses).reduce((acc, val) => acc + val, 0);
const allActive = allStatuses - combinedStatuses.unenrolled - combinedStatuses.inactive;
return {
...combinedStatuses,
/* @deprecated no agents will have other status */
other: 0,
/* @deprecated Agent events do not exists anymore */
events: 0,
total:
Object.values(statuses).reduce((acc, val) => acc + val, 0) -
combinedStatuses.unenrolled -
combinedStatuses.inactive,
/* @deprecated use active instead */
total: allActive,
all: allStatuses,
active: allActive,
};
}
export async function getIncomingDataByAgentsId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const initialPolicyDetailsState: () => Immutable<PolicyDetailsState> = ()
online: 0,
total: 0,
other: 0,
all: 0,
active: 0,
},
artifacts: {
location: {
Expand Down
4 changes: 4 additions & 0 deletions x-pack/test/fleet_api_integration/apis/agents/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ export default function ({ getService }: FtrProviderContext) {
other: 0,
total: 8,
online: 2,
active: 8,
all: 11,
error: 2,
offline: 1,
updating: 3,
Expand Down Expand Up @@ -298,6 +300,8 @@ export default function ({ getService }: FtrProviderContext) {
other: 0,
total: 10,
online: 3,
active: 10,
all: 11,
error: 2,
offline: 1,
updating: 4,
Expand Down

0 comments on commit 9ddb989

Please sign in to comment.