From ebee9f7dca5a4419006497abc6f1b074298a2464 Mon Sep 17 00:00:00 2001 From: Luke Morris Date: Mon, 8 May 2017 17:11:59 -0700 Subject: [PATCH] =?UTF-8?q?Cowabunga,=20it's=20dashboard=20=F0=9F=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- influx/query.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/influx/query.go b/influx/query.go index d5043e559..dc40a91d9 100644 --- a/influx/query.go +++ b/influx/query.go @@ -10,6 +10,12 @@ import ( // Convert changes an InfluxQL query to a QueryConfig func Convert(influxQL string) (chronograf.QueryConfig, error) { + itsDashboardTime := false + if strings.Contains(influxQL, ":dashboardTime:") { + influxQL = strings.Replace(influxQL, ":dashboardTime:", "now() - 15m", 1) + itsDashboardTime = true + } + query, err := influxql.ParseQuery(influxQL) if err != nil { return chronograf.QueryConfig{}, err @@ -177,8 +183,12 @@ func Convert(influxQL string) (chronograf.QueryConfig, error) { // If the condition has a time range we report back its duration if dur, ok := hasTimeRange(stmt.Condition); ok { - qc.Range = &chronograf.DurationRange{ - Lower: "now() - " + shortDur(dur), + if !itsDashboardTime { + qc.Range = &chronograf.DurationRange{ + Lower: "now() - " + shortDur(dur), + } + } else { + strings.Replace(influxQL, "now() - 15m", ":dashboardTime:", 1) } }