From 40845578c695c99ab75186937c7cae82be642869 Mon Sep 17 00:00:00 2001 From: Byron Date: Thu, 7 Jan 2016 14:39:20 -0800 Subject: [PATCH 1/5] Fix elasticsearch hourly indexes --- public/app/plugins/datasource/elasticsearch/index_pattern.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/index_pattern.js b/public/app/plugins/datasource/elasticsearch/index_pattern.js index d565e22c0b6..6b26e41e1c5 100644 --- a/public/app/plugins/datasource/elasticsearch/index_pattern.js +++ b/public/app/plugins/datasource/elasticsearch/index_pattern.js @@ -11,7 +11,7 @@ function (_, moment) { } IndexPattern.intervalMap = { - "Hours": { startOf: 'hour', amount: 'hours'}, + "Hourly": { startOf: 'hour', amount: 'hours'}, "Daily": { startOf: 'day', amount: 'days'}, "Weekly": { startOf: 'isoWeek', amount: 'weeks'}, "Monthly": { startOf: 'month', amount: 'months'}, From 1896bd0920ff8a2714bea115c8ab692fed88e08e Mon Sep 17 00:00:00 2001 From: David Keijser Date: Fri, 8 Jan 2016 16:27:43 +0100 Subject: [PATCH 2/5] Add missing peer dependency: phantomjs --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f40ba9cec24..d6a7719601d 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "karma-phantomjs-launcher": "0.2.1", "load-grunt-tasks": "3.4.0", "mocha": "2.3.4", + "phantomjs": "^1.9.19", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.0", "systemjs": "0.19.6", From 012d1378d41924d3adc2d2ead20bd0100cbf369b Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Sun, 15 Nov 2015 02:37:00 +0900 Subject: [PATCH 3/5] snapshot annotation --- public/app/features/annotations/annotationsSrv.js | 11 +++++++++++ public/app/features/dashboard/shareSnapshotCtrl.js | 13 +++++++++++-- public/app/plugins/panels/graph/module.js | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/public/app/features/annotations/annotationsSrv.js b/public/app/features/annotations/annotationsSrv.js index f131ad28393..64ebadd9e1a 100644 --- a/public/app/features/annotations/annotationsSrv.js +++ b/public/app/features/annotations/annotationsSrv.js @@ -38,10 +38,19 @@ define([ var rangeRaw = timeSrv.timeRange(false); var promises = _.map(annotations, function(annotation) { + if (annotation.snapshotData) { + self.receiveAnnotationResults(annotation.snapshotData); + return; + } return datasourceSrv.get(annotation.datasource).then(function(datasource) { var query = {range: range, rangeRaw: rangeRaw, annotation: annotation}; return datasource.annotationQuery(query) .then(self.receiveAnnotationResults) + .then(function(options) { + if (dashboard.snapshot) { + annotation.snapshotData = angular.copy(options); + } + }) .then(null, errorHandler); }, this); }); @@ -58,6 +67,8 @@ define([ for (var i = 0; i < results.length; i++) { self.addAnnotation(results[i]); } + + return results; }; this.addAnnotation = function(options) { diff --git a/public/app/features/dashboard/shareSnapshotCtrl.js b/public/app/features/dashboard/shareSnapshotCtrl.js index 13c1783d069..1c02a5af3d2 100644 --- a/public/app/features/dashboard/shareSnapshotCtrl.js +++ b/public/app/features/dashboard/shareSnapshotCtrl.js @@ -101,8 +101,14 @@ function (angular, _) { panel.links = []; panel.datasource = null; }); - // remove annotations - dash.annotations.list = []; + // remove annotation queries + dash.annotations.list = _.map(dash.annotations.list, function(annotation) { + return { + name: annotation.name, + enable: annotation.enable, + snapshotData: annotation.snapshotData + }; + }); // remove template queries _.each(dash.templating.list, function(variable) { variable.query = ""; @@ -122,6 +128,9 @@ function (angular, _) { $scope.dashboard.forEachPanel(function(panel) { delete panel.snapshotData; }); + _.each($scope.dashboard.annotations.list, function(annotation) { + delete annotation.snapshotData; + }); }; $scope.deleteSnapshot = function() { diff --git a/public/app/plugins/panels/graph/module.js b/public/app/plugins/panels/graph/module.js index 731fb47ae6d..42ef167f911 100644 --- a/public/app/plugins/panels/graph/module.js +++ b/public/app/plugins/panels/graph/module.js @@ -21,7 +21,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) { }; }); - module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper, $q) { + module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper) { $scope.panelMeta = new PanelMeta({ panelName: 'Graph', @@ -144,7 +144,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) { $scope.loadSnapshot = function(snapshotData) { panelHelper.updateTimeRange($scope); - $scope.annotationsPromise = $q.when([]); + $scope.annotationsPromise = annotationsSrv.getAnnotations($scope.dashboard); $scope.dataHandler(snapshotData); }; From d3bc52278d41e7fb5a6ef7c2c2c3da39802f56b1 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Mon, 11 Jan 2016 19:17:25 +0900 Subject: [PATCH 4/5] annotation snapshot fix --- public/app/features/annotations/annotationsSrv.js | 4 ++-- public/app/features/dashboard/shareSnapshotCtrl.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/app/features/annotations/annotationsSrv.js b/public/app/features/annotations/annotationsSrv.js index 64ebadd9e1a..c58c5ff6d4e 100644 --- a/public/app/features/annotations/annotationsSrv.js +++ b/public/app/features/annotations/annotationsSrv.js @@ -46,9 +46,9 @@ define([ var query = {range: range, rangeRaw: rangeRaw, annotation: annotation}; return datasource.annotationQuery(query) .then(self.receiveAnnotationResults) - .then(function(options) { + .then(function(results) { if (dashboard.snapshot) { - annotation.snapshotData = angular.copy(options); + annotation.snapshotData = angular.copy(results); } }) .then(null, errorHandler); diff --git a/public/app/features/dashboard/shareSnapshotCtrl.js b/public/app/features/dashboard/shareSnapshotCtrl.js index 1c02a5af3d2..445677d5a12 100644 --- a/public/app/features/dashboard/shareSnapshotCtrl.js +++ b/public/app/features/dashboard/shareSnapshotCtrl.js @@ -102,13 +102,17 @@ function (angular, _) { panel.datasource = null; }); // remove annotation queries - dash.annotations.list = _.map(dash.annotations.list, function(annotation) { + dash.annotations.list = _.chain(dash.annotations.list) + .filter(function(annotation) { + return annotation.enable; + }) + .map(function(annotation) { return { name: annotation.name, enable: annotation.enable, snapshotData: annotation.snapshotData }; - }); + }).value(); // remove template queries _.each(dash.templating.list, function(variable) { variable.query = ""; From 882980ada77f0c4c60bb2bfc0d0b68ba85fece46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 11 Jan 2016 16:39:22 +0100 Subject: [PATCH 5/5] changelog: updated with info about #3635 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be185b32ff8..acf60b77689 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ # 3.0.0 (unrelased master branch) - ### Breaking changes **InfluxDB 0.8.x** The data source for the old version of influxdb (0.8.x) is no longer included in default builds. Can easily be installed via improved plugin system, closes #3523 **KairosDB** The data source is no longer included in default builds. Can easily be installed via improved plugin system, closes #3524 @@ -8,6 +7,7 @@ ### Enhancements ### * **Sessions**: Support for memcached as session storage, closes [#3458](https://github.com/grafana/grafana/pull/3458) * **mysql**: Grafana now supports ssl for mysql, closes [#3584](https://github.com/grafana/grafana/pull/3584) +* **snapshot**: Annotations are now included in snapshots, closes [#3635](https://github.com/grafana/grafana/pull/3635) # 2.6.1 (unrelased, 2.6.x branch)