mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -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
|
||||
* **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 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)
|
||||
|
||||
### 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': {
|
||||
settings.interval = settings.interval || 'auto';
|
||||
settings.min_doc_count = settings.min_doc_count || 0;
|
||||
$scope.agg.field = $scope.target.timeField;
|
||||
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-inner-box" ng-if="agg.type === 'date_histogram'">
|
||||
<div class="tight-form last">
|
||||
<div class="tight-form">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item" style="width: 60px">
|
||||
<li class="tight-form-item" style="width: 94px">
|
||||
Interval
|
||||
</li>
|
||||
<li>
|
||||
@ -46,6 +46,17 @@
|
||||
</ul>
|
||||
<div class="clearfix"></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 class="tight-form-inner-box" ng-if="agg.type === 'terms'">
|
||||
<div class="tight-form">
|
||||
|
@ -50,12 +50,23 @@ function () {
|
||||
return queryNode;
|
||||
};
|
||||
|
||||
ElasticQueryBuilder.prototype.getInterval = function(agg) {
|
||||
if (agg.settings && agg.settings.interval !== 'auto') {
|
||||
return agg.settings.interval;
|
||||
} else {
|
||||
return '$interval';
|
||||
ElasticQueryBuilder.prototype.getDateHistogramAgg = function(aggDef) {
|
||||
var esAgg = {};
|
||||
var settings = aggDef.settings || {};
|
||||
esAgg.interval = settings.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) {
|
||||
@ -130,15 +141,7 @@ function () {
|
||||
|
||||
switch(aggDef.type) {
|
||||
case 'date_histogram': {
|
||||
esAgg["date_histogram"] = {
|
||||
"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";
|
||||
}
|
||||
esAgg["date_histogram"] = this.getDateHistogramAgg(aggDef);
|
||||
break;
|
||||
}
|
||||
case 'filters': {
|
||||
|
@ -205,7 +205,7 @@ describe('when generating timeseries from influxdb response', function() {
|
||||
|
||||
expect(table.type).to.be('table');
|
||||
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