mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Use new date_histogram intervals in timelion (#77160)
This commit is contained in:
parent
8ad47846ca
commit
100afab308
2 changed files with 13 additions and 3 deletions
|
@ -100,9 +100,17 @@ describe('es', () => {
|
|||
expect(agg.time_buckets.date_histogram.time_zone).to.equal('Etc/UTC');
|
||||
});
|
||||
|
||||
it('sets the field and interval', () => {
|
||||
it('sets the field', () => {
|
||||
expect(agg.time_buckets.date_histogram.field).to.equal('@timestamp');
|
||||
expect(agg.time_buckets.date_histogram.interval).to.equal('1y');
|
||||
});
|
||||
|
||||
it('sets the interval for calendar_interval correctly', () => {
|
||||
expect(agg.time_buckets.date_histogram).to.have.property('calendar_interval', '1y');
|
||||
});
|
||||
|
||||
it('sets the interval for fixed_interval correctly', () => {
|
||||
const a = createDateAgg({ timefield: '@timestamp', interval: '24h' }, tlConfig);
|
||||
expect(a.time_buckets.date_histogram).to.have.property('fixed_interval', '24h');
|
||||
});
|
||||
|
||||
it('sets min_doc_count to 0', () => {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import { buildAggBody } from './agg_body';
|
||||
import { search } from '../../../../../../plugins/data/server';
|
||||
const { dateHistogramInterval } = search.aggs;
|
||||
|
||||
export default function createDateAgg(config, tlConfig, scriptedFields) {
|
||||
const dateAgg = {
|
||||
|
@ -26,13 +28,13 @@ export default function createDateAgg(config, tlConfig, scriptedFields) {
|
|||
meta: { type: 'time_buckets' },
|
||||
date_histogram: {
|
||||
field: config.timefield,
|
||||
interval: config.interval,
|
||||
time_zone: tlConfig.time.timezone,
|
||||
extended_bounds: {
|
||||
min: tlConfig.time.from,
|
||||
max: tlConfig.time.to,
|
||||
},
|
||||
min_doc_count: 0,
|
||||
...dateHistogramInterval(config.interval),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue