Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Hide service if only data is from ML #80145

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Member

@sorenlouv sorenlouv Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this change the list would include other services than "opbeans-java" even though a kuery filter is given?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because the kuery filter is not applied to the ML job.

});
});
});
});
}