Skip to content

Commit

Permalink
[7.10] [APM] Hide service if only data is from ML (#80145) (#81128)
Browse files Browse the repository at this point in the history
Closes #79998.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
dgieselaar and kibanamachine authored Oct 20, 2020
1 parent ac7b6c0 commit 858eb60
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,27 @@ export async function getServicesItems({
}),
]);

const allMetrics = [
...transactionDurationAverages,
...agentNames,
...transactionRates,
...transactionErrorRates,
...environments,
...healthStatuses,
];
const apmServiceMetrics = joinByKey(
[
...transactionDurationAverages,
...agentNames,
...transactionRates,
...transactionErrorRates,
...environments,
],
'serviceName'
);

const apmServices = apmServiceMetrics.map(({ serviceName }) => serviceName);

// make sure to exclude health statuses from services
// that are not found in APM data

const matchedHealthStatuses = healthStatuses.filter(({ serviceName }) =>
apmServices.includes(serviceName)
);

const allMetrics = [...apmServiceMetrics, ...matchedHealthStatuses];

return joinByKey(allMetrics, 'serviceName');
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ export default function ApiTest({ getService }: FtrProviderContext) {
expect(definedHealthStatuses.length).to.be(0);
});
});

describe('and fetching a list of services with a filter', () => {
let response: PromiseReturnType<typeof supertest.get>;
before(async () => {
response = await supertest.get(
`/api/apm/services?start=${start}&end=${end}&uiFilters=${encodeURIComponent(
`{"kuery":"service.name:opbeans-java","environment":"ENVIRONMENT_ALL"}`
)}`
);
});

it('does not return health statuses for services that are not found in APM data', () => {
expect(response.status).to.be(200);

expect(response.body.items.length).to.be(1);

expect(response.body.items[0].serviceName).to.be('opbeans-java');
});
});
});
});
}

0 comments on commit 858eb60

Please sign in to comment.