From e4fecb48e37ee0144b198357cf4a3c891dd5cd29 Mon Sep 17 00:00:00 2001 From: Felix Barnsteiner Date: Fri, 23 Oct 2015 09:32:02 +0200 Subject: [PATCH 01/16] 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 +
  • +
  • + +
  • +
  • + +
  • +
+
+
From dc4f347ae11e93dd11efa9d688270aa76e62fb30 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Tue, 27 Oct 2015 13:40:50 -0700 Subject: [PATCH 02/16] Added relative checkbox --- public/app/panels/graph/graph.tooltip.js | 2 +- public/app/panels/graph/styleEditor.html | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/panels/graph/graph.tooltip.js b/public/app/panels/graph/graph.tooltip.js index 8a747b61e0c..7f3df2cbafa 100644 --- a/public/app/panels/graph/graph.tooltip.js +++ b/public/app/panels/graph/graph.tooltip.js @@ -117,7 +117,7 @@ function ($) { var seriesHoverInfo = self.getMultiSeriesPlotHoverInfo(plotData, pos); seriesHtml = ''; - timestamp = dashboard.formatDate(seriesHoverInfo.time); + timestamp = dashboard.formatDate(seriesHoverInfo.time,scope.panel.tooltip.relativeTimestamp); for (i = 0; i < seriesHoverInfo.length; i++) { hoverInfo = seriesHoverInfo[i]; diff --git a/public/app/panels/graph/styleEditor.html b/public/app/panels/graph/styleEditor.html index 5d5f2fd7401..312f29b85ab 100644 --- a/public/app/panels/graph/styleEditor.html +++ b/public/app/panels/graph/styleEditor.html @@ -52,6 +52,10 @@ text="All series" model="panel.tooltip.shared" change="render()" tip="Show all series on same tooltip and a x croshair to help follow all series"> + +
From 03e2f25adba38956460f2840166a74a4ffd67433 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Tue, 27 Oct 2015 22:04:43 -0700 Subject: [PATCH 03/16] Added relative time func and code refactoring --- public/app/features/dashboard/dashboardSrv.js | 21 ++++++++++++++++--- public/app/panels/graph/graph.tooltip.js | 15 +++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index 21318ac8370..25abdd42a97 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -216,9 +216,8 @@ function (angular, $, kbn, _, moment) { }; p.formatDate = function(date, format) { - if (!moment.isMoment(date)) { - date = moment(date); - } + + date = this.checkDate(date); format = format || 'YYYY-MM-DD HH:mm:ss'; @@ -227,6 +226,22 @@ function (angular, $, kbn, _, moment) { moment.utc(date).format(format); }; + p.formatRelativeDate = function(date) { + + date = this.checkDate(date); + + return this.timezone === 'browser' ? + moment(date).fromNow() : + moment.utc(date).fromNow(); + }; + + p.checkDate = function(date) { + if (!moment.isMoment(date)) { + date = moment(date); + } + return date; + }; + p._updateSchema = function(old) { var i, j, k; var oldVersion = this.schemaVersion; diff --git a/public/app/panels/graph/graph.tooltip.js b/public/app/panels/graph/graph.tooltip.js index 7f3df2cbafa..eecacf4a04c 100644 --- a/public/app/panels/graph/graph.tooltip.js +++ b/public/app/panels/graph/graph.tooltip.js @@ -117,7 +117,11 @@ function ($) { var seriesHoverInfo = self.getMultiSeriesPlotHoverInfo(plotData, pos); seriesHtml = ''; - timestamp = dashboard.formatDate(seriesHoverInfo.time,scope.panel.tooltip.relativeTimestamp); + if(scope.panel.tooltip.relativeTimestamp) { + timestamp = dashboard.formatRelativeDate(seriesHoverInfo.time); + } else { + timestamp = dashboard.formatDate(seriesHoverInfo.time); + } for (i = 0; i < seriesHoverInfo.length; i++) { hoverInfo = seriesHoverInfo[i]; @@ -127,6 +131,7 @@ function ($) { } series = seriesList[i]; + value = series.formatValue(hoverInfo.value); seriesHtml += '
'; @@ -151,7 +156,13 @@ function ($) { } value = series.formatValue(value); - timestamp = dashboard.formatDate(item.datapoint[0]); + + if(scope.panel.tooltip.relativeTimestamp) { + timestamp = dashboard.formatRelativeDate(item.datapoint[0]); + } else { + timestamp = dashboard.formatDate(item.datapoint[0]); + } + group += '
' + value + '
'; self.showTooltip(timestamp, group, pos); From af65a81d5b2fa5fb56965a9f566de4a45d6b08d1 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Tue, 27 Oct 2015 23:18:38 -0700 Subject: [PATCH 04/16] Added relative time in tooltip --- public/app/panels/graph/graph.tooltip.js | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/public/app/panels/graph/graph.tooltip.js b/public/app/panels/graph/graph.tooltip.js index eecacf4a04c..eef6f909de2 100644 --- a/public/app/panels/graph/graph.tooltip.js +++ b/public/app/panels/graph/graph.tooltip.js @@ -31,8 +31,13 @@ function ($) { return j - 1; }; - this.showTooltip = function(title, innerHtml, pos) { - var body = '
'+ title + '
' ; + this.showTooltip = function(absoluteTime, relativeTime, innerHtml, pos) { + var body; + if(typeof relativeTime === 'undefined') { + body = '
'+ absoluteTime + '
' ; + } else { + body = '
'+ absoluteTime + '
(' + relativeTime + ')
' ; + } body += innerHtml + '
'; $tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY); }; @@ -101,7 +106,7 @@ function ($) { var plot = elem.data().plot; var plotData = plot.getData(); var seriesList = getSeriesFn(); - var group, value, timestamp, hoverInfo, i, series, seriesHtml; + var group, value, absoluteTime, relativeTime, hoverInfo, i, series, seriesHtml; if(dashboard.sharedCrosshair){ scope.appEvent('setCrosshair', { pos: pos, scope: scope }); @@ -117,12 +122,13 @@ function ($) { var seriesHoverInfo = self.getMultiSeriesPlotHoverInfo(plotData, pos); seriesHtml = ''; + if(scope.panel.tooltip.relativeTimestamp) { - timestamp = dashboard.formatRelativeDate(seriesHoverInfo.time); - } else { - timestamp = dashboard.formatDate(seriesHoverInfo.time); + relativeTime = dashboard.formatRelativeDate(seriesHoverInfo.time); } + absoluteTime = dashboard.formatDate(seriesHoverInfo.time); + for (i = 0; i < seriesHoverInfo.length; i++) { hoverInfo = seriesHoverInfo[i]; @@ -140,7 +146,7 @@ function ($) { plot.highlight(i, hoverInfo.hoverIndex); } - self.showTooltip(timestamp, seriesHtml, pos); + self.showTooltip(absoluteTime, relativeTime, seriesHtml, pos); } // single series tooltip else if (item) { @@ -158,14 +164,14 @@ function ($) { value = series.formatValue(value); if(scope.panel.tooltip.relativeTimestamp) { - timestamp = dashboard.formatRelativeDate(item.datapoint[0]); - } else { - timestamp = dashboard.formatDate(item.datapoint[0]); + relativeTime = dashboard.formatRelativeDate(item.datapoint[0]); } + absoluteTime = dashboard.formatDate(item.datapoint[0]); + group += '
' + value + '
'; - self.showTooltip(timestamp, group, pos); + self.showTooltipOther(absoluteTime, relativeTime, group, pos); } // no hit else { From e0b585779d444e1960cb145e559d5a702b25154b Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 28 Oct 2015 08:52:46 -0700 Subject: [PATCH 05/16] Added relative time by default, removed checkbox --- public/app/features/dashboard/dashboardSrv.js | 2 +- public/app/panels/graph/graph.tooltip.js | 19 ++++--------------- public/app/panels/graph/styleEditor.html | 4 ---- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index 25abdd42a97..78d19c43592 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -226,7 +226,7 @@ function (angular, $, kbn, _, moment) { moment.utc(date).format(format); }; - p.formatRelativeDate = function(date) { + p.getRelativeTime = function(date) { date = this.checkDate(date); diff --git a/public/app/panels/graph/graph.tooltip.js b/public/app/panels/graph/graph.tooltip.js index eef6f909de2..62a5a418503 100644 --- a/public/app/panels/graph/graph.tooltip.js +++ b/public/app/panels/graph/graph.tooltip.js @@ -32,12 +32,7 @@ function ($) { }; this.showTooltip = function(absoluteTime, relativeTime, innerHtml, pos) { - var body; - if(typeof relativeTime === 'undefined') { - body = '
'+ absoluteTime + '
' ; - } else { - body = '
'+ absoluteTime + '
(' + relativeTime + ')
' ; - } + var body = '
'+ absoluteTime + '
(' + relativeTime + ')
' ; body += innerHtml + '
'; $tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY); }; @@ -123,10 +118,7 @@ function ($) { seriesHtml = ''; - if(scope.panel.tooltip.relativeTimestamp) { - relativeTime = dashboard.formatRelativeDate(seriesHoverInfo.time); - } - + relativeTime = dashboard.getRelativeTime(seriesHoverInfo.time); absoluteTime = dashboard.formatDate(seriesHoverInfo.time); for (i = 0; i < seriesHoverInfo.length; i++) { @@ -163,15 +155,12 @@ function ($) { value = series.formatValue(value); - if(scope.panel.tooltip.relativeTimestamp) { - relativeTime = dashboard.formatRelativeDate(item.datapoint[0]); - } - + relativeTime = dashboard.getRelativeTime(item.datapoint[0]); absoluteTime = dashboard.formatDate(item.datapoint[0]); group += '
' + value + '
'; - self.showTooltipOther(absoluteTime, relativeTime, group, pos); + self.showTooltip(absoluteTime, relativeTime, group, pos); } // no hit else { diff --git a/public/app/panels/graph/styleEditor.html b/public/app/panels/graph/styleEditor.html index 312f29b85ab..5d5f2fd7401 100644 --- a/public/app/panels/graph/styleEditor.html +++ b/public/app/panels/graph/styleEditor.html @@ -52,10 +52,6 @@ text="All series" model="panel.tooltip.shared" change="render()" tip="Show all series on same tooltip and a x croshair to help follow all series"> - -
From 9bafc4fea1b218b2c7065af6ec4c1514b6c178e2 Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Wed, 4 Nov 2015 11:36:55 -0500 Subject: [PATCH 06/16] add pencil icon back to graphite data source The input needed to be wrapped in a span set to display:block in order to prevent it from moving to the next line. See http://stackoverflow.com/questions/773517/style-input-element-to-fill-remaining-width-of-its-container --- .../datasource/graphite/partials/query.editor.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/graphite/partials/query.editor.html b/public/app/plugins/datasource/graphite/partials/query.editor.html index fb1bbded598..4e671354079 100755 --- a/public/app/plugins/datasource/graphite/partials/query.editor.html +++ b/public/app/plugins/datasource/graphite/partials/query.editor.html @@ -8,6 +8,11 @@
  • {{target.datasource}}
  • +
  • + + + +
  • - + + +
    diff --git a/public/app/plugins/datasource/cloudwatch/query_ctrl.js b/public/app/plugins/datasource/cloudwatch/query_ctrl.js index e24b73cd068..deac54a9b24 100644 --- a/public/app/plugins/datasource/cloudwatch/query_ctrl.js +++ b/public/app/plugins/datasource/cloudwatch/query_ctrl.js @@ -10,6 +10,7 @@ function (angular, _) { module.controller('CloudWatchQueryCtrl', function($scope) { $scope.init = function() { + $scope.target.divideSumByPeriod = $scope.target.divideSumByPeriod || false; $scope.aliasSyntax = '{{metric}} {{stat}} {{namespace}} {{region}} {{}}'; }; From 3a6e8a535cb636fbc8e92e1b4afec07c0c828044 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 16 Dec 2015 02:30:53 -0800 Subject: [PATCH 10/16] Fixed typos --- docs/sources/reference/table_panel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/reference/table_panel.md b/docs/sources/reference/table_panel.md index 381d16186a9..65437f85bd7 100644 --- a/docs/sources/reference/table_panel.md +++ b/docs/sources/reference/table_panel.md @@ -9,7 +9,7 @@ page_keywords: grafana, table, panel, documentation The new table panel is very flexible, supporting both multiple modes for time series as well as for -table, annotation and raw JSON data. It also provides date formating and value formating and coloring options. +table, annotation and raw JSON data. It also provides date formatting and value formatting and coloring options. To view table panels in action and test different configurations with sample data, check out the [Table Panel Showcase in the Grafana Playground](http://play.grafana.org/dashboard/db/table-panel-showcase). @@ -21,7 +21,7 @@ The table panel has many ways to manipulate your data for optimal presentation. 1. `Data`: Control how your query is transformed into a table. 2. `Table Display`: Table display options. -3. `Column Styles`: Column value formating and display options. +3. `Column Styles`: Column value formatting and display options. ## Data to Table From e320bd025f20cecbeb9e632c42cdcc25b080313a Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Wed, 16 Dec 2015 14:35:04 +0100 Subject: [PATCH 11/16] Revert "(cloudwatch) add "Divide Sum By Period" option" --- public/app/plugins/datasource/cloudwatch/datasource.js | 3 --- .../datasource/cloudwatch/partials/query.parameter.html | 3 --- public/app/plugins/datasource/cloudwatch/query_ctrl.js | 1 - 3 files changed, 7 deletions(-) diff --git a/public/app/plugins/datasource/cloudwatch/datasource.js b/public/app/plugins/datasource/cloudwatch/datasource.js index 3d335c90d81..f606b6e3dc8 100644 --- a/public/app/plugins/datasource/cloudwatch/datasource.js +++ b/public/app/plugins/datasource/cloudwatch/datasource.js @@ -330,9 +330,6 @@ function (angular, _, moment, dateMath) { dps.push([null, lastTimestamp + periodMs]); } lastTimestamp = timestamp; - if (options.divideSumByPeriod && stat === 'Sum') { - dp[stat] = dp[stat] / options.period; - } dps.push([dp[stat], timestamp]); }); diff --git a/public/app/plugins/datasource/cloudwatch/partials/query.parameter.html b/public/app/plugins/datasource/cloudwatch/partials/query.parameter.html index bd5dc9fb6ae..7b0785e808d 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/query.parameter.html +++ b/public/app/plugins/datasource/cloudwatch/partials/query.parameter.html @@ -52,9 +52,6 @@
  • -
  • - Sum / Period -
  • diff --git a/public/app/plugins/datasource/cloudwatch/query_ctrl.js b/public/app/plugins/datasource/cloudwatch/query_ctrl.js index deac54a9b24..e24b73cd068 100644 --- a/public/app/plugins/datasource/cloudwatch/query_ctrl.js +++ b/public/app/plugins/datasource/cloudwatch/query_ctrl.js @@ -10,7 +10,6 @@ function (angular, _) { module.controller('CloudWatchQueryCtrl', function($scope) { $scope.init = function() { - $scope.target.divideSumByPeriod = $scope.target.divideSumByPeriod || false; $scope.aliasSyntax = '{{metric}} {{stat}} {{namespace}} {{region}} {{}}'; }; From 2cb83cf19dce67c5191b08b6e9e58f7218ad984a Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 16 Dec 2015 16:32:55 +0100 Subject: [PATCH 12/16] style(graph.tooltip): moves checkdate logic inside each method. I find it easier to follow and checkdate didnt do much. --- public/app/features/dashboard/dashboardSrv.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index 7923e1071cb..559adff5c54 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -214,9 +214,7 @@ function (angular, $, _, moment) { }; p.formatDate = function(date, format) { - - date = this.checkDate(date); - + date = moment.isMoment(date) ? date : moment(date); format = format || 'YYYY-MM-DD HH:mm:ss'; return this.timezone === 'browser' ? @@ -225,21 +223,13 @@ function (angular, $, _, moment) { }; p.getRelativeTime = function(date) { - - date = this.checkDate(date); + date = moment.isMoment(date) ? date : moment(date); return this.timezone === 'browser' ? moment(date).fromNow() : moment.utc(date).fromNow(); }; - p.checkDate = function(date) { - if (!moment.isMoment(date)) { - date = moment(date); - } - return date; - }; - p._updateSchema = function(old) { var i, j, k; var oldVersion = this.schemaVersion; From 12889a9509fbdf037f7c43247fc15f10ad40620e Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 17 Dec 2015 07:17:39 +0100 Subject: [PATCH 13/16] feat(graphite): make sortByName optional fixes #3360 closes #3361 --- public/app/plugins/datasource/graphite/gfunc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/graphite/gfunc.js b/public/app/plugins/datasource/graphite/gfunc.js index cc4cdf01bb7..ec81cda87c5 100644 --- a/public/app/plugins/datasource/graphite/gfunc.js +++ b/public/app/plugins/datasource/graphite/gfunc.js @@ -280,7 +280,7 @@ function (_, $) { addFuncDef({ name: 'sortByName', category: categories.Special, - params: [{ name: "natural", type: "select", options: ["true", "false"] }], + params: [{ name: "natural", type: "select", options: ["true", "false"], optional: true }], defaultParams: ["false"] }); From 26f70a5fd731f6dd6fff9ea218ed317f09c91e50 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 17 Dec 2015 09:04:05 +0100 Subject: [PATCH 14/16] fix(settings): make headline more informative --- public/app/features/dashboard/partials/settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index 347265afed4..9b0e5674fe0 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -117,7 +117,7 @@
    -
    Info
    +
    Dashboard info
    • From e49850342871f592b5268066bdced5bd95ef2dfb Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 17 Dec 2015 09:05:01 +0100 Subject: [PATCH 15/16] fix(elastic): fixed typo --- .../app/plugins/datasource/elasticsearch/partials/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/partials/config.html b/public/app/plugins/datasource/elasticsearch/partials/config.html index 81acd03809c..6e6c00f3bd8 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
        From 80d757b37142cab4da5229fdc71ff0ece988636c Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 17 Dec 2015 10:00:53 +0100 Subject: [PATCH 16/16] feat(elasticsearch): move default query parameters to new table --- .../datasource/elasticsearch/partials/config.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/partials/config.html b/public/app/plugins/datasource/elasticsearch/partials/config.html index d08a83238ad..595588c1be0 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/config.html +++ b/public/app/plugins/datasource/elasticsearch/partials/config.html @@ -31,7 +31,7 @@
      -
      +
      • Version @@ -42,10 +42,13 @@
      +
      + +
      Default query settings
        -
      • +
      • Group by time interval
      • @@ -53,7 +56,7 @@ spellcheck='false' placeholder="example: >10s">
      • - +