[TSDB][Discover] Exclude counter fields from Breakdown options (#155532)

Closes https://github.com/elastic/kibana/issues/155143

## Summary

This PR excludes time series counter fields (like `bytes_counter`) from
"Break down by" options in the histogram.
This commit is contained in:
Julia Rechkunova 2023-04-22 07:34:33 +02:00 committed by GitHub
parent a108b8c9c6
commit 1bbaa5a62f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -31,5 +31,20 @@ describe('fieldSupportsBreakdown', () => {
expect(
fieldSupportsBreakdown({ aggregatable: true, scripted: false, type: 'string' } as any)
).toBe(true);
expect(
fieldSupportsBreakdown({ aggregatable: true, scripted: false, type: 'number' } as any)
).toBe(true);
});
it('should return false if field is aggregatable but it is a time series counter metric', () => {
expect(
fieldSupportsBreakdown({
aggregatable: true,
scripted: false,
type: 'number',
timeSeriesMetric: 'counter',
} as any)
).toBe(false);
});
});

View file

@ -11,4 +11,7 @@ import { DataViewField } from '@kbn/data-views-plugin/public';
const supportedTypes = new Set(['string', 'boolean', 'number', 'ip']);
export const fieldSupportsBreakdown = (field: DataViewField) =>
supportedTypes.has(field.type) && field.aggregatable && !field.scripted;
supportedTypes.has(field.type) &&
field.aggregatable &&
!field.scripted &&
field.timeSeriesMetric !== 'counter';