Parcourir la source

feat(elasticsearch): added unit option to derivative metric, closes #3512

Torkel Ödegaard il y a 10 ans
Parent
commit
aca9d3965d

+ 5 - 0
CHANGELOG.md

@@ -1,3 +1,8 @@
+# 2.6.1
+
+### New Features
+* **Elasticsearch**: Support for derivative unit option, closes [#3512](https://github.com/grafana/grafana/issues/3512)
+
 # 2.6.0 (2015-12-14)
 
 ### New Features

+ 5 - 1
public/app/plugins/datasource/elasticsearch/elastic_response.js

@@ -82,7 +82,11 @@ function (_, queryDef) {
 
             value = bucket[metric.id];
             if (value !== undefined) {
-              newSeries.datapoints.push([value.value, bucket.key]);
+              if (value.normalized_value) {
+                newSeries.datapoints.push([value.normalized_value, bucket.key]);
+              } else {
+                newSeries.datapoints.push([value.value, bucket.key]);
+              }
             }
 
           }

+ 12 - 0
public/app/plugins/datasource/elasticsearch/partials/metric_agg.html

@@ -39,6 +39,18 @@
 
 <div class="tight-form" ng-if="showOptions">
 	<div class="tight-form-inner-box tight-form-container">
+		<div class="tight-form" ng-if="agg.type === 'derivative'">
+			<ul class="tight-form-list">
+				<li class="tight-form-item" style="width: 75px;">
+					Unit
+				</li>
+				<li>
+					<input type="text" class="input-medium tight-form-input last" ng-model="agg.settings.unit" ng-blur="onChangeInternal()" spellcheck='false'>
+				</li>
+			</ul>
+			<div class="clearfix"></div>
+		</div>
+
 		<div class="tight-form" ng-if="agg.type === 'moving_avg'">
 			<ul class="tight-form-list">
 				<li class="tight-form-item" style="width: 75px;">

+ 3 - 1
public/app/plugins/datasource/elasticsearch/query_def.js

@@ -73,7 +73,9 @@ function (_) {
         {text: 'window', default: 5},
         {text: 'model', default: 'simple'}
       ],
-      'derivative': []
+      'derivative': [
+        {text: 'unit', default: undefined},
+      ]
     },
 
     getMetricAggTypes: function(esVersion) {