Skip to content

Commit

Permalink
[Fleet] Correctly check for degraded status in agent healthbar (#102821)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Jun 22, 2021
1 parent 138bd0d commit d792e02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/services/agent_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function buildKueryForOnlineAgents() {
}

export function buildKueryForErrorAgents() {
return 'last_checkin_status:error or .last_checkin_status:degraded';
return 'last_checkin_status:error or last_checkin_status:degraded';
}

export function buildKueryForOfflineAgents() {
Expand Down
16 changes: 10 additions & 6 deletions x-pack/test/fleet_api_integration/apis/fleet_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ export default function (providerContext: FtrProviderContext) {
let data: any = {};

switch (status) {
case 'unhealthy':
case 'error':
data = { last_checkin_status: 'error' };
break;
case 'degraded':
data = { last_checkin_status: 'degraded' };
break;
case 'offline':
data = { last_checkin: '2017-06-07T18:59:04.498Z' };
break;
Expand Down Expand Up @@ -85,12 +88,13 @@ export default function (providerContext: FtrProviderContext) {
// Default Fleet Server
await generateAgent('healthy', defaultFleetServerPolicy.id);
await generateAgent('healthy', defaultFleetServerPolicy.id);
await generateAgent('unhealthy', defaultFleetServerPolicy.id);
await generateAgent('error', defaultFleetServerPolicy.id);

// Default policy
await generateAgent('healthy', defaultServerPolicy.id);
await generateAgent('offline', defaultServerPolicy.id);
await generateAgent('unhealthy', defaultServerPolicy.id);
await generateAgent('error', defaultServerPolicy.id);
await generateAgent('degraded', defaultServerPolicy.id);
});

it('should return the correct telemetry values for fleet', async () => {
Expand All @@ -105,12 +109,12 @@ export default function (providerContext: FtrProviderContext) {
.expect(200);

expect(apiResponse.stack_stats.kibana.plugins.fleet.agents).eql({
total_enrolled: 6,
total_enrolled: 7,
healthy: 3,
unhealthy: 2,
unhealthy: 3,
offline: 1,
updating: 0,
total_all_statuses: 6,
total_all_statuses: 7,
});

expect(apiResponse.stack_stats.kibana.plugins.fleet.fleet_server).eql({
Expand Down

0 comments on commit d792e02

Please sign in to comment.