Просмотр исходного кода

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
Felix Barnsteiner 10 лет назад
Родитель
Сommit
e4fecb48e3

+ 3 - 1
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) {

+ 1 - 0
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
       });

+ 17 - 2
public/app/plugins/datasource/elasticsearch/partials/config.html

@@ -1,7 +1,7 @@
 <div ng-include="httpConfigPartialSrc"></div>
 <br>
 
-<h5>Elastic search details</h5>
+<h5>Elasticsearch details</h5>
 
 <div class="tight-form">
 	<ul class="tight-form-list">
@@ -20,7 +20,7 @@
 	</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: 144px">
 			Time field name
@@ -31,3 +31,18 @@
 	</ul>
 	<div class="clearfix"></div>
 </div>
+<div class="tight-form last">
+	<ul class="tight-form-list">
+		<li class="tight-form-item" style="width: 144px">
+			Group by time interval
+		</li>
+		<li>
+			<input type="text" class="input-medium tight-form-input input-xlarge" ng-model="current.jsonData.timeInterval"
+						 spellcheck='false' placeholder="example: >10s">
+		</li>
+		<li class="tight-form-item">
+			<i class="fa fa-question-circle" bs-tooltip="'Set a low limit by having a greater sign: example: >60s'" data-placement="right"></i>
+		</li>
+	</ul>
+	<div class="clearfix"></div>
+</div>