From 20e13a427551b8ad8eedfd9c3a53c602dd377ce8 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 5 Apr 2017 23:41:28 -0500 Subject: [PATCH 01/12] Workaround InfluxQL bugs by returning original query. --- influx/query.go | 2 +- influx/query_test.go | 42 +++++++++++++++++++++++++++++++++++++++ server/dashboards_test.go | 2 +- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 influx/query_test.go diff --git a/influx/query.go b/influx/query.go index 2601898243..c3340bb9c0 100644 --- a/influx/query.go +++ b/influx/query.go @@ -15,7 +15,7 @@ func Convert(influxQL string) (chronograf.QueryConfig, error) { } raw := chronograf.QueryConfig{ - RawText: query.String(), + RawText: influxQL, Fields: []chronograf.Field{}, GroupBy: chronograf.GroupBy{ Tags: []string{}, diff --git a/influx/query_test.go b/influx/query_test.go new file mode 100644 index 0000000000..b930cb4fa1 --- /dev/null +++ b/influx/query_test.go @@ -0,0 +1,42 @@ +package influx + +import ( + "reflect" + "testing" + + "github.com/influxdata/chronograf" +) + +func TestConvert(t *testing.T) { + tests := []struct { + name string + influxQL string + want chronograf.QueryConfig + wantErr bool + }{ + { + name: "Test named count field", + influxQL: `SELECT moving_average(mean("count"),14) FROM "usage_computed"."autogen".unique_clusters_by_day WHERE time > now() - 90d AND product = 'influxdb' group by time(1d)`, + want: chronograf.QueryConfig{ + RawText: `SELECT moving_average(mean("count"),14) FROM "usage_computed"."autogen".unique_clusters_by_day WHERE time > now() - 90d AND product = 'influxdb' group by time(1d)`, + Fields: []chronograf.Field{}, + Tags: map[string][]string{}, + GroupBy: chronograf.GroupBy{ + Tags: []string{}, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := Convert(tt.influxQL) + if (err != nil) != tt.wantErr { + t.Errorf("Convert() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("Convert() = %#v, want %#v", got, tt.want) + } + }) + } +} diff --git a/server/dashboards_test.go b/server/dashboards_test.go index 55547f5fb6..2d1c3c034f 100644 --- a/server/dashboards_test.go +++ b/server/dashboards_test.go @@ -246,7 +246,7 @@ func Test_newDashboardResponse(t *testing.T) { { Command: "SELECT donors from hill_valley_preservation_society where time > '1985-10-25 08:00:00'", QueryConfig: chronograf.QueryConfig{ - RawText: "SELECT donors FROM hill_valley_preservation_society WHERE time > '1985-10-25 08:00:00'", + RawText: "SELECT donors from hill_valley_preservation_society where time > '1985-10-25 08:00:00'", Fields: []chronograf.Field{}, GroupBy: chronograf.GroupBy{ Tags: []string{}, From 66f5c890d40ac9c60ab4ca16ceab7d2e3e321e51 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Thu, 6 Apr 2017 00:57:50 -0500 Subject: [PATCH 02/12] Update CHANGELOG to mention fixing no quoted raw influxql --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92b9643939..4496ec5d1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ 1. [#1179](https://github.com/influxdata/chronograf/pull/1179): Admin Databases Page will render a database without retention policies 1. [#1128](https://github.com/influxdata/chronograf/pull/1128): No more ghost dashboards 👻 1. [#1189](https://github.com/influxdata/chronograf/pull/1189): Clicking inside the graph header edit box will no longer blur the field. Use the Escape key for that behavior instead. + 1. [#1193](https://github.com/influxdata/chronograf/issues/1193): Fix no quoting of raw InfluxQL fields with function names ### Features 1. [#1112](https://github.com/influxdata/chronograf/pull/1112): Add ability to delete a dashboard From b7f91df6f412f0b2ad6278bd70aa187810f3aa4b Mon Sep 17 00:00:00 2001 From: Luke Morris Date: Thu, 6 Apr 2017 13:46:50 -0700 Subject: [PATCH 03/12] No need to build a query if rawText exists --- ui/src/shared/components/LayoutRenderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/src/shared/components/LayoutRenderer.js b/ui/src/shared/components/LayoutRenderer.js index c8992cb4d6..f772b0f9aa 100644 --- a/ui/src/shared/components/LayoutRenderer.js +++ b/ui/src/shared/components/LayoutRenderer.js @@ -100,7 +100,8 @@ export const LayoutRenderer = React.createClass({ // on a stable query representation. let queryText if (query.queryConfig) { - queryText = buildInfluxQLQuery(timeRange, query.queryConfig) + const {queryConfig: {rawText}} = query + queryText = rawText || buildInfluxQLQuery(timeRange, query.queryConfig) } else { queryText = this.buildQueryForOldQuerySchema(query) } From ee9042bd602fe6f9e61793f33da82eef354bd4de Mon Sep 17 00:00:00 2001 From: lukevmorris Date: Thu, 6 Apr 2017 14:30:36 -0700 Subject: [PATCH 04/12] These three are siblings now; give them a stacking priority (#1215) --- ui/src/style/pages/dashboards.scss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/src/style/pages/dashboards.scss b/ui/src/style/pages/dashboards.scss index 7d4dff2d0d..ae500071e2 100644 --- a/ui/src/style/pages/dashboards.scss +++ b/ui/src/style/pages/dashboards.scss @@ -57,6 +57,7 @@ $dash-graph-options-arrow: 8px; left: 0; } .dash-graph--container { + z-index: 0; user-select: none !important; -o-user-select: none !important; -moz-user-select: none !important; @@ -88,7 +89,7 @@ $dash-graph-options-arrow: 8px; } } .dash-graph--heading { - z-index: 1; + z-index: 0; user-select: none !important; -o-user-select: none !important; -moz-user-select: none !important; @@ -146,7 +147,7 @@ $dash-graph-options-arrow: 8px; .dash-graph--options { width: $dash-graph-heading; position: absolute; - z-index: 2; + z-index: 1; right: 0px; top: 0px; From 150b0f212d4f240eb2d413cafe0df7849ca11108 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Thu, 6 Apr 2017 17:30:53 -0500 Subject: [PATCH 05/12] Update cell dashboard error messags to be descriptive --- server/dashboards.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/dashboards.go b/server/dashboards.go index 0a0a71eac1..73705a645b 100644 --- a/server/dashboards.go +++ b/server/dashboards.go @@ -365,7 +365,7 @@ func (s *Service) NewDashboardCell(w http.ResponseWriter, r *http.Request) { dash.Cells = append(dash.Cells, cell) if err := s.DashboardsStore.Update(ctx, dash); err != nil { - msg := fmt.Sprintf("Error updating dashboard ID %d: %v", id, err) + msg := fmt.Sprintf("Error adding cell %s to dashboard %d: %v", cid, id, err) Error(w, http.StatusInternalServerError, msg, s.Logger) return } @@ -435,7 +435,7 @@ func (s *Service) RemoveDashboardCell(w http.ResponseWriter, r *http.Request) { dash.Cells = append(dash.Cells[:cellid], dash.Cells[cellid+1:]...) if err := s.DashboardsStore.Update(ctx, dash); err != nil { - msg := fmt.Sprintf("Error updating dashboard ID %d: %v", id, err) + msg := fmt.Sprintf("Error removing cell %s from dashboard %d: %v", cid, id, err) Error(w, http.StatusInternalServerError, msg, s.Logger) return } @@ -484,7 +484,7 @@ func (s *Service) ReplaceDashboardCell(w http.ResponseWriter, r *http.Request) { dash.Cells[cellid] = cell if err := s.DashboardsStore.Update(ctx, dash); err != nil { - msg := fmt.Sprintf("Error updating dashboard ID %d: %v", id, err) + msg := fmt.Sprintf("Error updating cell %s in dashboard %d: %v", cid, id, err) Error(w, http.StatusInternalServerError, msg, s.Logger) return } From 777221c9cfaad98e05fd41fa675a1122d12e9f63 Mon Sep 17 00:00:00 2001 From: lukevmorris Date: Thu, 6 Apr 2017 16:21:27 -0700 Subject: [PATCH 06/12] Server validates that queries include database + rp (#1219) * Server validates that queries include database + rp * Update CHANGELOG --- CHANGELOG.md | 1 + ui/src/dashboards/constants/index.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fabed63f6..c5e8c1f7a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ 1. [#1195](https://github.com/influxdata/chronograf/issues/1195): Chronograf was not redirecting with authentiation for Influx Enterprise Meta service 1. [#1095](https://github.com/influxdata/chronograf/pull/1095): Make logout button display again 1. [#1209](https://github.com/influxdata/chronograf/pull/1209): HipChat Kapacitor config now uses only the subdomain instead of asking for the entire HipChat URL. + 1. [#1219](https://github.com/influxdata/chronograf/pull/1219): Update query for default cell in new dashboard ### Features 1. [#1112](https://github.com/influxdata/chronograf/pull/1112): Add ability to delete a dashboard diff --git a/ui/src/dashboards/constants/index.js b/ui/src/dashboards/constants/index.js index 8ace203bae..418dfaf23c 100644 --- a/ui/src/dashboards/constants/index.js +++ b/ui/src/dashboards/constants/index.js @@ -24,7 +24,7 @@ export const NEW_DASHBOARD = { type: 'line', queries: [ { - query: "SELECT mean(\"usage_user\") AS \"usage_user\" FROM \"cpu\"", + query: "SELECT mean(\"usage_user\") AS \"usage_user\" FROM \"telegraf\".\"autogen\".\"cpu\"", label: "", groupbys: [], wheres: [], From 11666128605c21064a7146fe30ae51e8539684e4 Mon Sep 17 00:00:00 2001 From: lukevmorris Date: Thu, 6 Apr 2017 17:07:13 -0700 Subject: [PATCH 07/12] Dashboard comes from params, not Redux (#1218) We removed the `dashboard` key from Redux in favor of `dashboards`, which contains an array of all dashboards. This means we have to pass the current dashboard around to action creators. --- ui/src/dashboards/actions/index.js | 5 +++-- ui/src/dashboards/reducers/ui.js | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/src/dashboards/actions/index.js b/ui/src/dashboards/actions/index.js index 3258f0376e..f60b2395a3 100644 --- a/ui/src/dashboards/actions/index.js +++ b/ui/src/dashboards/actions/index.js @@ -64,9 +64,10 @@ export const syncDashboardCell = (dashboard, cell) => ({ }, }) -export const addDashboardCell = (cell) => ({ +export const addDashboardCell = (dashboard, cell) => ({ type: 'ADD_DASHBOARD_CELL', payload: { + dashboard, cell, }, }) @@ -141,7 +142,7 @@ export const deleteDashboardAsync = (dashboard) => async (dispatch) => { export const addDashboardCellAsync = (dashboard) => async (dispatch) => { try { const {data} = await addDashboardCellAJAX(dashboard, NEW_DEFAULT_DASHBOARD_CELL) - dispatch(addDashboardCell(data)) + dispatch(addDashboardCell(dashboard, data)) } catch (error) { console.error(error) throw error diff --git a/ui/src/dashboards/reducers/ui.js b/ui/src/dashboards/reducers/ui.js index 2f7b15cabd..5156c5da4a 100644 --- a/ui/src/dashboards/reducers/ui.js +++ b/ui/src/dashboards/reducers/ui.js @@ -72,15 +72,13 @@ export default function ui(state = initialState, action) { } case 'ADD_DASHBOARD_CELL': { - const {cell} = action.payload - const {dashboard, dashboards} = state + const {cell, dashboard} = action.payload + const {dashboards} = state const newCells = [cell, ...dashboard.cells] const newDashboard = {...dashboard, cells: newCells} const newDashboards = dashboards.map((d) => d.id === dashboard.id ? newDashboard : d) - const newState = { - dashboards: newDashboards, - } + const newState = {dashboards: newDashboards} return {...state, ...newState} } From 68877e07e3bb8cb1aca81a67a3eb1a56aedf7e4c Mon Sep 17 00:00:00 2001 From: lukevmorris Date: Thu, 6 Apr 2017 17:44:15 -0700 Subject: [PATCH 08/12] Fuller DefaultCell; Reference DefaultCell in DefaultDashboard (#1221) * Fuller default cell; reference cell in default dashboard * Update CHANGELOG --- CHANGELOG.md | 1 + ui/src/dashboards/constants/index.js | 34 +++++++++------------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5e8c1f7a8..9ee73a6759 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ 1. [#1113](https://github.com/influxdata/chronograf/issues/1113): Add Slack channel per Kapacitor alert. 1. [#1095](https://github.com/influxdata/chronograf/pull/1095): Add new auth duration CLI option; add client heartbeat 1. [#1168](https://github.com/influxdata/chronograf/issue/1168): Expand support for --basepath on some load balancers + 1. [#1221](https://github.com/influxdata/chronograf/issue/1221): More sensical Cell and Dashboard defaults ### UI Improvements 1. [#1101](https://github.com/influxdata/chronograf/pull/1101): Compress InfluxQL responses with gzip diff --git a/ui/src/dashboards/constants/index.js b/ui/src/dashboards/constants/index.js index 418dfaf23c..8ede7d3c04 100644 --- a/ui/src/dashboards/constants/index.js +++ b/ui/src/dashboards/constants/index.js @@ -12,29 +12,17 @@ export const EMPTY_DASHBOARD = { ], } -export const NEW_DASHBOARD = { - name: 'Name This Dashboard', - cells: [ - { - x: 0, - y: 0, - w: 4, - h: 4, - name: 'Name This Graph', - type: 'line', - queries: [ - { - query: "SELECT mean(\"usage_user\") AS \"usage_user\" FROM \"telegraf\".\"autogen\".\"cpu\"", - label: "", - groupbys: [], - wheres: [], - }, - ], - }, - ], +export const NEW_DEFAULT_DASHBOARD_CELL = { + x: 0, + y: 0, + w: 4, + h: 4, + name: 'Name This Graph', + type: 'line', + queries: [], } -export const NEW_DEFAULT_DASHBOARD_CELL = { - query: [], - type: 'line', +export const NEW_DASHBOARD = { + name: 'Name This Dashboard', + cells: [NEW_DEFAULT_DASHBOARD_CELL], } From cf054c1f791cccaa8dd67f6abb11a9d1727f8b11 Mon Sep 17 00:00:00 2001 From: John Gilden Date: Fri, 7 Apr 2017 10:02:19 +0200 Subject: [PATCH 09/12] Use the Host header from the original Kapacitor URL --- server/proxy.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/proxy.go b/server/proxy.go index 5e1a0fa850..b00709e072 100644 --- a/server/proxy.go +++ b/server/proxy.go @@ -44,6 +44,9 @@ func (h *Service) KapacitorProxy(w http.ResponseWriter, r *http.Request) { u.Path = path director := func(req *http.Request) { + // Set the Host header of the original Kapacitor URL + req.Host = u.Host + req.URL = u // Because we are acting as a proxy, kapacitor needs to have the basic auth information set as // a header directly From 3f5f82dd86b0b27373055f6a80ce755b7ea04c8f Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Fri, 7 Apr 2017 08:31:44 -0500 Subject: [PATCH 10/12] Update CHANGELOG to mention fixing https://github.com/influxdata/chronograf/issues/1206 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ee73a6759..7c33f0a35d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ 1. [#1095](https://github.com/influxdata/chronograf/pull/1095): Make logout button display again 1. [#1209](https://github.com/influxdata/chronograf/pull/1209): HipChat Kapacitor config now uses only the subdomain instead of asking for the entire HipChat URL. 1. [#1219](https://github.com/influxdata/chronograf/pull/1219): Update query for default cell in new dashboard + 1. [#1206](https://github.com/influxdata/chronograf/issues/1206): Chronograf now proxies to kapacitors behind proxy using vhost correctly. ### Features 1. [#1112](https://github.com/influxdata/chronograf/pull/1112): Add ability to delete a dashboard From 95844bbaac1e777bc26d685d447016415a06b9de Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 7 Apr 2017 09:02:16 -0700 Subject: [PATCH 11/12] Prevent dygraphs legend from going off the screen in the DE --- ui/src/shared/components/Dygraph.js | 12 ++++++++++-- ui/src/shared/components/LineGraph.js | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/src/shared/components/Dygraph.js b/ui/src/shared/components/Dygraph.js index 2d391a76b1..e27cdf4307 100644 --- a/ui/src/shared/components/Dygraph.js +++ b/ui/src/shared/components/Dygraph.js @@ -48,6 +48,7 @@ export default React.createClass({ value: string, rangeValue: string, }), + legendOnBottom: bool, }, getDefaultProps() { @@ -55,6 +56,7 @@ export default React.createClass({ containerStyle: {}, isGraphFilled: true, overrideLineColors: null, + legendOnBottom: false, } }, @@ -67,7 +69,7 @@ export default React.createClass({ componentDidMount() { const timeSeries = this.getTimeSeries() // dygraphSeries is a legend label and its corresponding y-axis e.g. {legendLabel1: 'y', legendLabel2: 'y2'}; - const {ranges, dygraphSeries, ruleValues} = this.props + const {ranges, dygraphSeries, ruleValues, legendOnBottom} = this.props const refs = this.refs const graphContainerNode = refs.graphContainer @@ -92,6 +94,7 @@ export default React.createClass({ highlightCircleSize: 3, colors: finalLineColors, series: dygraphSeries, + hideOverlayOnMouseOut: false, axes: { y: { valueRange: getRange(timeSeries, ranges.y, ruleValues), @@ -122,7 +125,12 @@ export default React.createClass({ } legendContainerNode.style.left = `${legendLeft}px` - legendContainerNode.style.top = `${legendTop}px` + if (legendOnBottom) { + legendContainerNode.style.bottom = `4px` + } else { + legendContainerNode.style.top = `${legendTop}px` + } + setMarker(points) }, unhighlightCallback() { diff --git a/ui/src/shared/components/LineGraph.js b/ui/src/shared/components/LineGraph.js index 3cd3f9dad6..ecd0a2a0df 100644 --- a/ui/src/shared/components/LineGraph.js +++ b/ui/src/shared/components/LineGraph.js @@ -67,7 +67,7 @@ export default React.createClass({ }, render() { - const {data, ranges, isFetchingInitially, isRefreshing, isGraphFilled, overrideLineColors, title, underlayCallback, queries, showSingleStat, displayOptions, ruleValues} = this.props + const {data, ranges, isFetchingInitially, isRefreshing, isGraphFilled, overrideLineColors, title, underlayCallback, queries, showSingleStat, displayOptions, ruleValues, isInDataExplorer} = this.props const {labels, timeSeries, dygraphSeries} = this._timeSeries // If data for this graph is being fetched for the first time, show a graph-wide spinner. @@ -119,6 +119,7 @@ export default React.createClass({ dygraphSeries={dygraphSeries} ranges={ranges || this.getRanges()} ruleValues={ruleValues} + legendOnBottom={isInDataExplorer ? true : null} /> {showSingleStat ?
{roundedValue}
: null} From 9c599d33b28493311597c408c9db5fd5461504ad Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 7 Apr 2017 09:09:06 -0700 Subject: [PATCH 12/12] Remove debug option --- ui/src/shared/components/Dygraph.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/src/shared/components/Dygraph.js b/ui/src/shared/components/Dygraph.js index e27cdf4307..70cfec9347 100644 --- a/ui/src/shared/components/Dygraph.js +++ b/ui/src/shared/components/Dygraph.js @@ -94,7 +94,6 @@ export default React.createClass({ highlightCircleSize: 3, colors: finalLineColors, series: dygraphSeries, - hideOverlayOnMouseOut: false, axes: { y: { valueRange: getRange(timeSeries, ranges.y, ruleValues),