mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added ES histogram setting to drop/ignore the first and last datapoints
This commit is contained in:
parent
38f4cfb7a2
commit
bf41eb824d
@ -96,6 +96,9 @@ function (angular, _, queryDef) {
|
||||
$scope.agg.field = $scope.target.timeField;
|
||||
settingsLinkText = 'Interval: ' + settings.interval;
|
||||
settingsLinkText += ', Min Doc Count: ' + settings.min_doc_count;
|
||||
if (settings.dropFirstLast) {
|
||||
settingsLinkText += ', Drop first & last value';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,9 @@ function (_, queryDef) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
ElasticResponse.prototype.processMetrics = function(esAgg, target, seriesList, props) {
|
||||
ElasticResponse.prototype.processMetrics = function(esAgg, target, seriesList, props, dropFirstLast) {
|
||||
var metric, y, i, newSeries, bucket, value;
|
||||
dropFirstLast = dropFirstLast ? 1 : 0;
|
||||
|
||||
for (y = 0; y < target.metrics.length; y++) {
|
||||
metric = target.metrics[y];
|
||||
@ -22,7 +23,7 @@ function (_, queryDef) {
|
||||
switch(metric.type) {
|
||||
case 'count': {
|
||||
newSeries = { datapoints: [], metric: 'count', props: props};
|
||||
for (i = 0; i < esAgg.buckets.length; i++) {
|
||||
for (i = dropFirstLast; i < esAgg.buckets.length - dropFirstLast; i++) {
|
||||
bucket = esAgg.buckets[i];
|
||||
value = bucket.doc_count;
|
||||
newSeries.datapoints.push([value, bucket.key]);
|
||||
@ -31,17 +32,17 @@ function (_, queryDef) {
|
||||
break;
|
||||
}
|
||||
case 'percentiles': {
|
||||
if (esAgg.buckets.length === 0) {
|
||||
if (esAgg.buckets.length - dropFirstLast * 2 <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
var firstBucket = esAgg.buckets[0];
|
||||
var firstBucket = esAgg.buckets[dropFirstLast];
|
||||
var percentiles = firstBucket[metric.id].values;
|
||||
|
||||
for (var percentileName in percentiles) {
|
||||
newSeries = {datapoints: [], metric: 'p' + percentileName, props: props, field: metric.field};
|
||||
|
||||
for (i = 0; i < esAgg.buckets.length; i++) {
|
||||
for (i = dropFirstLast; i < esAgg.buckets.length - dropFirstLast; i++) {
|
||||
bucket = esAgg.buckets[i];
|
||||
var values = bucket[metric.id].values;
|
||||
newSeries.datapoints.push([values[percentileName], bucket.key]);
|
||||
@ -59,7 +60,7 @@ function (_, queryDef) {
|
||||
|
||||
newSeries = {datapoints: [], metric: statName, props: props, field: metric.field};
|
||||
|
||||
for (i = 0; i < esAgg.buckets.length; i++) {
|
||||
for (i = dropFirstLast; i < esAgg.buckets.length - dropFirstLast; i++) {
|
||||
bucket = esAgg.buckets[i];
|
||||
var stats = bucket[metric.id];
|
||||
|
||||
@ -77,7 +78,7 @@ function (_, queryDef) {
|
||||
}
|
||||
default: {
|
||||
newSeries = { datapoints: [], metric: metric.type, field: metric.field, props: props};
|
||||
for (i = 0; i < esAgg.buckets.length; i++) {
|
||||
for (i = dropFirstLast; i < esAgg.buckets.length - dropFirstLast; i++) {
|
||||
bucket = esAgg.buckets[i];
|
||||
|
||||
value = bucket[metric.id];
|
||||
@ -158,7 +159,7 @@ function (_, queryDef) {
|
||||
|
||||
if (depth === maxDepth) {
|
||||
if (aggDef.type === 'date_histogram') {
|
||||
this.processMetrics(esAgg, target, seriesList, props);
|
||||
this.processMetrics(esAgg, target, seriesList, props, aggDef.settings && aggDef.settings.dropFirstLast);
|
||||
} else {
|
||||
this.processAggregationDocs(esAgg, aggDef, target, docs, props);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
<div class="tight-form-inner-box" ng-if="agg.type === 'date_histogram'">
|
||||
<div class="tight-form">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item" style="width: 94px">
|
||||
<li class="tight-form-item" style="width: 140px">
|
||||
Interval
|
||||
</li>
|
||||
<li>
|
||||
@ -46,13 +46,29 @@
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="tight-form last">
|
||||
<div class="tight-form">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item" style="width: 94px">
|
||||
<li class="tight-form-item" style="width: 140px">
|
||||
Min Doc Count
|
||||
</li>
|
||||
<li>
|
||||
<input type="number" class="tight-form-input" ng-model="agg.settings.min_doc_count" ng-blur="onChangeInternal()"></input>
|
||||
<input type="number" class="tight-form-input" ng-model="agg.settings.min_doc_count" ng-blur="onChangeInternal()">
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="tight-form last">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item" style="width: 140px">
|
||||
Drop first & last value
|
||||
</li>
|
||||
<li class="tight-form-item">
|
||||
<input class="cr1" type="checkbox" id="agg[{{agg.id}}].settings.dropFirstLast"
|
||||
ng-model="agg.settings.dropFirstLast" ng-checked="agg.settings.dropFirstLast" ng-change="onChangeInternal()">
|
||||
<label for="agg[{{agg.id}}].settings.dropFirstLast" class="cr1"></label>
|
||||
</li>
|
||||
<li class="tight-form-item last">
|
||||
<i class="fa fa-question-circle" bs-tooltip="'Ignore the first and last values of the dataset'" data-placement="right"></i>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
|
Loading…
Reference in New Issue
Block a user