diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d6fa247b59..f91ebd2fe1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/public/app/panels/table/specs/table_model_specs.ts b/public/app/panels/table/specs/table_model_specs.ts new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/public/app/panels/table/specs/table_model_specs.ts @@ -0,0 +1 @@ + diff --git a/public/app/plugins/datasource/elasticsearch/bucket_agg.js b/public/app/plugins/datasource/elasticsearch/bucket_agg.js index 014761da7f2..2a21bc17960 100644 --- a/public/app/plugins/datasource/elasticsearch/bucket_agg.js +++ b/public/app/plugins/datasource/elasticsearch/bucket_agg.js @@ -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; } } diff --git a/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html b/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html index f6ff3f6cd93..48e9a1322e1 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/bucketAgg.html @@ -35,9 +35,9 @@
-
+
    -
  • +
  • Interval
  • @@ -46,6 +46,17 @@
+
+
    +
  • + Min Doc Count +
  • +
  • + +
  • +
+
+
diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index de4e52a8e81..d736966285c 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -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': { diff --git a/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts b/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts index 8352e41d99a..0e8e16a6114 100644 --- a/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts +++ b/public/app/plugins/datasource/influxdb/specs/influx_series_specs.ts @@ -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]); }); });