mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[TSVB] Fix bucket paths to work with ES 6.0 and later (#15322)
* Fix bucket paths (and pretty up the file some) * Fixing tests
This commit is contained in:
parent
2ba3cf45d2
commit
95755ef794
2 changed files with 21 additions and 18 deletions
|
@ -27,9 +27,11 @@ function extendStats(bucket) {
|
|||
}
|
||||
|
||||
function extendStatsBucket(bucket, metrics) {
|
||||
const bucketsPath = 'timeseries > ' + getBucketsPath(bucket.field, metrics);
|
||||
const bucketsPath = 'timeseries>' + getBucketsPath(bucket.field, metrics);
|
||||
const body = { extended_stats_bucket: { buckets_path: bucketsPath } };
|
||||
if (bucket.sigma) body.extended_stats_bucket.sigma = parseInt(bucket.sigma, 10);
|
||||
if (bucket.sigma) {
|
||||
body.extended_stats_bucket.sigma = parseInt(bucket.sigma, 10);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
|
@ -46,7 +48,7 @@ export default {
|
|||
}
|
||||
};
|
||||
},
|
||||
static: (bucket) => {
|
||||
static: bucket => {
|
||||
checkMetric(bucket, ['value']);
|
||||
return {
|
||||
bucket_script: {
|
||||
|
@ -88,13 +90,15 @@ export default {
|
|||
std_deviation_bucket: extendStatsBucket,
|
||||
variance_bucket: extendStatsBucket,
|
||||
|
||||
percentile: (bucket) => {
|
||||
percentile: bucket => {
|
||||
checkMetric(bucket, ['type', 'field', 'percentiles']);
|
||||
let percents = bucket.percentiles.filter(p => p.value != null).map(p => p.value);
|
||||
let percents = bucket.percentiles
|
||||
.filter(p => p.value != null)
|
||||
.map(p => p.value);
|
||||
if (bucket.percentiles.some(p => p.mode === 'band')) {
|
||||
percents = percents.concat(bucket.percentiles
|
||||
.filter(p => p.percentile)
|
||||
.map(p => p.percentile));
|
||||
percents = percents.concat(
|
||||
bucket.percentiles.filter(p => p.percentile).map(p => p.percentile)
|
||||
);
|
||||
}
|
||||
const agg = {
|
||||
percentiles: {
|
||||
|
@ -115,7 +119,11 @@ export default {
|
|||
}
|
||||
};
|
||||
if (bucket.gap_policy) body.derivative.gap_policy = bucket.gap_policy;
|
||||
if (bucket.unit) body.derivative.unit = /^([\d]+)([shmdwMy]|ms)$/.test(bucket.unit) ? bucket.unit : bucketSize;
|
||||
if (bucket.unit) {
|
||||
body.derivative.unit = /^([\d]+)([shmdwMy]|ms)$/.test(bucket.unit)
|
||||
? bucket.unit
|
||||
: bucketSize;
|
||||
}
|
||||
return body;
|
||||
},
|
||||
|
||||
|
@ -129,7 +137,9 @@ export default {
|
|||
}
|
||||
};
|
||||
if (bucket.gap_policy) body.serial_diff.gap_policy = bucket.gap_policy;
|
||||
if (bucket.lag) body.serial_diff.lag = /^([\d]+)$/.test(bucket.lag) ? bucket.lag : 0;
|
||||
if (bucket.lag) {
|
||||
body.serial_diff.lag = /^([\d]+)$/.test(bucket.lag) ? bucket.lag : 0;
|
||||
}
|
||||
return body;
|
||||
},
|
||||
|
||||
|
@ -193,7 +203,4 @@ export default {
|
|||
};
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { expect } from 'chai';
|
|||
import sinon from 'sinon';
|
||||
|
||||
describe('siblingBuckets(req, panel, series)', () => {
|
||||
|
||||
let panel;
|
||||
let series;
|
||||
let req;
|
||||
|
@ -54,15 +53,12 @@ describe('siblingBuckets(req, panel, series)', () => {
|
|||
aggs: {
|
||||
'metric-2': {
|
||||
extended_stats_bucket: {
|
||||
buckets_path: 'timeseries > metric-1'
|
||||
buckets_path: 'timeseries>metric-1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue