parent
9a4e5cff20
commit
b4833a3c57
|
@ -23,6 +23,15 @@ export const populateSeriesWithTSVBData = (
|
|||
options: MetricsExplorerRequest,
|
||||
framework: InfraBackendFrameworkAdapter
|
||||
) => async (series: MetricsExplorerSeries) => {
|
||||
// IF there are no metrics selected then we should return an empty result.
|
||||
if (options.metrics.length === 0) {
|
||||
return {
|
||||
...series,
|
||||
columns: [],
|
||||
rows: [],
|
||||
};
|
||||
}
|
||||
|
||||
// Set the filter for the group by or match everything
|
||||
const filters = options.groupBy ? [{ match: { [options.groupBy]: series.id } }] : [];
|
||||
const timerange = { min: options.timerange.from, max: options.timerange.to };
|
||||
|
|
|
@ -66,6 +66,33 @@ const metricsExplorerTest: KbnTestProvider = ({ getService }) => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should work for empty metrics', async () => {
|
||||
const postBody = {
|
||||
timerange: {
|
||||
field: '@timestamp',
|
||||
to: max,
|
||||
from: min,
|
||||
interval: '>=1m',
|
||||
},
|
||||
indexPattern: 'metricbeat-*',
|
||||
metrics: [],
|
||||
};
|
||||
const response = await supertest
|
||||
.post('/api/infra/metrics_explorer')
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send(postBody)
|
||||
.expect(200);
|
||||
const body: MetricsExplorerResponse = response.body;
|
||||
expect(body).to.have.property('series');
|
||||
expect(body.series).length(1);
|
||||
const firstSeries = first(body.series);
|
||||
expect(firstSeries).to.have.property('id', 'ALL');
|
||||
expect(firstSeries).to.have.property('columns');
|
||||
expect(firstSeries).to.have.property('rows');
|
||||
expect(firstSeries!.columns).to.eql([]);
|
||||
expect(firstSeries!.rows).to.have.length(0);
|
||||
});
|
||||
|
||||
it('should work with groupBy', async () => {
|
||||
const postBody = {
|
||||
timerange: {
|
||||
|
|
Loading…
Reference in a new issue