From 3fab4d6f8caa15790b4f8a6103a0998a56ce348c Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 13 Feb 2019 19:52:27 +0100 Subject: [PATCH 01/16] docs: fix typo --- docs/sources/auth/overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/auth/overview.md b/docs/sources/auth/overview.md index 1d0b0d89b3fa0..fc22d6b2d7fb7 100644 --- a/docs/sources/auth/overview.md +++ b/docs/sources/auth/overview.md @@ -38,7 +38,7 @@ provider (listed above). There is also options for allowing self sign up. ### Login and short-lived tokens -> The followung applies when using Grafana's built in user authentication, LDAP (without Auth proxy) or OAuth integration. +> The following applies when using Grafana's built in user authentication, LDAP (without Auth proxy) or OAuth integration. Grafana are using short-lived tokens as a mechanism for verifying authenticated users. These short-lived tokens are rotated each `token_rotation_interval_minutes` for an active authenticated user. From 592f57d0ba5487f8c6621a98cae5446f435ded67 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 13 Feb 2019 19:53:25 +0100 Subject: [PATCH 02/16] docs: add note regarding auth proxy and user session requirement --- docs/sources/tutorials/ha_setup.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sources/tutorials/ha_setup.md b/docs/sources/tutorials/ha_setup.md index f141392e2232e..3464f1244587f 100644 --- a/docs/sources/tutorials/ha_setup.md +++ b/docs/sources/tutorials/ha_setup.md @@ -26,6 +26,8 @@ Grafana will now persist all long term data in the database. How to configure th ## User sessions +> Beginning with Grafana v6.0 and above the following only applies when using [Auth Proxy Authentication](/auth/auth-proxy/). + The second thing to consider is how to deal with user sessions and how to configure your load balancer in front of Grafana. Grafana supports two ways of storing session data: locally on disk or in a database/cache-server. If you want to store sessions on disk you can use `sticky sessions` in your load balancer. If you prefer to store session data in a database/cache-server From 1bd9573f8ec9a40dd87f79f5fa103bff10fa6593 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 13 Feb 2019 19:53:55 +0100 Subject: [PATCH 03/16] docs: add upgrade notes for v6.0 --- docs/sources/installation/upgrading.md | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/sources/installation/upgrading.md b/docs/sources/installation/upgrading.md index a476a38c3c5a3..18c6cb649b182 100644 --- a/docs/sources/installation/upgrading.md +++ b/docs/sources/installation/upgrading.md @@ -117,3 +117,32 @@ One of the database migrations included in this release will update all annotati We've got one report where using systemd, PostgreSQL and a large amount of annotations (table size 1645mb) took 8-20 minutes for the database migration to complete. However, the grafana-server process was killed after 90 seconds by systemd. Any database migration queries in progress when systemd kills the grafana-server process continues to execute in database until finished. If you're using systemd and have a large amount of annotations consider temporary adjusting the systemd `TimeoutStartSec` setting to something high like `30m` before upgrading. + +## Upgrading to v6.0 + +If you have text panels with script tags they will no longer work due to a new setting that per default disallow unsanitzied HTML. +Read more [here](/installation/configuration/#disable-sanitize-html) about this new setting. + +### Authentication and security + +If your using Grafana's builtin, LDAP (without Auth Proxy) or OAuth authentication all users will be required to login upon the next visit after the upgrade. + +If you have `cookie_secure` set to `true` in the `session` section you probably want to change the `cookie_secure` to `true` in the `security` section as well. Ending up with a configuration like this: + +```ini +[session] +cookie_secure = true + +[security] +cookie_secure = true +``` + +The `login_remember_days`, `cookie_username` and `cookie_remember_name` settings in the `security` section are no longer being used so they're safe to remove. + +If you have `login_remember_days` configured to 0 (zero) you should change your configuration to this to accomplish similar behavior, i.e. a logged in user will maximum be logged in for 1 day until being forced to login again: + +```ini +[auth] +login_maximum_inactive_lifetime_days = 1 +login_maximum_lifetime_days = 1 +``` From de2f3db4130c4afc6b57cdb614151e21060daeed Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Wed, 13 Feb 2019 19:54:45 +0100 Subject: [PATCH 04/16] docs: improve removal of session storage for what's new in v6.0 --- docs/sources/guides/whats-new-in-v6-0.md | 32 +++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/docs/sources/guides/whats-new-in-v6-0.md b/docs/sources/guides/whats-new-in-v6-0.md index 61eec0ac390a1..2cf267230626a 100644 --- a/docs/sources/guides/whats-new-in-v6-0.md +++ b/docs/sources/guides/whats-new-in-v6-0.md @@ -27,6 +27,7 @@ The main highlights are: - [Azure Monitor]({{< relref "#azure-monitor-datasource" >}}) plugin is ported from being an external plugin to being a core datasource - [React Plugin]({{< relref "#react-panels-query-editors" >}}) support enables an easier way to build plugins. - [Named Colors]({{< relref "#named-colors" >}}) in our new improved color picker. +- [Removal of user session storage]({{< relref "#easier-to-deploy-more-secure" >}}) makes Grafana easier to deploy & more secure. ## Explore @@ -113,30 +114,39 @@ will be shared closer to or just after release. {{< docs-imagebox img="/img/docs/v60/react_panels.png" max-width="600px" caption="React Panel" >}}
-### Google Stackdriver Datasource +## Google Stackdriver Datasource Built-in support for [Google Stackdriver](https://cloud.google.com/stackdriver/) is officially released in Grafana 6.0. Beta support was added in Grafana 5.3 and we have added lots of improvements since then. To get started read the guide: [Using Google Stackdriver in Grafana](/features/datasources/stackdriver/). -### Azure Monitor Datasource +## Azure Monitor Datasource One of the goals of the Grafana v6.0 release is to add support for the three major clouds. Amazon Cloudwatch has been a core datasource for years and Google Stackdriver is also now supported. We developed an external plugin for Azure Monitor last year and for this release the [plugin](https://grafana.com/plugins/grafana-azure-monitor-datasource) is being moved into Grafana to be one of the built-in datasources. For users of the external plugin, Grafana will automatically start using the built-in version. As a core datasource, the Azure Monitor datasource will get alerting support for the official 6.0 release. The Azure Monitor datasource integrates four Azure services with Grafana - Azure Monitor, Azure Log Analytics, Azure Application Insights and Azure Application Insights Analytics. -### Provisioning support for alert notifiers +## Provisioning support for alert notifiers Grafana now added support for provisioning alert notifiers from configuration files. Allowing operators to provision notifiers without using the UI or the API. A new field called `uid` has been introduced which is a string identifier that the administrator can set themselves. Same kind of identifier used for dashboards since v5.0. This feature makes it possible to use the same notifier configuration in multiple environments and refer to notifiers in dashboard json by a string identifier instead of the numeric id which depends on insert order and how many notifiers that exists in the instance. -### Auth and session token improvements +## Easier to deploy & more secure -The previous session storage implementation in Grafana was causing problems in larger HA setups due to too many write requests to the database. The remember me token also have several security issues which is why we decided to rewrite auth middleware in Grafana and remove the session storage since most operations using the session storage could be rewritten to use cookies or data already made available earlier in the request. -If you are using `Auth proxy` for authentication the session storage will still be used but our goal is to remove this ASAP as well. +Grafana 6.0 removes the need of configuring and setup of additional storage for [user sessions](/tutorials/ha_setup/#user-sessions). This should make it easier to deploy and operate Grafana in a +high availability setup and/or if you're using a stateless user session storage like Redis, Memcache, Postgres or MySQL. -This release will force all users to log in again since their previous token is not valid anymore. +Instead of user sessions a solution based on short-lived tokens that are rotated frequently have been implemented. This also replaces the old "remember me cookie" +solution, which allowed a user to be logged in between browser sessions, and which have been subject to several security holes throughout the years. +Read more about the short-lived token solution and how to configure it [here](/auth/overview/#login-and-short-lived-tokens). -### Named Colors +> Please note that due to these changes, all users will be required to login upon next visit after upgrade. + +Besides these changes there have also been security improvements regarding protection against Cross-Site Request Forgery (CSRF) and Cross-site Scripting (XSS) attacks. + +> If you're using [Auth Proxy Authentication](/auth/auth-proxy/) you still need to have user sessions setup and configured +but our goal is to remove this requirements in a near future. + +## Named Colors {{< docs-imagebox img="/img/docs/v60/named_colors.png" max-width="400px" class="docs-image--right" caption="Named Colors" >}} @@ -148,12 +158,16 @@ Named colors also enables Grafana to adapt colors to the current theme.
-### Other features +## Other features - The ElasticSearch datasource now supports [bucket script pipeline aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html). This gives the ability to do per bucket computations like the difference or ratio between two metrics. - Support for Google Hangouts Chat alert notifications - New built in template variables for the current time range in `$__from` and `$__to` +## Upgrading + +See [upgrade notes](/installation/upgrading/#upgrading-to-v6-0). + ## Changelog Checkout the [CHANGELOG.md](https://github.com/grafana/grafana/blob/master/CHANGELOG.md) file for a complete list of new features, changes, and bug fixes. From 7f7cc85ef0b0319a12cb02aa541952414c14f154 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 14 Feb 2019 13:24:41 +0100 Subject: [PATCH 05/16] docs: adds note about new login cookie name --- docs/sources/installation/upgrading.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sources/installation/upgrading.md b/docs/sources/installation/upgrading.md index 18c6cb649b182..d230efb188896 100644 --- a/docs/sources/installation/upgrading.md +++ b/docs/sources/installation/upgrading.md @@ -146,3 +146,5 @@ If you have `login_remember_days` configured to 0 (zero) you should change your login_maximum_inactive_lifetime_days = 1 login_maximum_lifetime_days = 1 ``` + +The default cookie name for storing the auth token is `grafana_sess`. you can configure this with `login_cookie_name` in `[auth]` settings. \ No newline at end of file From 933d4729db6062b99ad614316aa63312e8e6f6a1 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 14 Feb 2019 14:06:50 +0100 Subject: [PATCH 06/16] docs: mention samesite setting --- docs/sources/guides/whats-new-in-v6-0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/guides/whats-new-in-v6-0.md b/docs/sources/guides/whats-new-in-v6-0.md index 2cf267230626a..e411704f75713 100644 --- a/docs/sources/guides/whats-new-in-v6-0.md +++ b/docs/sources/guides/whats-new-in-v6-0.md @@ -130,7 +130,7 @@ The Azure Monitor datasource integrates four Azure services with Grafana - Azure Grafana now added support for provisioning alert notifiers from configuration files. Allowing operators to provision notifiers without using the UI or the API. A new field called `uid` has been introduced which is a string identifier that the administrator can set themselves. Same kind of identifier used for dashboards since v5.0. This feature makes it possible to use the same notifier configuration in multiple environments and refer to notifiers in dashboard json by a string identifier instead of the numeric id which depends on insert order and how many notifiers that exists in the instance. -## Easier to deploy & more secure +## Easier to deploy & more secure authentication Grafana 6.0 removes the need of configuring and setup of additional storage for [user sessions](/tutorials/ha_setup/#user-sessions). This should make it easier to deploy and operate Grafana in a high availability setup and/or if you're using a stateless user session storage like Redis, Memcache, Postgres or MySQL. @@ -141,7 +141,7 @@ Read more about the short-lived token solution and how to configure it [here](/a > Please note that due to these changes, all users will be required to login upon next visit after upgrade. -Besides these changes there have also been security improvements regarding protection against Cross-Site Request Forgery (CSRF) and Cross-site Scripting (XSS) attacks. +Besides these changes we have also introduced [SameSite](https://www.owasp.org/index.php/SameSite) setting to protect against Cross-Site Request Forgery (CSRF) and Cross-site Scripting (XSS) attacks. This setting enables more control of when the browser include cookies in requests. Its set to `lax` by default but can be configured using `cookie_samesite` under `[security]` > If you're using [Auth Proxy Authentication](/auth/auth-proxy/) you still need to have user sessions setup and configured but our goal is to remove this requirements in a near future. From 94c1335f1101c5f177536c76c925ff6c13ffc775 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 14 Feb 2019 14:17:02 +0100 Subject: [PATCH 07/16] docs: move alerting above session --- docs/sources/tutorials/ha_setup.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/sources/tutorials/ha_setup.md b/docs/sources/tutorials/ha_setup.md index 3464f1244587f..f20a9933126e5 100644 --- a/docs/sources/tutorials/ha_setup.md +++ b/docs/sources/tutorials/ha_setup.md @@ -15,7 +15,7 @@ Setting up Grafana for high availability is fairly simple. It comes down to two 2. Decide how to store session data.
- +
## Configure multiple servers to use the same database @@ -24,6 +24,10 @@ First, you need to do is to setup MySQL or Postgres on another server and config You can find the configuration for doing that in the [[database]]({{< relref "configuration.md" >}}#database) section in the grafana config. Grafana will now persist all long term data in the database. How to configure the database for high availability is out of scope for this guide. We recommend finding an expert on for the database you're using. +## Alerting + +Currently alerting supports a limited form of high availability. Since v4.2.0, alert notifications are deduped when running multiple servers. This means all alerts are executed on every server but alert notifications are only sent once per alert. Grafana does not support load distribution between servers. + ## User sessions > Beginning with Grafana v6.0 and above the following only applies when using [Auth Proxy Authentication](/auth/auth-proxy/). @@ -43,6 +47,4 @@ If you use MySQL/Postgres for session storage, you first need a table to store t For Grafana itself it doesn't really matter if you store the session data on disk or database/redis/memcache. But we recommend using a database/redis/memcache since it makes it easier manage the grafana servers. -## Alerting -Currently alerting supports a limited form of high availability. Since v4.2.0, alert notifications are deduped when running multiple servers. This means all alerts are executed on every server but alert notifications are only sent once per alert. Grafana does not support distributing the alert rule execution between servers. That might be added in the future but right now prefer to keep it simple. From 3c2f6094b2a90676558f4c4c58d2871bedd2b0df Mon Sep 17 00:00:00 2001 From: Maxim Neverov Date: Thu, 14 Feb 2019 16:31:15 +0100 Subject: [PATCH 08/16] Fix percent_diff calculation when points are nulls --- pkg/services/alerting/conditions/reducer.go | 19 +++++++++++-------- .../alerting/conditions/reducer_test.go | 12 ++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pkg/services/alerting/conditions/reducer.go b/pkg/services/alerting/conditions/reducer.go index 1e8ae79274668..485ea43561bd7 100644 --- a/pkg/services/alerting/conditions/reducer.go +++ b/pkg/services/alerting/conditions/reducer.go @@ -131,14 +131,17 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float { break } } - // get the oldest point - points = points[0:i] - for i := 0; i < len(points); i++ { - if points[i][0].Valid { - allNull = false - val := (first - points[i][0].Float64) / points[i][0].Float64 * 100 - value = math.Abs(val) - break + + if i >= 1 { + // get the oldest point + points = points[0:i] + for i := 0; i < len(points); i++ { + if points[i][0].Valid { + allNull = false + val := (first - points[i][0].Float64) / points[i][0].Float64 * 100 + value = math.Abs(val) + break + } } } case "count_non_null": diff --git a/pkg/services/alerting/conditions/reducer_test.go b/pkg/services/alerting/conditions/reducer_test.go index 7f11fc498bde8..70b03f1dba8eb 100644 --- a/pkg/services/alerting/conditions/reducer_test.go +++ b/pkg/services/alerting/conditions/reducer_test.go @@ -157,6 +157,18 @@ func TestSimpleReducer(t *testing.T) { result := testReducer("percent_diff", 30, 40, 40) So(result, ShouldEqual, float64(33.33333333333333)) }) + + Convey("percent_diff with only nulls", func() { + reducer := NewSimpleReducer("percent_diff") + series := &tsdb.TimeSeries{ + Name: "test time serie", + } + + series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 1)) + series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 2)) + + So(reducer.Reduce(series).Valid, ShouldEqual, false) + }) }) } From 191f9c8407220f2702c1fb43d1b2134629bc8bef Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 14 Feb 2019 19:42:39 +0100 Subject: [PATCH 09/16] whats new: rename security section --- docs/sources/guides/whats-new-in-v6-0.md | 8 +++++--- docs/sources/installation/upgrading.md | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/sources/guides/whats-new-in-v6-0.md b/docs/sources/guides/whats-new-in-v6-0.md index e411704f75713..656e563a7f8b6 100644 --- a/docs/sources/guides/whats-new-in-v6-0.md +++ b/docs/sources/guides/whats-new-in-v6-0.md @@ -27,7 +27,7 @@ The main highlights are: - [Azure Monitor]({{< relref "#azure-monitor-datasource" >}}) plugin is ported from being an external plugin to being a core datasource - [React Plugin]({{< relref "#react-panels-query-editors" >}}) support enables an easier way to build plugins. - [Named Colors]({{< relref "#named-colors" >}}) in our new improved color picker. -- [Removal of user session storage]({{< relref "#easier-to-deploy-more-secure" >}}) makes Grafana easier to deploy & more secure. +- [Removal of user session storage]({{< relref "#easier-to-deploy-improved security" >}}) makes Grafana easier to deploy & improved security. ## Explore @@ -130,7 +130,7 @@ The Azure Monitor datasource integrates four Azure services with Grafana - Azure Grafana now added support for provisioning alert notifiers from configuration files. Allowing operators to provision notifiers without using the UI or the API. A new field called `uid` has been introduced which is a string identifier that the administrator can set themselves. Same kind of identifier used for dashboards since v5.0. This feature makes it possible to use the same notifier configuration in multiple environments and refer to notifiers in dashboard json by a string identifier instead of the numeric id which depends on insert order and how many notifiers that exists in the instance. -## Easier to deploy & more secure authentication +## Easier to deploy & improved security Grafana 6.0 removes the need of configuring and setup of additional storage for [user sessions](/tutorials/ha_setup/#user-sessions). This should make it easier to deploy and operate Grafana in a high availability setup and/or if you're using a stateless user session storage like Redis, Memcache, Postgres or MySQL. @@ -141,11 +141,13 @@ Read more about the short-lived token solution and how to configure it [here](/a > Please note that due to these changes, all users will be required to login upon next visit after upgrade. -Besides these changes we have also introduced [SameSite](https://www.owasp.org/index.php/SameSite) setting to protect against Cross-Site Request Forgery (CSRF) and Cross-site Scripting (XSS) attacks. This setting enables more control of when the browser include cookies in requests. Its set to `lax` by default but can be configured using `cookie_samesite` under `[security]` +Besides these changes we have also introduced [SameSite](https://www.owasp.org/index.php/SameSite) setting to protect against Cross-Site Request Forgery (CSRF). This setting enables more control of when the browser include cookies in requests. Its set to `lax` by default but can be configured using `cookie_samesite` under `[security]` > If you're using [Auth Proxy Authentication](/auth/auth-proxy/) you still need to have user sessions setup and configured but our goal is to remove this requirements in a near future. +We also disable script tags in text panels by defult to avoid Cross-site Scripting (XSS) attacks. + ## Named Colors {{< docs-imagebox img="/img/docs/v60/named_colors.png" max-width="400px" class="docs-image--right" caption="Named Colors" >}} diff --git a/docs/sources/installation/upgrading.md b/docs/sources/installation/upgrading.md index d230efb188896..e235f25b9e940 100644 --- a/docs/sources/installation/upgrading.md +++ b/docs/sources/installation/upgrading.md @@ -147,4 +147,4 @@ login_maximum_inactive_lifetime_days = 1 login_maximum_lifetime_days = 1 ``` -The default cookie name for storing the auth token is `grafana_sess`. you can configure this with `login_cookie_name` in `[auth]` settings. \ No newline at end of file +The default cookie name for storing the auth token is `grafana_session`. you can configure this with `login_cookie_name` in `[auth]` settings. \ No newline at end of file From af5a2468e88bffbe6fc7412c4a859b51af0feb82 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 14 Feb 2019 20:18:24 +0100 Subject: [PATCH 10/16] fix spelling error --- docs/sources/guides/whats-new-in-v6-0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/guides/whats-new-in-v6-0.md b/docs/sources/guides/whats-new-in-v6-0.md index 656e563a7f8b6..e789b6e71b26f 100644 --- a/docs/sources/guides/whats-new-in-v6-0.md +++ b/docs/sources/guides/whats-new-in-v6-0.md @@ -146,7 +146,7 @@ Besides these changes we have also introduced [SameSite](https://www.owasp.org/i > If you're using [Auth Proxy Authentication](/auth/auth-proxy/) you still need to have user sessions setup and configured but our goal is to remove this requirements in a near future. -We also disable script tags in text panels by defult to avoid Cross-site Scripting (XSS) attacks. +We also disable script tags in text panels by default to avoid Cross-site Scripting (XSS) attacks. ## Named Colors From 28eaac3a9c7082e8c496005c1cb66b4b70a4f82f Mon Sep 17 00:00:00 2001 From: Maxim Neverov Date: Thu, 14 Feb 2019 21:52:59 +0100 Subject: [PATCH 11/16] Extracted common code for diff calculation --- pkg/services/alerting/conditions/reducer.go | 87 +++++++++---------- .../alerting/conditions/reducer_test.go | 12 +++ 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/pkg/services/alerting/conditions/reducer.go b/pkg/services/alerting/conditions/reducer.go index 485ea43561bd7..f55545be311f0 100644 --- a/pkg/services/alerting/conditions/reducer.go +++ b/pkg/services/alerting/conditions/reducer.go @@ -95,55 +95,9 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float { } } case "diff": - var ( - points = series.Points - first float64 - i int - ) - // get the newest point - for i = len(points) - 1; i >= 0; i-- { - if points[i][0].Valid { - allNull = false - first = points[i][0].Float64 - break - } - } - // get the oldest point - points = points[0:i] - for i := 0; i < len(points); i++ { - if points[i][0].Valid { - allNull = false - value = first - points[i][0].Float64 - break - } - } + allNull, value = calculateDiff(series, allNull, value, diff) case "percent_diff": - var ( - points = series.Points - first float64 - i int - ) - // get the newest point - for i = len(points) - 1; i >= 0; i-- { - if points[i][0].Valid { - allNull = false - first = points[i][0].Float64 - break - } - } - - if i >= 1 { - // get the oldest point - points = points[0:i] - for i := 0; i < len(points); i++ { - if points[i][0].Valid { - allNull = false - val := (first - points[i][0].Float64) / points[i][0].Float64 * 100 - value = math.Abs(val) - break - } - } - } + allNull, value = calculateDiff(series, allNull, value, percentDiff) case "count_non_null": for _, v := range series.Points { if v[0].Valid { @@ -166,3 +120,40 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float { func NewSimpleReducer(typ string) *SimpleReducer { return &SimpleReducer{Type: typ} } + +func calculateDiff(series *tsdb.TimeSeries, allNull bool, value float64, fn func(float64, float64) float64) (bool, float64) { + var ( + points = series.Points + first float64 + i int + ) + // get the newest point + for i = len(points) - 1; i >= 0; i-- { + if points[i][0].Valid { + allNull = false + first = points[i][0].Float64 + break + } + } + if i >= 1 { + // get the oldest point + points = points[0:i] + for i := 0; i < len(points); i++ { + if points[i][0].Valid { + allNull = false + val := fn(first, points[i][0].Float64) + value = math.Abs(val) + break + } + } + } + return allNull, value +} + +var diff = func(newest, oldest float64) float64 { + return newest - oldest +} + +var percentDiff = func(newest, oldest float64) float64 { + return (newest - oldest) / oldest * 100 +} diff --git a/pkg/services/alerting/conditions/reducer_test.go b/pkg/services/alerting/conditions/reducer_test.go index 70b03f1dba8eb..d2c21771d0b1b 100644 --- a/pkg/services/alerting/conditions/reducer_test.go +++ b/pkg/services/alerting/conditions/reducer_test.go @@ -143,6 +143,18 @@ func TestSimpleReducer(t *testing.T) { So(result, ShouldEqual, float64(10)) }) + Convey("diff with only nulls", func() { + reducer := NewSimpleReducer("diff") + series := &tsdb.TimeSeries{ + Name: "test time serie", + } + + series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 1)) + series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 2)) + + So(reducer.Reduce(series).Valid, ShouldEqual, false) + }) + Convey("percent_diff one point", func() { result := testReducer("percent_diff", 40) So(result, ShouldEqual, float64(0)) From d6de40cbe69bf884632b3412b7875fc689665f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 15 Feb 2019 10:49:10 +0100 Subject: [PATCH 12/16] Added missing strict type checking options to grafana/ui and fixed type errors --- .../grafana-ui/src/components/Graph/Graph.tsx | 2 +- packages/grafana-ui/src/themes/index.ts | 2 +- .../valueFormats/arithmeticFormatters.ts | 14 ++--- .../utils/valueFormats/dateTimeFormatters.ts | 63 ++++++++++++------- .../utils/valueFormats/symbolFormatters.ts | 4 +- .../src/utils/valueFormats/valueFormats.ts | 47 ++++++++------ packages/grafana-ui/tsconfig.json | 14 ++--- 7 files changed, 85 insertions(+), 61 deletions(-) diff --git a/packages/grafana-ui/src/components/Graph/Graph.tsx b/packages/grafana-ui/src/components/Graph/Graph.tsx index ad038cebcdadf..d380ad26b68c0 100644 --- a/packages/grafana-ui/src/components/Graph/Graph.tsx +++ b/packages/grafana-ui/src/components/Graph/Graph.tsx @@ -22,7 +22,7 @@ export class Graph extends PureComponent { showBars: false, }; - element: HTMLElement | null; + element: HTMLElement | null = null; componentDidUpdate() { this.draw(); diff --git a/packages/grafana-ui/src/themes/index.ts b/packages/grafana-ui/src/themes/index.ts index c0d9a4f2d32ae..1d8d2f62606ce 100644 --- a/packages/grafana-ui/src/themes/index.ts +++ b/packages/grafana-ui/src/themes/index.ts @@ -6,7 +6,7 @@ let themeMock: ((name?: string) => GrafanaTheme) | null; export let getTheme = (name?: string) => (themeMock && themeMock(name)) || (name === 'light' ? lightTheme : darkTheme); -export const mockTheme = (mock: (name: string) => GrafanaTheme) => { +export const mockTheme = (mock: (name?: string) => GrafanaTheme) => { themeMock = mock; return () => { themeMock = null; diff --git a/packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.ts b/packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.ts index fa9daf0fb97e7..8ff5a1ff5e7e2 100644 --- a/packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.ts +++ b/packages/grafana-ui/src/utils/valueFormats/arithmeticFormatters.ts @@ -1,20 +1,20 @@ -import { toFixed } from './valueFormats'; +import { toFixed, DecimalCount } from './valueFormats'; -export function toPercent(size: number, decimals: number) { +export function toPercent(size: number, decimals: DecimalCount) { if (size === null) { return ''; } return toFixed(size, decimals) + '%'; } -export function toPercentUnit(size: number, decimals: number) { +export function toPercentUnit(size: number, decimals: DecimalCount) { if (size === null) { return ''; } return toFixed(100 * size, decimals) + '%'; } -export function toHex0x(value: number, decimals: number) { +export function toHex0x(value: number, decimals: DecimalCount) { if (value == null) { return ''; } @@ -25,7 +25,7 @@ export function toHex0x(value: number, decimals: number) { return '0x' + hexString; } -export function toHex(value: number, decimals: number) { +export function toHex(value: number, decimals: DecimalCount) { if (value == null) { return ''; } @@ -34,9 +34,9 @@ export function toHex(value: number, decimals: number) { .toUpperCase(); } -export function sci(value: number, decimals: number) { +export function sci(value: number, decimals: DecimalCount) { if (value == null) { return ''; } - return value.toExponential(decimals); + return value.toExponential(decimals as number); } diff --git a/packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.ts b/packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.ts index 1e07857eb66e0..819b73586d52d 100644 --- a/packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.ts +++ b/packages/grafana-ui/src/utils/valueFormats/dateTimeFormatters.ts @@ -1,4 +1,4 @@ -import { toFixed, toFixedScaled } from './valueFormats'; +import { toFixed, toFixedScaled, DecimalCount } from './valueFormats'; import moment from 'moment'; interface IntervalsInSeconds { @@ -27,7 +27,7 @@ const INTERVALS_IN_SECONDS: IntervalsInSeconds = { [Interval.Millisecond]: 0.001, }; -export function toNanoSeconds(size: number, decimals: number, scaledDecimals: number) { +export function toNanoSeconds(size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) { if (size === null) { return ''; } @@ -45,7 +45,7 @@ export function toNanoSeconds(size: number, decimals: number, scaledDecimals: nu } } -export function toMicroSeconds(size: number, decimals: number, scaledDecimals: number) { +export function toMicroSeconds(size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) { if (size === null) { return ''; } @@ -59,7 +59,7 @@ export function toMicroSeconds(size: number, decimals: number, scaledDecimals: n } } -export function toMilliSeconds(size: number, decimals: number, scaledDecimals: number) { +export function toMilliSeconds(size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) { if (size === null) { return ''; } @@ -83,22 +83,29 @@ export function toMilliSeconds(size: number, decimals: number, scaledDecimals: n return toFixedScaled(size / 31536000000, decimals, scaledDecimals, 10, ' year'); } -export function toSeconds(size: number, decimals: number, scaledDecimals: number) { +export function trySubstract(value1: DecimalCount, value2: DecimalCount): DecimalCount { + if (value1 !== null && value1 !== undefined && value2 !== null && value2 !== undefined) { + return value1 - value2; + } + return undefined; +} + +export function toSeconds(size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) { if (size === null) { return ''; } // Less than 1 µs, divide in ns if (Math.abs(size) < 0.000001) { - return toFixedScaled(size * 1e9, decimals, scaledDecimals - decimals, -9, ' ns'); + return toFixedScaled(size * 1e9, decimals, trySubstract(scaledDecimals, decimals), -9, ' ns'); } // Less than 1 ms, divide in µs if (Math.abs(size) < 0.001) { - return toFixedScaled(size * 1e6, decimals, scaledDecimals - decimals, -6, ' µs'); + return toFixedScaled(size * 1e6, decimals, trySubstract(scaledDecimals, decimals), -6, ' µs'); } // Less than 1 second, divide in ms if (Math.abs(size) < 1) { - return toFixedScaled(size * 1e3, decimals, scaledDecimals - decimals, -3, ' ms'); + return toFixedScaled(size * 1e3, decimals, trySubstract(scaledDecimals, decimals), -3, ' ms'); } if (Math.abs(size) < 60) { @@ -120,7 +127,7 @@ export function toSeconds(size: number, decimals: number, scaledDecimals: number return toFixedScaled(size / 3.15569e7, decimals, scaledDecimals, 7, ' year'); } -export function toMinutes(size: number, decimals: number, scaledDecimals: number) { +export function toMinutes(size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) { if (size === null) { return ''; } @@ -138,7 +145,7 @@ export function toMinutes(size: number, decimals: number, scaledDecimals: number } } -export function toHours(size: number, decimals: number, scaledDecimals: number) { +export function toHours(size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) { if (size === null) { return ''; } @@ -154,7 +161,7 @@ export function toHours(size: number, decimals: number, scaledDecimals: number) } } -export function toDays(size: number, decimals: number, scaledDecimals: number) { +export function toDays(size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) { if (size === null) { return ''; } @@ -168,13 +175,15 @@ export function toDays(size: number, decimals: number, scaledDecimals: number) { } } -export function toDuration(size: number, decimals: number, timeScale: Interval): string { +export function toDuration(size: number, decimals: DecimalCount, timeScale: Interval): string { if (size === null) { return ''; } + if (size === 0) { return '0 ' + timeScale + 's'; } + if (size < 0) { return toDuration(-size, decimals, timeScale) + ' ago'; } @@ -189,14 +198,22 @@ export function toDuration(size: number, decimals: number, timeScale: Interval): { long: Interval.Second }, { long: Interval.Millisecond }, ]; + // convert $size to milliseconds // intervals_in_seconds uses seconds (duh), convert them to milliseconds here to minimize floating point errors size *= INTERVALS_IN_SECONDS[timeScale] * 1000; const strings = []; + // after first value >= 1 print only $decimals more let decrementDecimals = false; - for (let i = 0; i < units.length && decimals >= 0; i++) { + let decimalsCount = 0; + + if (decimals !== null || decimals !== undefined) { + decimalsCount = decimals as number; + } + + for (let i = 0; i < units.length && decimalsCount >= 0; i++) { const interval = INTERVALS_IN_SECONDS[units[i].long] * 1000; const value = size / interval; if (value >= 1 || decrementDecimals) { @@ -205,14 +222,14 @@ export function toDuration(size: number, decimals: number, timeScale: Interval): const unit = units[i].long + (floor !== 1 ? 's' : ''); strings.push(floor + ' ' + unit); size = size % interval; - decimals--; + decimalsCount--; } } return strings.join(', '); } -export function toClock(size: number, decimals?: number) { +export function toClock(size: number, decimals?: DecimalCount) { if (size === null) { return ''; } @@ -257,11 +274,11 @@ export function toClock(size: number, decimals?: number) { return format ? `${hours}:${moment.utc(size).format(format)}` : hours; } -export function toDurationInMilliseconds(size: number, decimals: number) { +export function toDurationInMilliseconds(size: number, decimals: DecimalCount) { return toDuration(size, decimals, Interval.Millisecond); } -export function toDurationInSeconds(size: number, decimals: number) { +export function toDurationInSeconds(size: number, decimals: DecimalCount) { return toDuration(size, decimals, Interval.Second); } @@ -276,19 +293,19 @@ export function toDurationInHoursMinutesSeconds(size: number) { return strings.join(':'); } -export function toTimeTicks(size: number, decimals: number, scaledDecimals: number) { +export function toTimeTicks(size: number, decimals: DecimalCount, scaledDecimals: DecimalCount) { return toSeconds(size, decimals, scaledDecimals); } -export function toClockMilliseconds(size: number, decimals: number) { +export function toClockMilliseconds(size: number, decimals: DecimalCount) { return toClock(size, decimals); } -export function toClockSeconds(size: number, decimals: number) { +export function toClockSeconds(size: number, decimals: DecimalCount) { return toClock(size * 1000, decimals); } -export function dateTimeAsIso(value: number, decimals: number, scaledDecimals: number, isUtc: boolean) { +export function dateTimeAsIso(value: number, decimals: DecimalCount, scaledDecimals: DecimalCount, isUtc?: boolean) { const time = isUtc ? moment.utc(value) : moment(value); if (moment().isSame(value, 'day')) { @@ -297,7 +314,7 @@ export function dateTimeAsIso(value: number, decimals: number, scaledDecimals: n return time.format('YYYY-MM-DD HH:mm:ss'); } -export function dateTimeAsUS(value: number, decimals: number, scaledDecimals: number, isUtc: boolean) { +export function dateTimeAsUS(value: number, decimals: DecimalCount, scaledDecimals: DecimalCount, isUtc?: boolean) { const time = isUtc ? moment.utc(value) : moment(value); if (moment().isSame(value, 'day')) { @@ -306,7 +323,7 @@ export function dateTimeAsUS(value: number, decimals: number, scaledDecimals: nu return time.format('MM/DD/YYYY h:mm:ss a'); } -export function dateTimeFromNow(value: number, decimals: number, scaledDecimals: number, isUtc: boolean) { +export function dateTimeFromNow(value: number, decimals: DecimalCount, scaledDecimals: DecimalCount, isUtc?: boolean) { const time = isUtc ? moment.utc(value) : moment(value); return time.fromNow(); } diff --git a/packages/grafana-ui/src/utils/valueFormats/symbolFormatters.ts b/packages/grafana-ui/src/utils/valueFormats/symbolFormatters.ts index 66808143daa37..da8198daf5ae1 100644 --- a/packages/grafana-ui/src/utils/valueFormats/symbolFormatters.ts +++ b/packages/grafana-ui/src/utils/valueFormats/symbolFormatters.ts @@ -1,9 +1,9 @@ -import { scaledUnits } from './valueFormats'; +import { scaledUnits, DecimalCount } from './valueFormats'; export function currency(symbol: string) { const units = ['', 'K', 'M', 'B', 'T']; const scaler = scaledUnits(1000, units); - return (size: number, decimals: number, scaledDecimals: number) => { + return (size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) => { if (size === null) { return ''; } diff --git a/packages/grafana-ui/src/utils/valueFormats/valueFormats.ts b/packages/grafana-ui/src/utils/valueFormats/valueFormats.ts index 0a56ce58e5b30..d626a241a7985 100644 --- a/packages/grafana-ui/src/utils/valueFormats/valueFormats.ts +++ b/packages/grafana-ui/src/utils/valueFormats/valueFormats.ts @@ -1,8 +1,15 @@ import { getCategories } from './categories'; -type ValueFormatter = (value: number, decimals?: number, scaledDecimals?: number, isUtc?: boolean) => string; +export type DecimalCount = number | null | undefined; -interface ValueFormat { +export type ValueFormatter = ( + value: number, + decimals?: DecimalCount, + scaledDecimals?: DecimalCount, + isUtc?: boolean +) => string; + +export interface ValueFormat { name: string; id: string; fn: ValueFormatter; @@ -22,7 +29,7 @@ let categories: ValueFormatCategory[] = []; const index: ValueFormatterIndex = {}; let hasBuiltIndex = false; -export function toFixed(value: number, decimals?: number): string { +export function toFixed(value: number, decimals?: DecimalCount): string { if (value === null) { return ''; } @@ -50,20 +57,24 @@ export function toFixed(value: number, decimals?: number): string { export function toFixedScaled( value: number, - decimals: number, - scaledDecimals: number, - additionalDecimals: number, - ext: string + decimals?: DecimalCount, + scaledDecimals?: DecimalCount, + additionalDecimals?: DecimalCount, + ext?: string ) { - if (scaledDecimals === null) { - return toFixed(value, decimals) + ext; - } else { - return toFixed(value, scaledDecimals + additionalDecimals) + ext; + if (scaledDecimals) { + if (additionalDecimals) { + return toFixed(value, scaledDecimals + additionalDecimals) + ext; + } else { + return toFixed(value, scaledDecimals) + ext; + } } + + return toFixed(value, decimals) + ext; } -export function toFixedUnit(unit: string) { - return (size: number, decimals: number) => { +export function toFixedUnit(unit: string): ValueFormatter { + return (size: number, decimals?: DecimalCount) => { if (size === null) { return ''; } @@ -75,7 +86,7 @@ export function toFixedUnit(unit: string) { // numeric factor. Repeatedly scales the value down by the factor until it is // less than the factor in magnitude, or the end of the array is reached. export function scaledUnits(factor: number, extArray: string[]) { - return (size: number, decimals: number, scaledDecimals: number) => { + return (size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) => { if (size === null) { return ''; } @@ -92,7 +103,7 @@ export function scaledUnits(factor: number, extArray: string[]) { } } - if (steps > 0 && scaledDecimals !== null) { + if (steps > 0 && scaledDecimals !== null && scaledDecimals !== undefined) { decimals = scaledDecimals + 3 * steps; } @@ -100,17 +111,17 @@ export function scaledUnits(factor: number, extArray: string[]) { }; } -export function locale(value: number, decimals: number) { +export function locale(value: number, decimals: DecimalCount) { if (value == null) { return ''; } - return value.toLocaleString(undefined, { maximumFractionDigits: decimals }); + return value.toLocaleString(undefined, { maximumFractionDigits: decimals as number }); } export function simpleCountUnit(symbol: string) { const units = ['', 'K', 'M', 'B', 'T']; const scaler = scaledUnits(1000, units); - return (size: number, decimals: number, scaledDecimals: number) => { + return (size: number, decimals?: DecimalCount, scaledDecimals?: DecimalCount) => { if (size === null) { return ''; } diff --git a/packages/grafana-ui/tsconfig.json b/packages/grafana-ui/tsconfig.json index 22d336b85f5a9..1dfe6e0b44cb8 100644 --- a/packages/grafana-ui/tsconfig.json +++ b/packages/grafana-ui/tsconfig.json @@ -1,21 +1,17 @@ { "extends": "../../tsconfig.json", - "include": [ - "src/**/*.ts", - "src/**/*.tsx" - ], - "exclude": [ - "dist", - "node_modules" - ], + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["dist", "node_modules"], "compilerOptions": { "rootDirs": [".", "stories"], "module": "esnext", "outDir": "dist", "declaration": true, + "strict": true, + "alwaysStrict": true, "noImplicitAny": true, "strictNullChecks": true, "typeRoots": ["./node_modules/@types", "types"], "skipLibCheck": true // Temp workaround for Duplicate identifier tsc errors - }, + } } From 7b59b9cf4b428f255131c8af68d651e6c54972c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 15 Feb 2019 11:03:24 +0100 Subject: [PATCH 13/16] Fixed dashboard navbar buttons being visible in fullscreen, fixes #15450 --- public/sass/components/_navbar.scss | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/sass/components/_navbar.scss b/public/sass/components/_navbar.scss index a915d003eabec..86494f9e47a66 100644 --- a/public/sass/components/_navbar.scss +++ b/public/sass/components/_navbar.scss @@ -46,9 +46,8 @@ .navbar-button--add-panel, .navbar-button--star, - .navbar-button--tv, - .navbar-buttons--close { - display: flex; + .navbar-button--tv { + display: none; } } From 7699706e65ffd48c03196907de6b89d2b0be1c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 15 Feb 2019 11:23:31 +0100 Subject: [PATCH 14/16] fixed handling of alert urls with true flags, fixes #15454 --- pkg/services/alerting/eval_context.go | 2 +- .../app/features/alerting/AlertRuleItem.tsx | 2 +- .../__snapshots__/AlertRuleItem.test.tsx.snap | 4 +-- .../containers/DashboardPage.test.tsx | 34 ++++++++++++++++++- .../dashboard/containers/DashboardPage.tsx | 6 ++-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/pkg/services/alerting/eval_context.go b/pkg/services/alerting/eval_context.go index 4db942e0a559f..02b9955662f04 100644 --- a/pkg/services/alerting/eval_context.go +++ b/pkg/services/alerting/eval_context.go @@ -104,7 +104,7 @@ func (c *EvalContext) GetDashboardUID() (*m.DashboardRef, error) { return c.dashboardRef, nil } -const urlFormat = "%s?fullscreen=true&edit=true&tab=alert&panelId=%d&orgId=%d" +const urlFormat = "%s?fullscreen&edit&tab=alert&panelId=%d&orgId=%d" func (c *EvalContext) GetRuleUrl() (string, error) { if c.IsTestRun { diff --git a/public/app/features/alerting/AlertRuleItem.tsx b/public/app/features/alerting/AlertRuleItem.tsx index 86bb0207460c5..3fec37d19b8fe 100644 --- a/public/app/features/alerting/AlertRuleItem.tsx +++ b/public/app/features/alerting/AlertRuleItem.tsx @@ -29,7 +29,7 @@ class AlertRuleItem extends PureComponent { 'fa-pause': rule.state !== 'paused', }); - const ruleUrl = `${rule.url}?panelId=${rule.panelId}&fullscreen=true&edit=true&tab=alert`; + const ruleUrl = `${rule.url}?panelId=${rule.panelId}&fullscreen&edit&tab=alert`; return (
  • diff --git a/public/app/features/alerting/__snapshots__/AlertRuleItem.test.tsx.snap b/public/app/features/alerting/__snapshots__/AlertRuleItem.test.tsx.snap index f686127ebf3ef..8e076ffd22e63 100644 --- a/public/app/features/alerting/__snapshots__/AlertRuleItem.test.tsx.snap +++ b/public/app/features/alerting/__snapshots__/AlertRuleItem.test.tsx.snap @@ -21,7 +21,7 @@ exports[`Render should render component 1`] = ` className="alert-rule-item__name" > { expect(ctx.cleanUpDashboardMock.calls).toBe(1); }); }); + + describe('mapStateToProps with bool fullscreen', () => { + const props = mapStateToProps({ + location: { + routeParams: {}, + query: { + fullscreen: true, + edit: false, + }, + }, + dashboard: {}, + } as any); + + expect(props.urlFullscreen).toBe(true); + expect(props.urlEdit).toBe(false); + }); + + describe('mapStateToProps with string edit true', () => { + const props = mapStateToProps({ + location: { + routeParams: {}, + query: { + fullscreen: false, + edit: 'true', + }, + }, + dashboard: {}, + } as any); + + expect(props.urlFullscreen).toBe(false); + expect(props.urlEdit).toBe(true); + }); }); diff --git a/public/app/features/dashboard/containers/DashboardPage.tsx b/public/app/features/dashboard/containers/DashboardPage.tsx index 27118e297b553..bdb601a692f23 100644 --- a/public/app/features/dashboard/containers/DashboardPage.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.tsx @@ -284,15 +284,15 @@ export class DashboardPage extends PureComponent { } } -const mapStateToProps = (state: StoreState) => ({ +export const mapStateToProps = (state: StoreState) => ({ urlUid: state.location.routeParams.uid, urlSlug: state.location.routeParams.slug, urlType: state.location.routeParams.type, editview: state.location.query.editview, urlPanelId: state.location.query.panelId, urlFolderId: state.location.query.folderId, - urlFullscreen: state.location.query.fullscreen === true, - urlEdit: state.location.query.edit === true, + urlFullscreen: !!state.location.query.fullscreen, + urlEdit: !!state.location.query.edit, initPhase: state.dashboard.initPhase, isInitSlow: state.dashboard.isInitSlow, initError: state.dashboard.initError, From 88fbe3adcab52f47224584dba91324a6db342a4e Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Fri, 15 Feb 2019 11:27:21 +0100 Subject: [PATCH 15/16] docs: fix header --- docs/sources/installation/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/installation/configuration.md b/docs/sources/installation/configuration.md index d85e39146dcad..2352bd15b8920 100644 --- a/docs/sources/installation/configuration.md +++ b/docs/sources/installation/configuration.md @@ -594,7 +594,7 @@ Default setting for new alert rules. Defaults to categorize error and timeouts a Default setting for how Grafana handles nodata or null values in alerting. (alerting, no_data, keep_state, ok) -# concurrent_render_limit +### concurrent_render_limit > Available in 5.3 and above From ff87f6d303961f5c3f8a9304b7bfb6f57233e593 Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Fri, 15 Feb 2019 11:31:29 +0100 Subject: [PATCH 16/16] docs: suggested changes --- docs/sources/guides/whats-new-in-v6-0.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/sources/guides/whats-new-in-v6-0.md b/docs/sources/guides/whats-new-in-v6-0.md index e789b6e71b26f..2ba7e86b38536 100644 --- a/docs/sources/guides/whats-new-in-v6-0.md +++ b/docs/sources/guides/whats-new-in-v6-0.md @@ -27,7 +27,7 @@ The main highlights are: - [Azure Monitor]({{< relref "#azure-monitor-datasource" >}}) plugin is ported from being an external plugin to being a core datasource - [React Plugin]({{< relref "#react-panels-query-editors" >}}) support enables an easier way to build plugins. - [Named Colors]({{< relref "#named-colors" >}}) in our new improved color picker. -- [Removal of user session storage]({{< relref "#easier-to-deploy-improved security" >}}) makes Grafana easier to deploy & improved security. +- [Removal of user session storage]({{< relref "#easier-to-deploy-improved-security" >}}) makes Grafana easier to deploy & improves security. ## Explore @@ -141,13 +141,14 @@ Read more about the short-lived token solution and how to configure it [here](/a > Please note that due to these changes, all users will be required to login upon next visit after upgrade. -Besides these changes we have also introduced [SameSite](https://www.owasp.org/index.php/SameSite) setting to protect against Cross-Site Request Forgery (CSRF). This setting enables more control of when the browser include cookies in requests. Its set to `lax` by default but can be configured using `cookie_samesite` under `[security]` +Besides these changes we have also made security improvements regarding Cross-Site Request Forgery (CSRF) and Cross-site Scripting (XSS) vulnerabilities: + +* Cookies are per default using the [SameSite](/installation/configuration/#cookie-samesite) attribute to protect against CSRF attacks +* Script tags in text panels are per default [disabled](/installation/configuration/#disable-sanitize-html) to protect against XSS attacks > If you're using [Auth Proxy Authentication](/auth/auth-proxy/) you still need to have user sessions setup and configured but our goal is to remove this requirements in a near future. -We also disable script tags in text panels by default to avoid Cross-site Scripting (XSS) attacks. - ## Named Colors {{< docs-imagebox img="/img/docs/v60/named_colors.png" max-width="400px" class="docs-image--right" caption="Named Colors" >}}