From b4267eafb8fb0cd78702933eb772989cb30993d6 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Thu, 7 Feb 2019 15:43:05 +0100 Subject: [PATCH 01/14] log root cause error when reading from provisioning directories --- pkg/services/provisioning/dashboards/config_reader.go | 2 +- pkg/services/provisioning/datasources/config_reader.go | 2 +- pkg/services/provisioning/notifiers/config_reader.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/services/provisioning/dashboards/config_reader.go b/pkg/services/provisioning/dashboards/config_reader.go index fa08972961d..c57ca1c55e1 100644 --- a/pkg/services/provisioning/dashboards/config_reader.go +++ b/pkg/services/provisioning/dashboards/config_reader.go @@ -59,7 +59,7 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) { files, err := ioutil.ReadDir(cr.path) if err != nil { - cr.log.Error("can't read dashboard provisioning files from directory", "path", cr.path) + cr.log.Error("can't read dashboard provisioning files from directory", "path", cr.path, "error", err) return dashboards, nil } diff --git a/pkg/services/provisioning/datasources/config_reader.go b/pkg/services/provisioning/datasources/config_reader.go index b2930c2b679..34c1418aa98 100644 --- a/pkg/services/provisioning/datasources/config_reader.go +++ b/pkg/services/provisioning/datasources/config_reader.go @@ -19,7 +19,7 @@ func (cr *configReader) readConfig(path string) ([]*DatasourcesAsConfig, error) files, err := ioutil.ReadDir(path) if err != nil { - cr.log.Error("can't read datasource provisioning files from directory", "path", path) + cr.log.Error("can't read datasource provisioning files from directory", "path", path, "error", err) return datasources, nil } diff --git a/pkg/services/provisioning/notifiers/config_reader.go b/pkg/services/provisioning/notifiers/config_reader.go index e712e8e3eff..c1b4cbf9f29 100644 --- a/pkg/services/provisioning/notifiers/config_reader.go +++ b/pkg/services/provisioning/notifiers/config_reader.go @@ -23,7 +23,7 @@ func (cr *configReader) readConfig(path string) ([]*notificationsAsConfig, error files, err := ioutil.ReadDir(path) if err != nil { - cr.log.Error("Can't read alert notification provisioning files from directory", "path", path) + cr.log.Error("Can't read alert notification provisioning files from directory", "path", path, "error", err) return notifications, nil } From 9c18aa8684d3c3f1149a234617a7f1abcceed9cb Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Thu, 7 Feb 2019 16:10:39 +0100 Subject: [PATCH 02/14] make sure to create provisioning/notifiers directory for deb and rpm packages --- packaging/deb/control/postinst | 8 ++++++-- packaging/rpm/control/postinst | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packaging/deb/control/postinst b/packaging/deb/control/postinst index 351c966a8e6..049061ac2dd 100755 --- a/packaging/deb/control/postinst +++ b/packaging/deb/control/postinst @@ -32,10 +32,14 @@ case "$1" in fi if [ ! -f $PROVISIONING_CFG_DIR ]; then - mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources + mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources $PROVISIONING_CFG_DIR/notifiers cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml - fi + cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml + elif [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then + mkdir -p $PROVISIONING_CFG_DIR/notifiers + cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml + fi # configuration files should not be modifiable by grafana user, as this can be a security issue chown -Rh root:$GRAFANA_GROUP /etc/grafana/* diff --git a/packaging/rpm/control/postinst b/packaging/rpm/control/postinst index e75850f258e..0187fc82cc5 100755 --- a/packaging/rpm/control/postinst +++ b/packaging/rpm/control/postinst @@ -46,10 +46,14 @@ if [ $1 -eq 1 ] ; then fi if [ ! -f $PROVISIONING_CFG_DIR ]; then - mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources + mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources $PROVISIONING_CFG_DIR/notifiers cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml - fi + cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml + elif [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then + mkdir -p $PROVISIONING_CFG_DIR/notifiers + cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml + fi # Set user permissions on /var/log/grafana, /var/lib/grafana mkdir -p /var/log/grafana /var/lib/grafana From 3ce99bca66db9c059af5af5f071a940240db89c6 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 11 Feb 2019 10:50:32 +0100 Subject: [PATCH 03/14] renames usage state name for auth token as noted, sessions might not be a good name for this metrics. while devices would be a better name for users I think we should align the name with the code as much as possible. The ui listing all auth_tokens per user should probarbly say "devices" instead --- pkg/infra/usagestats/usage_stats.go | 8 ++++---- pkg/infra/usagestats/usage_stats_test.go | 6 +++--- pkg/models/stats.go | 2 +- pkg/services/sqlstore/stats.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/infra/usagestats/usage_stats.go b/pkg/infra/usagestats/usage_stats.go index b54de124335..9d7501b7765 100644 --- a/pkg/infra/usagestats/usage_stats.go +++ b/pkg/infra/usagestats/usage_stats.go @@ -59,15 +59,15 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) { metrics["stats.provisioned_dashboards.count"] = statsQuery.Result.ProvisionedDashboards metrics["stats.snapshots.count"] = statsQuery.Result.Snapshots metrics["stats.teams.count"] = statsQuery.Result.Teams - metrics["stats.total_sessions.count"] = statsQuery.Result.Sessions + metrics["stats.total_auth_token.count"] = statsQuery.Result.AuthTokens userCount := statsQuery.Result.Users - avgSessionsPerUser := statsQuery.Result.Sessions + avgAuthTokensPerUser := statsQuery.Result.AuthTokens if userCount != 0 { - avgSessionsPerUser = avgSessionsPerUser / userCount + avgAuthTokensPerUser = avgAuthTokensPerUser / userCount } - metrics["stats.avg_sessions_per_user.count"] = avgSessionsPerUser + metrics["stats.avg_auth_token_per_user.count"] = avgAuthTokensPerUser dsStats := models.GetDataSourceStatsQuery{} if err := uss.Bus.Dispatch(&dsStats); err != nil { diff --git a/pkg/infra/usagestats/usage_stats_test.go b/pkg/infra/usagestats/usage_stats_test.go index d343ed52b93..ea5b95d6ef0 100644 --- a/pkg/infra/usagestats/usage_stats_test.go +++ b/pkg/infra/usagestats/usage_stats_test.go @@ -45,7 +45,7 @@ func TestMetrics(t *testing.T) { ProvisionedDashboards: 12, Snapshots: 13, Teams: 14, - Sessions: 15, + AuthTokens: 15, } getSystemStatsQuery = query return nil @@ -229,8 +229,8 @@ func TestMetrics(t *testing.T) { So(metrics.Get("stats.provisioned_dashboards.count").MustInt(), ShouldEqual, getSystemStatsQuery.Result.ProvisionedDashboards) So(metrics.Get("stats.snapshots.count").MustInt(), ShouldEqual, getSystemStatsQuery.Result.Snapshots) So(metrics.Get("stats.teams.count").MustInt(), ShouldEqual, getSystemStatsQuery.Result.Teams) - So(metrics.Get("stats.total_sessions.count").MustInt64(), ShouldEqual, 15) - So(metrics.Get("stats.avg_sessions_per_user.count").MustInt64(), ShouldEqual, 5) + So(metrics.Get("stats.total_auth_token.count").MustInt64(), ShouldEqual, 15) + So(metrics.Get("stats.avg_auth_token_per_user.count").MustInt64(), ShouldEqual, 5) So(metrics.Get("stats.ds."+models.DS_ES+".count").MustInt(), ShouldEqual, 9) So(metrics.Get("stats.ds."+models.DS_PROMETHEUS+".count").MustInt(), ShouldEqual, 10) diff --git a/pkg/models/stats.go b/pkg/models/stats.go index 00f881f3c59..0edd204ec03 100644 --- a/pkg/models/stats.go +++ b/pkg/models/stats.go @@ -15,7 +15,7 @@ type SystemStats struct { FolderPermissions int64 Folders int64 ProvisionedDashboards int64 - Sessions int64 + AuthTokens int64 } type DataSourceStats struct { diff --git a/pkg/services/sqlstore/stats.go b/pkg/services/sqlstore/stats.go index 4c6d6c21221..2b7c35a4b4a 100644 --- a/pkg/services/sqlstore/stats.go +++ b/pkg/services/sqlstore/stats.go @@ -75,7 +75,7 @@ func GetSystemStats(query *m.GetSystemStatsQuery) error { sb.Write(`(SELECT COUNT(id) FROM ` + dialect.Quote("dashboard_provisioning") + `) AS provisioned_dashboards,`) sb.Write(`(SELECT COUNT(id) FROM ` + dialect.Quote("dashboard_snapshot") + `) AS snapshots,`) sb.Write(`(SELECT COUNT(id) FROM ` + dialect.Quote("team") + `) AS teams,`) - sb.Write(`(SELECT COUNT(id) FROM ` + dialect.Quote("user_auth_token") + `) AS sessions`) + sb.Write(`(SELECT COUNT(id) FROM ` + dialect.Quote("user_auth_token") + `) AS auth_tokens`) var stats m.SystemStats _, err := x.SQL(sb.GetSqlString(), sb.params...).Get(&stats) From 217eb6310e157ff2d1f479993acabf31e27615b9 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 11 Feb 2019 11:17:23 +0100 Subject: [PATCH 04/14] make sure notifiers dir exists for provisioning in docker --- Dockerfile | 1 + packaging/docker/Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index c3e59c8048e..9f07dc79c1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,6 +64,7 @@ RUN mkdir -p "$GF_PATHS_HOME/.aws" && \ useradd -r -u $GF_UID -g grafana grafana && \ mkdir -p "$GF_PATHS_PROVISIONING/datasources" \ "$GF_PATHS_PROVISIONING/dashboards" \ + "$GF_PATHS_PROVISIONING/notifiers" \ "$GF_PATHS_LOGS" \ "$GF_PATHS_PLUGINS" \ "$GF_PATHS_DATA" && \ diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile index d4f2f2aa7a3..d783cb14377 100644 --- a/packaging/docker/Dockerfile +++ b/packaging/docker/Dockerfile @@ -39,6 +39,7 @@ RUN mkdir -p "$GF_PATHS_HOME/.aws" && \ useradd -r -u $GF_UID -g grafana grafana && \ mkdir -p "$GF_PATHS_PROVISIONING/datasources" \ "$GF_PATHS_PROVISIONING/dashboards" \ + "$GF_PATHS_PROVISIONING/notifiers" \ "$GF_PATHS_LOGS" \ "$GF_PATHS_PLUGINS" \ "$GF_PATHS_DATA" && \ From 7ce18ec4f79c529316fcb8d101e2aa2fa22be5b9 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 11 Feb 2019 11:30:41 +0100 Subject: [PATCH 05/14] extract notifiers folder creation to new if statement --- packaging/deb/control/postinst | 7 ++++--- packaging/rpm/control/postinst | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packaging/deb/control/postinst b/packaging/deb/control/postinst index 049061ac2dd..93fa276854c 100755 --- a/packaging/deb/control/postinst +++ b/packaging/deb/control/postinst @@ -32,11 +32,12 @@ case "$1" in fi if [ ! -f $PROVISIONING_CFG_DIR ]; then - mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources $PROVISIONING_CFG_DIR/notifiers + mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml - cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml - elif [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then + fi + + if [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then mkdir -p $PROVISIONING_CFG_DIR/notifiers cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml fi diff --git a/packaging/rpm/control/postinst b/packaging/rpm/control/postinst index 0187fc82cc5..fe4429fd0d4 100755 --- a/packaging/rpm/control/postinst +++ b/packaging/rpm/control/postinst @@ -46,11 +46,12 @@ if [ $1 -eq 1 ] ; then fi if [ ! -f $PROVISIONING_CFG_DIR ]; then - mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources $PROVISIONING_CFG_DIR/notifiers + mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml - cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml - elif [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then + fi + + if [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then mkdir -p $PROVISIONING_CFG_DIR/notifiers cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml fi From 5dc864b47f7f2bc06a341f301ba0b12f804cfdbe Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 11 Feb 2019 11:36:34 +0100 Subject: [PATCH 06/14] fixes invalid folder check -f check if a file exists. -d checks if the dir exists --- packaging/deb/control/postinst | 4 ++-- packaging/rpm/control/postinst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/deb/control/postinst b/packaging/deb/control/postinst index 93fa276854c..957f8aef307 100755 --- a/packaging/deb/control/postinst +++ b/packaging/deb/control/postinst @@ -31,13 +31,13 @@ case "$1" in cp /usr/share/grafana/conf/ldap.toml /etc/grafana/ldap.toml fi - if [ ! -f $PROVISIONING_CFG_DIR ]; then + if [ ! -d $PROVISIONING_CFG_DIR ]; then mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml fi - if [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then + if [ ! -d $PROVISIONING_CFG_DIR/notifiers ]; then mkdir -p $PROVISIONING_CFG_DIR/notifiers cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml fi diff --git a/packaging/rpm/control/postinst b/packaging/rpm/control/postinst index fe4429fd0d4..cd679838487 100755 --- a/packaging/rpm/control/postinst +++ b/packaging/rpm/control/postinst @@ -45,13 +45,13 @@ if [ $1 -eq 1 ] ; then cp /usr/share/grafana/conf/ldap.toml /etc/grafana/ldap.toml fi - if [ ! -f $PROVISIONING_CFG_DIR ]; then + if [ ! -d $PROVISIONING_CFG_DIR ]; then mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml fi - if [ ! -f $PROVISIONING_CFG_DIR/notifiers ]; then + if [ ! -d $PROVISIONING_CFG_DIR/notifiers ]; then mkdir -p $PROVISIONING_CFG_DIR/notifiers cp /usr/share/grafana/conf/provisioning/notifiers/sample.yaml $PROVISIONING_CFG_DIR/notifiers/sample.yaml fi From 9485c678279762acee88bf6f2434fa0db99102cc Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Mon, 11 Feb 2019 11:47:12 +0100 Subject: [PATCH 07/14] Fix plugin loading failure message not being displayed --- .../features/dashboard/dashgrid/DashboardPanel.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx index 2d794bec4d4..b9c56e36382 100644 --- a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx @@ -68,7 +68,7 @@ export class DashboardPanel extends PureComponent { // handle plugin loading & changing of plugin type if (!this.state.plugin || this.state.plugin.id !== pluginId) { - const plugin = config.panels[pluginId] || getPanelPluginNotFound(pluginId); + let plugin = config.panels[pluginId] || getPanelPluginNotFound(pluginId); // remember if this is from an angular panel const fromAngularPanel = this.state.angularPanel != null; @@ -81,10 +81,15 @@ export class DashboardPanel extends PureComponent { } if (plugin.exports) { - this.setState({ plugin: plugin, angularPanel: null }); + this.setState({ plugin, angularPanel: null }); } else { - plugin.exports = await importPluginModule(plugin.module); - this.setState({ plugin: plugin, angularPanel: null }); + try { + plugin.exports = await importPluginModule(plugin.module); + } catch (e) { + plugin = getPanelPluginNotFound(pluginId); + } + + this.setState({ plugin, angularPanel: null }); } } } From 37a73b6b35e44189d14a32d6b19a3e5973fb7349 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 11 Feb 2019 12:04:27 +0100 Subject: [PATCH 08/14] make sure graphite takes dashboard timezone into consideration --- .../plugins/datasource/graphite/datasource.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts index a89c0ea0034..8a720cb3f35 100644 --- a/public/app/plugins/datasource/graphite/datasource.ts +++ b/public/app/plugins/datasource/graphite/datasource.ts @@ -31,8 +31,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, this.query = function(options) { const graphOptions = { - from: this.translateTime(options.rangeRaw.from, false), - until: this.translateTime(options.rangeRaw.to, true), + from: this.translateTime(options.rangeRaw.from, false, options.timezone), + until: this.translateTime(options.rangeRaw.to, true, options.timezone), targets: options.targets, format: options.format, cacheTimeout: options.cacheTimeout || this.cacheTimeout, @@ -165,9 +165,9 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, method: 'GET', url: '/events/get_data?from=' + - this.translateTime(options.range.from, false) + + this.translateTime(options.range.from, false, options.timezone) + '&until=' + - this.translateTime(options.range.to, true) + + this.translateTime(options.range.to, true, options.timezone) + tags, }); } catch (err) { @@ -179,7 +179,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, return templateSrv.variableExists(target.target); }; - this.translateTime = (date, roundUp) => { + this.translateTime = (date, roundUp, timezone) => { if (_.isString(date)) { if (date === 'now') { return 'now'; @@ -189,7 +189,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, date = date.replace('M', 'mon'); return date; } - date = dateMath.parse(date, roundUp); + date = dateMath.parse(date, roundUp, timezone); } // graphite' s from filter is exclusive @@ -255,8 +255,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, }; if (options.range) { - httpOptions.params.from = this.translateTime(options.range.from, false); - httpOptions.params.until = this.translateTime(options.range.to, true); + httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone); + httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone); } return this.doGraphiteRequest(httpOptions).then(results => { @@ -280,8 +280,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, }; if (options.range) { - httpOptions.params.from = this.translateTime(options.range.from, false); - httpOptions.params.until = this.translateTime(options.range.to, true); + httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone); + httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone); } return this.doGraphiteRequest(httpOptions).then(results => { @@ -305,8 +305,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, }; if (options.range) { - httpOptions.params.from = this.translateTime(options.range.from, false); - httpOptions.params.until = this.translateTime(options.range.to, true); + httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone); + httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone); } return this.doGraphiteRequest(httpOptions).then(results => { @@ -343,8 +343,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, httpOptions.params.limit = options.limit; } if (options.range) { - httpOptions.params.from = this.translateTime(options.range.from, false); - httpOptions.params.until = this.translateTime(options.range.to, true); + httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone); + httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone); } return this.doGraphiteRequest(httpOptions).then(results => { @@ -379,8 +379,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, httpOptions.params.limit = options.limit; } if (options.range) { - httpOptions.params.from = this.translateTime(options.range.from, false); - httpOptions.params.until = this.translateTime(options.range.to, true); + httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone); + httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone); } return this.doGraphiteRequest(httpOptions).then(results => { From 519dfd0899570999eb656063eacc678dfa9587a1 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 11 Feb 2019 13:11:56 +0100 Subject: [PATCH 09/14] make sure influx takes dashboard timezone into consideration --- public/app/plugins/datasource/influxdb/datasource.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index 8f1904dbc55..4e4c3feaebd 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -127,7 +127,7 @@ export default class InfluxDatasource { }); } - const timeFilter = this.getTimeFilter({ rangeRaw: options.rangeRaw }); + const timeFilter = this.getTimeFilter({ rangeRaw: options.rangeRaw, timezone: options.timezone }); let query = options.annotation.query.replace('$timeFilter', timeFilter); query = this.templateSrv.replace(query, null, 'regex'); @@ -184,7 +184,7 @@ export default class InfluxDatasource { } if (options && options.range) { - const timeFilter = this.getTimeFilter({ rangeRaw: options.range }); + const timeFilter = this.getTimeFilter({ rangeRaw: options.range, timezone: options.timezone }); query = query.replace('$timeFilter', timeFilter); } @@ -291,8 +291,8 @@ export default class InfluxDatasource { } getTimeFilter(options) { - const from = this.getInfluxTime(options.rangeRaw.from, false); - const until = this.getInfluxTime(options.rangeRaw.to, true); + const from = this.getInfluxTime(options.rangeRaw.from, false, options.timezone); + const until = this.getInfluxTime(options.rangeRaw.to, true, options.timezone); const fromIsAbsolute = from[from.length - 1] === 'ms'; if (until === 'now()' && !fromIsAbsolute) { @@ -302,7 +302,7 @@ export default class InfluxDatasource { return 'time >= ' + from + ' and time <= ' + until; } - getInfluxTime(date, roundUp) { + getInfluxTime(date, roundUp, timezone) { if (_.isString(date)) { if (date === 'now') { return 'now()'; @@ -314,7 +314,7 @@ export default class InfluxDatasource { const unit = parts[2]; return 'now() - ' + amount + unit; } - date = dateMath.parse(date, roundUp); + date = dateMath.parse(date, roundUp, timezone); } return date.valueOf() + 'ms'; From b9c36e5301cc80893c808e349cdcb5e97a66e156 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 11 Feb 2019 13:13:38 +0100 Subject: [PATCH 10/14] make sure opentsdb takes dashboard timezone into consideration --- public/app/plugins/datasource/opentsdb/datasource.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/opentsdb/datasource.ts b/public/app/plugins/datasource/opentsdb/datasource.ts index 772f2aa7ff9..bab86a04765 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.ts +++ b/public/app/plugins/datasource/opentsdb/datasource.ts @@ -33,8 +33,8 @@ export default class OpenTsDatasource { // Called once per panel (graph) query(options) { - const start = this.convertToTSDBTime(options.rangeRaw.from, false); - const end = this.convertToTSDBTime(options.rangeRaw.to, true); + const start = this.convertToTSDBTime(options.rangeRaw.from, false, options.timezone); + const end = this.convertToTSDBTime(options.rangeRaw.to, true, options.timezone); const qs = []; _.each(options.targets, target => { @@ -86,8 +86,8 @@ export default class OpenTsDatasource { } annotationQuery(options) { - const start = this.convertToTSDBTime(options.rangeRaw.from, false); - const end = this.convertToTSDBTime(options.rangeRaw.to, true); + const start = this.convertToTSDBTime(options.rangeRaw.from, false, options.timezone); + const end = this.convertToTSDBTime(options.rangeRaw.to, true, options.timezone); const qs = []; const eventList = []; @@ -484,12 +484,12 @@ export default class OpenTsDatasource { }); } - convertToTSDBTime(date, roundUp) { + convertToTSDBTime(date, roundUp, timezone) { if (date === 'now') { return null; } - date = dateMath.parse(date, roundUp); + date = dateMath.parse(date, roundUp, timezone); return date.valueOf(); } } From 13f21fffc4500b70afa6fd9aad2379f208968681 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 11 Feb 2019 13:35:37 +0100 Subject: [PATCH 11/14] changelog: adds note about closing #15295 [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6971f7952c..065e035128f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * **Annotations**: Support PATCH verb in annotations http api [#12546](https://github.com/grafana/grafana/issues/12546), thx [@SamuelToh](https://github.com/SamuelToh) * **Templating**: Add json formatting to variable interpolation [#15291](https://github.com/grafana/grafana/issues/15291), thx [@mtanda](https://github.com/mtanda) * **Login**: Anonymous usage stats for token auth [#15288](https://github.com/grafana/grafana/issues/15288) +* **Alerting**: Fixes crash bug when alert notifier folders are missing [#15295](https://github.com/grafana/grafana/issues/15295) ### 6.0.0-beta1 fixes From a1cd550df4a2a7aaa85ba0b7b31ad92437e58739 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 11 Feb 2019 13:42:05 +0100 Subject: [PATCH 12/14] revert ds_proxy timeout and implement dataproxy timeout correctly --- pkg/api/pluginproxy/ds_proxy.go | 2 +- pkg/models/datasource_cache.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/api/pluginproxy/ds_proxy.go b/pkg/api/pluginproxy/ds_proxy.go index a0ad96a6977..b1950998297 100644 --- a/pkg/api/pluginproxy/ds_proxy.go +++ b/pkg/api/pluginproxy/ds_proxy.go @@ -54,7 +54,7 @@ func NewDataSourceProxy(ds *m.DataSource, plugin *plugins.DataSourcePlugin, ctx func newHTTPClient() httpClient { return &http.Client{ - Timeout: time.Duration(setting.DataProxyTimeout) * time.Second, + Timeout: 30 * time.Second, Transport: &http.Transport{Proxy: http.ProxyFromEnvironment}, } } diff --git a/pkg/models/datasource_cache.go b/pkg/models/datasource_cache.go index 1c895514ace..864adb4a5a6 100644 --- a/pkg/models/datasource_cache.go +++ b/pkg/models/datasource_cache.go @@ -8,6 +8,8 @@ import ( "net/http" "sync" "time" + + "github.com/grafana/grafana/pkg/setting" ) type proxyTransportCache struct { @@ -57,7 +59,7 @@ func (ds *DataSource) GetHttpTransport() (*http.Transport, error) { TLSClientConfig: tlsConfig, Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ - Timeout: 30 * time.Second, + Timeout: time.Duration(setting.DataProxyTimeout) * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).Dial, From 77ba73449131126368eb491dc1e61982e8919a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 11 Feb 2019 13:53:07 +0100 Subject: [PATCH 13/14] Fixed issue with light theme introduced by #15333 --- public/sass/_variables.light.scss | 2 +- public/sass/components/_query_editor.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/sass/_variables.light.scss b/public/sass/_variables.light.scss index 0f4e15c91ec..97d7a374765 100644 --- a/public/sass/_variables.light.scss +++ b/public/sass/_variables.light.scss @@ -56,7 +56,7 @@ $page-bg: $gray-7; $body-color: $gray-1; $text-color: $gray-1; $text-color-strong: $dark-2; -$text-color-weak: $gray-3; +$text-color-weak: $gray-2; $text-color-faint: $gray-4; $text-color-emphasis: $dark-5; diff --git a/public/sass/components/_query_editor.scss b/public/sass/components/_query_editor.scss index b57e575dc5b..6b2e93121f5 100644 --- a/public/sass/components/_query_editor.scss +++ b/public/sass/components/_query_editor.scss @@ -124,7 +124,7 @@ input[type='text'].tight-form-func-param { &--disabled { .query-keyword { - color: darken($blue, 20%); + color: $text-color-weak; } } From 5e6c746c9b0eeda36481e72a1f8e52ccaf664634 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 11 Feb 2019 13:57:44 +0100 Subject: [PATCH 14/14] changelog: add notes about closing #15284 --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 065e035128f..9db747d6ed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Minor * **Pushover**: Adds support for images in pushover notifier [#10780](https://github.com/grafana/grafana/issues/10780), thx [@jpenalbae](https://github.com/jpenalbae) +* **Graphite/InfluxDB/OpenTSDB**: Fix always take dashboard timezone into consideration when handle custom time ranges [#15284](https://github.com/grafana/grafana/issues/15284) * **Stackdriver**: Template variables in filters using globbing format [#15182](https://github.com/grafana/grafana/issues/15182) * **Cloudwatch**: Add `resource_arns` template variable query function [#8207](https://github.com/grafana/grafana/issues/8207), thx [@jeroenvollenbrock](https://github.com/jeroenvollenbrock) * **Cloudwatch**: Add AWS/Neptune metrics [#14231](https://github.com/grafana/grafana/issues/14231), thx [@tcpatterson](https://github.com/tcpatterson) @@ -96,7 +97,7 @@ * **Stackdriver**: Fixes issue with data proxy and Authorization header [#14262](https://github.com/grafana/grafana/issues/14262) * **Units**: fixedUnit for Flow:l/min and mL/min [#14294](https://github.com/grafana/grafana/issues/14294), thx [@flopp999](https://github.com/flopp999). * **Logging**: Fix for issue where data proxy logged a secret when debug logging was enabled, now redacted. [#14319](https://github.com/grafana/grafana/issues/14319) -* **InfluxDB**: Add support for alerting on InfluxDB queries that use the cumulative_sum function. [#14314](https://github.com/grafana/grafana/pull/14314), thx [@nitti](https://github.com/nitti) +* TSDB**: Fix always take dashboard timezone into consideration when handle custom time ranges**: Add support for alerting on InfluxDB queries that use the cumulative_sum function. [#14314](https://github.com/grafana/grafana/pull/14314), thx [@nitti](https://github.com/nitti) * **Plugins**: Panel plugins should no receive the panel-initialized event again as usual. * **Embedded Graphs**: Iframe graph panels should now work as usual. [#14284](https://github.com/grafana/grafana/issues/14284) * **Postgres**: Improve PostgreSQL Query Editor if using different Schemas, [#14313]( @@ -1031,7 +1032,7 @@ Pull Request: [#8472](https://github.com/grafana/grafana/pull/8472) * **Docs**: Added some details about Sessions in Postgres [#7694](https://github.com/grafana/grafana/pull/7694) thx [@rickard-von-essen](https://github.com/rickard-von-essen) * **Influxdb**: Allow commas in template variables [#7681](https://github.com/grafana/grafana/issues/7681) thx [@thuck](https://github.com/thuck) * **Cloudwatch**: stop using deprecated session.New() [#7736](https://github.com/grafana/grafana/issues/7736) thx [@mtanda](https://github.com/mtanda) -* **OpenTSDB**: Pass dropcounter rate option if no max counter and no reset value or reset value as 0 is specified [#7743](https://github.com/grafana/grafana/pull/7743) thx [@r4um](https://github.com/r4um) +*TSDB**: Fix always take dashboard timezone into consideration when handle custom time ranges**: Pass dropcounter rate option if no max counter and no reset value or reset value as 0 is specified [#7743](https://github.com/grafana/grafana/pull/7743) thx [@r4um](https://github.com/r4um) * **Templating**: support full resolution for $interval variable [#7696](https://github.com/grafana/grafana/pull/7696) thx [@mtanda](https://github.com/mtanda) * **Elasticsearch**: Unique Count on string fields in ElasticSearch [#3536](https://github.com/grafana/grafana/issues/3536), thx [@pyro2927](https://github.com/pyro2927) * **Templating**: Data source template variable that refers to other variable in regex filter [#6365](https://github.com/grafana/grafana/issues/6365) thx [@rlodge](https://github.com/rlodge)