Kaynağa Gözat

Merge remote-tracking branch 'origin/master' into develop

Conflicts:
	src/app/features/opentsdb/datasource.js
Torkel Ödegaard 10 yıl önce
ebeveyn
işleme
09f2950256

+ 8 - 3
CHANGELOG.md

@@ -6,9 +6,6 @@
 - [Issue #171](https://github.com/grafana/grafana/issues/171).   Panel: Different time periods, panels can override dashboard relative time and/or add a time shift
 - [Issue #171](https://github.com/grafana/grafana/issues/171).   Panel: Different time periods, panels can override dashboard relative time and/or add a time shift
 - [Issue #1488](https://github.com/grafana/grafana/issues/1488). Dashboard: Clone dashboard / Save as
 - [Issue #1488](https://github.com/grafana/grafana/issues/1488). Dashboard: Clone dashboard / Save as
 
 
-**Changes**
-- Dashboard title change & save will no longer create a new dashboard, it will just change the title.
-
 **Enhancements**
 **Enhancements**
 - [Issue #1366](https://github.com/grafana/grafana/issues/1366). Graph & Singlestat: Support for additional units, Fahrenheit (°F) and Celsius (°C), Humidity (%H), kW, watt-hour (Wh), kilowatt-hour (kWh), velocities (m/s, km/h, mpg, knot)
 - [Issue #1366](https://github.com/grafana/grafana/issues/1366). Graph & Singlestat: Support for additional units, Fahrenheit (°F) and Celsius (°C), Humidity (%H), kW, watt-hour (Wh), kilowatt-hour (kWh), velocities (m/s, km/h, mpg, knot)
 - [Issue #978](https://github.com/grafana/grafana/issues/978).   Graph: Shared tooltip improvement, can now support metrics of different resolution/intervals
 - [Issue #978](https://github.com/grafana/grafana/issues/978).   Graph: Shared tooltip improvement, can now support metrics of different resolution/intervals
@@ -26,6 +23,14 @@
 - [Issue #1359](https://github.com/grafana/grafana/issues/1359). Graph: Fix for all series tooltip showing series with all null values when ``Hide Empty`` option is enabled
 - [Issue #1359](https://github.com/grafana/grafana/issues/1359). Graph: Fix for all series tooltip showing series with all null values when ``Hide Empty`` option is enabled
 - [Issue #1497](https://github.com/grafana/grafana/issues/1497). Dashboard: Fixed memory leak when switching dashboards
 - [Issue #1497](https://github.com/grafana/grafana/issues/1497). Dashboard: Fixed memory leak when switching dashboards
 
 
+**Changes**
+- Dashboard title change & save will no longer create a new dashboard, it will just change the title.
+
+**OpenTSDB breaking change**
+- [Issue #1438](https://github.com/grafana/grafana/issues/1438). OpenTSDB: Automatic downsample interval passed to OpenTSDB (depends on timespan and graph width)
+- NOTICE, Downsampling is now enabled by default, so if you have not picked a downsample aggregator in your metric query do so or your graphs will be missleading
+- This will make Grafana a lot quicker for OpenTSDB users when viewing large time spans without having to change the downsample interval manually.
+
 **Tech**
 **Tech**
 - [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2
 - [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2
 
 

+ 14 - 4
src/app/features/opentsdb/datasource.js

@@ -24,7 +24,16 @@ function (angular, _, kbn) {
     OpenTSDBDatasource.prototype.query = function(options) {
     OpenTSDBDatasource.prototype.query = function(options) {
       var start = convertToTSDBTime(options.range.from);
       var start = convertToTSDBTime(options.range.from);
       var end = convertToTSDBTime(options.range.to);
       var end = convertToTSDBTime(options.range.to);
-      var queries = _.compact(_.map(options.targets, convertTargetToQuery));
+      var qs = [];
+
+      if (options.interval.match(/\.[0-9]+s/)) {
+        options.interval = parseFloat(options.interval)*1000 + "ms";
+      }
+      _.each(options.targets, function(target) {
+        qs.push(convertTargetToQuery(target, options.interval));
+      });
+
+      var queries = _.compact(qs);
 
 
       // No valid targets, return the empty result to save a round trip.
       // No valid targets, return the empty result to save a round trip.
       if (_.isEmpty(queries)) {
       if (_.isEmpty(queries)) {
@@ -119,7 +128,7 @@ function (angular, _, kbn) {
       return metric;
       return metric;
     }
     }
 
 
-    function convertTargetToQuery(target) {
+    function convertTargetToQuery(target, interval) {
       if (!target.metric || target.hide) {
       if (!target.metric || target.hide) {
         return null;
         return null;
       }
       }
@@ -148,8 +157,9 @@ function (angular, _, kbn) {
         }
         }
       }
       }
 
 
-      if (target.shouldDownsample) {
-        query.downsample = templateSrv.replace(target.downsampleInterval) + "-" + target.downsampleAggregator;
+      if (!target.disableDownsampling) {
+        var buf =  target.downsampleInterval || interval;
+        query.downsample = templateSrv.replace(buf) + "-" + target.downsampleAggregator;
       }
       }
 
 
       query.tags = angular.copy(target.tags);
       query.tags = angular.copy(target.tags);

+ 94 - 62
src/app/features/opentsdb/partials/query.editor.html

@@ -43,14 +43,18 @@
       </ul>
       </ul>
 
 
       <ul class="tight-form-list" role="menu">
       <ul class="tight-form-list" role="menu">
+				<li class="tight-form-item" style="width: 86px">
+					Metric
+				</li>
         <li>
         <li>
           <input type="text"
           <input type="text"
-                 class="tight-form-input"
+                 class="input-large tight-form-input"
                  ng-model="target.metric"
                  ng-model="target.metric"
                  spellcheck='false'
                  spellcheck='false'
                  bs-typeahead="suggestMetrics"
                  bs-typeahead="suggestMetrics"
                  placeholder="metric name"
                  placeholder="metric name"
                  data-min-length=0 data-items=100
                  data-min-length=0 data-items=100
+								 ng-model-onblur
                  ng-blur="targetBlur()"
                  ng-blur="targetBlur()"
                  >
                  >
           <a bs-tooltip="target.errors.metric"
           <a bs-tooltip="target.errors.metric"
@@ -75,49 +79,7 @@
           </a>
           </a>
         </li>
         </li>
 
 
-        <li class="tight-form-item">
-            Rate:
-            <input type="checkbox"
-                   class="tight-form-checkbox"
-                   ng-model="target.shouldComputeRate"
-                   ng-change="targetBlur()"
-                   >
-        </li>
-        <li class="tight-form-item" ng-hide="!target.shouldComputeRate">
-          Counter:
-          <input type="checkbox"
-                 class="tight-form-checkbox"
-                 ng-disabled="!target.shouldComputeRate"
-                 ng-model="target.isCounter"
-                 ng-change="targetBlur()">
-        </li>
-        <li class="tight-form-item" ng-hide="!target.isCounter">
-          Counter Max:
-        </li>
-        <li ng-hide="!target.isCounter">
-          <input type="text"
-                 class="tight-form-input input-medium"
-                 ng-disabled="!target.shouldComputeRate"
-                 ng-model="target.counterMax"
-                 spellcheck='false'
-                 placeholder="Counter max value"
-                 ng-blur="targetBlur()"
-                 />
-        </li>
-        <li class="tight-form-item" ng-hide="!target.isCounter">
-          Counter Reset Value:
-        </li>
-        <li ng-hide="!target.isCounter">
-          <input type="text"
-                 class="tight-form-input input-medium"
-                 ng-disabled="!target.shouldComputeRate"
-                 ng-model="target.counterResetValue"
-                 spellcheck='false'
-                 placeholder="Counter reset value"
-                 ng-blur="targetBlur()"
-                 />
-        </li>
-        <li class="tight-form-item">
+				<li class="tight-form-item">
           Alias:
           Alias:
         </li>
         </li>
 				<li>
 				<li>
@@ -137,32 +99,30 @@
     </div>
     </div>
 
 
     <div class="tight-form">
     <div class="tight-form">
-      <ul class="tight-form-list" role="menu">
+			<ul class="tight-form-list" role="menu">
+				<li class="tight-form-item">
+					<i class="fa fa-eye invisible"></i>
+				</li>
 
 
-        <li class="tight-form-item">
-          Downsample:
-          <input type="checkbox"
-                 class="tight-form-checkbox"
-                 ng-model="target.shouldDownsample"
-                 ng-change="targetBlur(target)"
-                 >
-        </li>
+				<li class="tight-form-item" style="width: 86px">
+					Down sample
+				</li>
 
 
-        <li ng-hide="!target.shouldDownsample">
+				<li>
           <input type="text"
           <input type="text"
-                 class="input-small tight-form-input"
-                 ng-disabled="!target.shouldDownsample"
+                 class="input-large tight-form-input"
                  ng-model="target.downsampleInterval"
                  ng-model="target.downsampleInterval"
+								 ng-model-onblur
                  ng-change="targetBlur()"
                  ng-change="targetBlur()"
-                 placeholder="interval"
+                 placeholder="interval (empty = auto)"
                  >
                  >
         </li>
         </li>
 
 
-        <li class="tight-form-item" ng-hide="!target.shouldDownsample">
+        <li class="tight-form-item">
           Aggregator
           Aggregator
         </li>
         </li>
 
 
-        <li ng-hide="!target.shouldDownsample">
+        <li>
           <select ng-model="target.downsampleAggregator"
           <select ng-model="target.downsampleAggregator"
                   class="tight-form-input input-small"
                   class="tight-form-input input-small"
                   ng-options="agg for agg in aggregators"
                   ng-options="agg for agg in aggregators"
@@ -170,8 +130,25 @@
           </select>
           </select>
         </li>
         </li>
 
 
-        <li class="tight-form-item">
-            Tags:
+				<li class="tight-form-item">
+					Disable downsampling&nbsp;
+					<input class="cr1" id="target.disableDownsampling" type="checkbox"
+					ng-model="target.disableDownsampling" ng-checked="target.disableDownsampling" ng-change="targetBlur()">
+					<label for="target.disableDownsampling" class="cr1"></label>
+				</li>
+
+			</ul>
+      <div class="clearfix"></div>
+    </div>
+
+		<div class="tight-form">
+			<ul class="tight-form-list" role="menu">
+				<li class="tight-form-item">
+					<i class="fa fa-eye invisible"></i>
+				</li>
+
+				<li class="tight-form-item" style="width: 86px">
+           Tags
         </li>
         </li>
         <li ng-repeat="(key, value) in target.tags track by $index" class="tight-form-item">
         <li ng-repeat="(key, value) in target.tags track by $index" class="tight-form-item">
           {{key}}&nbsp;=&nbsp;{{value}}
           {{key}}&nbsp;=&nbsp;{{value}}
@@ -202,7 +179,7 @@
                    ng-model="target.currentTagValue"
                    ng-model="target.currentTagValue"
                    placeholder="value">
                    placeholder="value">
             <a ng-click="addTag()">
             <a ng-click="addTag()">
-              <i class="fa fa-plus"></i>
+							add tag
             </a>
             </a>
             <a bs-tooltip="target.errors.tags"
             <a bs-tooltip="target.errors.tags"
                style="color: rgb(229, 189, 28)"
                style="color: rgb(229, 189, 28)"
@@ -213,5 +190,60 @@
       </ul>
       </ul>
       <div class="clearfix"></div>
       <div class="clearfix"></div>
     </div>
     </div>
+
+		<div class="tight-form">
+			<ul class="tight-form-list" role="menu">
+				<li class="tight-form-item">
+					<i class="fa fa-eye invisible"></i>
+				</li>
+
+				<li class="tight-form-item" style="width: 86px">
+					Rate&nbsp;
+					<input class="cr1" id="target.shouldComputeRate" type="checkbox"
+					ng-model="target.shouldComputeRate" ng-checked="target.shouldComputeRate" ng-change="targetBlur()">
+					<label for="target.shouldComputeRate" class="cr1"></label>
+				</li>
+
+        <li class="tight-form-item" ng-hide="!target.shouldComputeRate">
+					Counter&nbsp;
+					<input class="cr1" id="target.isCounter" type="checkbox"
+					ng-model="target.isCounter" ng-checked="target.isCounter" ng-change="targetBlur()">
+					<label for="target.isCounter" class="cr1"></label>
+				</li>
+
+				<li class="tight-form-item" ng-hide="!target.isCounter">
+          Counter Max:
+        </li>
+
+        <li ng-hide="!target.isCounter">
+          <input type="text"
+                 class="tight-form-input input-small"
+                 ng-disabled="!target.shouldComputeRate"
+                 ng-model="target.counterMax"
+                 spellcheck='false'
+                 placeholder="max value"
+								 ng-model-onblur
+                 ng-blur="targetBlur()"
+                 />
+        </li>
+        <li class="tight-form-item" ng-hide="!target.isCounter">
+          Reset Value:
+        </li>
+        <li ng-hide="!target.isCounter">
+          <input type="text"
+                 class="tight-form-input input-small"
+                 ng-disabled="!target.shouldComputeRate"
+                 ng-model="target.counterResetValue"
+                 spellcheck='false'
+                 placeholder="reset value"
+								 ng-model-onblur
+                 ng-blur="targetBlur()"
+                 />
+        </li>
+			</ul>
+
+      <div class="clearfix"></div>
+    </div>
+
   </div>
   </div>
 </div>
 </div>