From e4fecb48e37ee0144b198357cf4a3c891dd5cd29 Mon Sep 17 00:00:00 2001 From: Felix Barnsteiner Date: Fri, 23 Oct 2015 09:32:02 +0200 Subject: [PATCH] Add ability to set a global time interval The interval is configurable in the data source. This commit only adds the ability to Elasticsearch datasources --- public/app/features/panel/panelHelper.js | 4 +++- .../datasource/elasticsearch/datasource.js | 1 + .../elasticsearch/partials/config.html | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/public/app/features/panel/panelHelper.js b/public/app/features/panel/panelHelper.js index c7473692a43..f0d4f98ee9c 100644 --- a/public/app/features/panel/panelHelper.js +++ b/public/app/features/panel/panelHelper.js @@ -59,7 +59,9 @@ function (angular, dateMath, rangeUtil, _, kbn, $) { scope.resolution = Math.ceil($(window).width() * (scope.panel.span / 12)); } - scope.interval = kbn.calculateInterval(scope.range, scope.resolution, scope.panel.interval); + var panelInterval = scope.panel.interval; + var datasourceInterval = (scope.datasource || {}).interval; + scope.interval = kbn.calculateInterval(scope.range, scope.resolution, panelInterval || datasourceInterval); }; this.applyPanelTimeOverrides = function(scope) { diff --git a/public/app/plugins/datasource/elasticsearch/datasource.js b/public/app/plugins/datasource/elasticsearch/datasource.js index 374fc9da90d..21a5f929e89 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.js +++ b/public/app/plugins/datasource/elasticsearch/datasource.js @@ -24,6 +24,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes this.index = datasource.index; this.timeField = datasource.jsonData.timeField; this.indexPattern = new IndexPattern(datasource.index, datasource.jsonData.interval); + this.interval = datasource.jsonData.timeInterval; this.queryBuilder = new ElasticQueryBuilder({ timeField: this.timeField }); diff --git a/public/app/plugins/datasource/elasticsearch/partials/config.html b/public/app/plugins/datasource/elasticsearch/partials/config.html index d1cb05801d6..622d4cbdc86 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/config.html +++ b/public/app/plugins/datasource/elasticsearch/partials/config.html @@ -1,7 +1,7 @@

-
Elastic search details
+
Elasticsearch details
-
+
  • Time field name @@ -31,3 +31,18 @@
+
+
    +
  • + Group by time interval +
  • +
  • + +
  • +
  • + +
  • +
+
+