From 8d2f350ad17d1cc3ce36933ae4b7d0b7e4eb854b Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Wed, 18 May 2016 14:00:12 +0900 Subject: [PATCH 1/2] (prometheus) fix prometheus link --- public/app/plugins/datasource/prometheus/datasource.ts | 8 ++++---- public/app/plugins/datasource/prometheus/query_ctrl.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index ca7ef051ba0..d4d4ff8ff83 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -43,7 +43,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS return value.replace(/[\\^$*+?.()|[\]{}]/g, '\\\\$&'); } - function interpolateQueryExpr(value, variable, defaultFormatFn) { + this.interpolateQueryExpr = function(value, variable, defaultFormatFn) { // if no multi or include all do not regexEscape if (!variable.multi && !variable.includeAll) { return value; @@ -59,6 +59,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS // Called once per panel (graph) this.query = function(options) { + var self = this; var start = getPrometheusTime(options.range.from, false); var end = getPrometheusTime(options.range.to, true); @@ -73,7 +74,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS activeTargets.push(target); var query: any = {}; - query.expr = templateSrv.replace(target.expr, options.scopedVars, interpolateQueryExpr); + query.expr = templateSrv.replace(target.expr, options.scopedVars, self.interpolateQueryExpr); var interval = target.interval || options.interval; var intervalFactor = target.intervalFactor || 1; @@ -99,7 +100,6 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS return this.performTimeSeriesQuery(query, start, end); }, this)); - var self = this; return $q.all(allQueryPromise) .then(function(allResponse) { var result = []; @@ -160,7 +160,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS var interpolated; try { - interpolated = templateSrv.replace(expr, {}, interpolateQueryExpr); + interpolated = templateSrv.replace(expr, {}, this.interpolateQueryExpr); } catch (err) { return $q.reject(err); } diff --git a/public/app/plugins/datasource/prometheus/query_ctrl.ts b/public/app/plugins/datasource/prometheus/query_ctrl.ts index 8284268ef39..94340804988 100644 --- a/public/app/plugins/datasource/prometheus/query_ctrl.ts +++ b/public/app/plugins/datasource/prometheus/query_ctrl.ts @@ -61,7 +61,7 @@ class PrometheusQueryCtrl extends QueryCtrl { var rangeDiff = Math.ceil((range.to.valueOf() - range.from.valueOf()) / 1000); var endTime = range.to.utc().format('YYYY-MM-DD HH:mm'); var expr = { - expr: this.templateSrv.replace(this.target.expr, this.panelCtrl.panel.scopedVars), + expr: this.templateSrv.replace(this.target.expr, this.panelCtrl.panel.scopedVars, this.datasource.interpolateQueryExpr), range_input: rangeDiff + 's', end_input: endTime, step_input: '', From cd80884b76ed5467d0bdbb88107fde03d855f3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 18 May 2016 12:01:11 +0200 Subject: [PATCH 2/2] fix(dashboard timepicker): fixed issue with time picker and UTC when reading time from url, fixes #5078 --- public/app/features/dashboard/timeSrv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/dashboard/timeSrv.js b/public/app/features/dashboard/timeSrv.js index 13f5ad07bab..cd52155ff5f 100644 --- a/public/app/features/dashboard/timeSrv.js +++ b/public/app/features/dashboard/timeSrv.js @@ -50,7 +50,7 @@ define([ if (!isNaN(value)) { var epoch = parseInt(value); - return moment(epoch); + return moment.utc(epoch); } return null;