mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(elasticsearch): added min_doc_count option for date histogram, closes #3416
This commit is contained in:
parent
141e395489
commit
2345b41a74
@ -6,6 +6,7 @@
|
|||||||
### Enhancements
|
### Enhancements
|
||||||
* **CloudWatch**: Support for multiple AWS Credentials, closes [#3053](https://github.com/grafana/grafana/issues/3053), [#3080](https://github.com/grafana/grafana/issues/3080)
|
* **CloudWatch**: Support for multiple AWS Credentials, closes [#3053](https://github.com/grafana/grafana/issues/3053), [#3080](https://github.com/grafana/grafana/issues/3080)
|
||||||
* **Elasticsearch**: Support for dynamic daily indices for annotations, closes [#3061](https://github.com/grafana/grafana/issues/3061)
|
* **Elasticsearch**: Support for dynamic daily indices for annotations, closes [#3061](https://github.com/grafana/grafana/issues/3061)
|
||||||
|
* **Elasticsearch**: Support for setting min_doc_count for date histogram, closes [#3416](https://github.com/grafana/grafana/issues/3416)
|
||||||
* **Graph Panel**: Option to hide series with all zeroes from legend and tooltip, closes [#1381](https://github.com/grafana/grafana/issues/1381), [#3336](https://github.com/grafana/grafana/issues/3336)
|
* **Graph Panel**: Option to hide series with all zeroes from legend and tooltip, closes [#1381](https://github.com/grafana/grafana/issues/1381), [#3336](https://github.com/grafana/grafana/issues/3336)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
1
public/app/panels/table/specs/table_model_specs.ts
Normal file
1
public/app/panels/table/specs/table_model_specs.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -92,8 +92,10 @@ function (angular, _, queryDef) {
|
|||||||
}
|
}
|
||||||
case 'date_histogram': {
|
case 'date_histogram': {
|
||||||
settings.interval = settings.interval || 'auto';
|
settings.interval = settings.interval || 'auto';
|
||||||
|
settings.min_doc_count = settings.min_doc_count || 0;
|
||||||
$scope.agg.field = $scope.target.timeField;
|
$scope.agg.field = $scope.target.timeField;
|
||||||
settingsLinkText = 'Interval: ' + settings.interval;
|
settingsLinkText = 'Interval: ' + settings.interval;
|
||||||
|
settingsLinkText += ', Min Doc Count: ' + settings.min_doc_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
|
|
||||||
<div class="tight-form" ng-if="showOptions">
|
<div class="tight-form" ng-if="showOptions">
|
||||||
<div class="tight-form-inner-box" ng-if="agg.type === 'date_histogram'">
|
<div class="tight-form-inner-box" ng-if="agg.type === 'date_histogram'">
|
||||||
<div class="tight-form last">
|
<div class="tight-form">
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
<li class="tight-form-item" style="width: 60px">
|
<li class="tight-form-item" style="width: 94px">
|
||||||
Interval
|
Interval
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -46,6 +46,17 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tight-form last">
|
||||||
|
<ul class="tight-form-list">
|
||||||
|
<li class="tight-form-item" style="width: 94px">
|
||||||
|
Min Doc Count
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<input type="number" class="tight-form-input" ng-model="agg.settings.min_doc_count" ng-blur="onChangeInternal()"></metric-segment-model>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tight-form-inner-box" ng-if="agg.type === 'terms'">
|
<div class="tight-form-inner-box" ng-if="agg.type === 'terms'">
|
||||||
<div class="tight-form">
|
<div class="tight-form">
|
||||||
|
@ -50,12 +50,23 @@ function () {
|
|||||||
return queryNode;
|
return queryNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
ElasticQueryBuilder.prototype.getInterval = function(agg) {
|
ElasticQueryBuilder.prototype.getDateHistogramAgg = function(aggDef) {
|
||||||
if (agg.settings && agg.settings.interval !== 'auto') {
|
var esAgg = {};
|
||||||
return agg.settings.interval;
|
var settings = aggDef.settings || {};
|
||||||
} else {
|
esAgg.interval = settings.interval;
|
||||||
return '$interval';
|
esAgg.field = this.timeField;
|
||||||
|
esAgg.min_doc_count = settings.min_doc_count || 0;
|
||||||
|
esAgg.extended_bounds = {min: "$timeFrom", max: "$timeTo"};
|
||||||
|
|
||||||
|
if (esAgg.interval === 'auto') {
|
||||||
|
esAgg.interval = "$interval";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.esVersion >= 2) {
|
||||||
|
esAgg.format = "epoch_millis";
|
||||||
|
}
|
||||||
|
|
||||||
|
return esAgg;
|
||||||
};
|
};
|
||||||
|
|
||||||
ElasticQueryBuilder.prototype.getFiltersAgg = function(aggDef) {
|
ElasticQueryBuilder.prototype.getFiltersAgg = function(aggDef) {
|
||||||
@ -130,15 +141,7 @@ function () {
|
|||||||
|
|
||||||
switch(aggDef.type) {
|
switch(aggDef.type) {
|
||||||
case 'date_histogram': {
|
case 'date_histogram': {
|
||||||
esAgg["date_histogram"] = {
|
esAgg["date_histogram"] = this.getDateHistogramAgg(aggDef);
|
||||||
"interval": this.getInterval(aggDef),
|
|
||||||
"field": this.timeField,
|
|
||||||
"min_doc_count": 0,
|
|
||||||
"extended_bounds": { "min": "$timeFrom", "max": "$timeTo" }
|
|
||||||
};
|
|
||||||
if (this.esVersion >= 2) {
|
|
||||||
esAgg["date_histogram"]["format"] = "epoch_millis";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'filters': {
|
case 'filters': {
|
||||||
|
@ -205,7 +205,7 @@ describe('when generating timeseries from influxdb response', function() {
|
|||||||
|
|
||||||
expect(table.type).to.be('table');
|
expect(table.type).to.be('table');
|
||||||
expect(table.columns.length).to.be(3);
|
expect(table.columns.length).to.be(3);
|
||||||
expect(table.rows[0]).to.eql([1431946625000, 'America', 10]);;
|
expect(table.rows[0]).to.eql([1431946625000, 'America', 10]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user