From aca9d3965da1c8ce6c74c7de6cea886c6507c977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 14 Dec 2015 18:49:53 +0100 Subject: [PATCH] feat(elasticsearch): added unit option to derivative metric, closes #3512 --- CHANGELOG.md | 5 +++++ .../datasource/elasticsearch/elastic_response.js | 6 +++++- .../elasticsearch/partials/metric_agg.html | 12 ++++++++++++ .../plugins/datasource/elasticsearch/query_def.js | 4 +++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a6f780faf1..850ebfee008 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.js b/public/app/plugins/datasource/elasticsearch/elastic_response.js index 32120a4519a..b8405797408 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.js +++ b/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]); + } } } diff --git a/public/app/plugins/datasource/elasticsearch/partials/metric_agg.html b/public/app/plugins/datasource/elasticsearch/partials/metric_agg.html index 4da8b53181b..5f3c3072bfa 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metric_agg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metric_agg.html @@ -39,6 +39,18 @@
+
+
    +
  • + Unit +
  • +
  • + +
  • +
+
+
+
  • diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 53c1fe378ef..ae44af3e2db 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/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) {