diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4b4588eab21..69ce3168730 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,5 @@ -* Link the PR to an issue for new features +* Follow the contribution guidelines in [`CONTRIBUTING.md`](https://github.com/grafana/grafana/blob/master/CONTRIBUTING.md) * Rebase your PR if it gets out of sync with master +* Include `closes #` or a link to the issue in the description **REMOVE THE TEXT ABOVE BEFORE CREATING THE PULL REQUEST** diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..b7a33870ddd --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +.git +.github +dist/ +pkg/ +node_modules +public/vendor/ +vendor/ + diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b97da0e81c..faa2f49faff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # 6.0.0-beta3 (unreleased) +### Minor +* **CLI**: Grafana CLI should preserve permissions for backend binaries for Linux and Darwin [#15500](https://github.com/grafana/grafana/issues/15500) +* **Alerting**: Allow image rendering 90 percent of alertTimeout [#15395](https://github.com/grafana/grafana/pull/15395) + +### Bug fixes +* **Influxdb**: Add support for alerting on InfluxDB queries that use the non_negative_difference function [#15415](https://github.com/grafana/grafana/issues/15415), thx [@kiran3394](https://github.com/kiran3394) +* **Alerting**: Fix percent_diff calculation when points are nulls [#15443](https://github.com/grafana/grafana/issues/15443), thx [@max-neverov](https://github.com/max-neverov) +* **Alerting**: Fixed handling of alert urls with true flags [#15454](https://github.com/grafana/grafana/issues/15454) + # 6.0.0-beta2 (2019-02-11) ### New Features @@ -20,20 +29,19 @@ * **Login**: Anonymous usage stats for token auth [#15288](https://github.com/grafana/grafana/issues/15288) * **AzureMonitor**: improve autocomplete for Log Analytics and App Insights editor [#15131](https://github.com/grafana/grafana/issues/15131) * **LDAP**: Fix IPA/FreeIPA v4.6.4 does not allow LDAP searches with empty attributes [#14432](https://github.com/grafana/grafana/issues/14432) +* **Provisioning**: Allow testing data sources that were added by config [#12164](https://github.com/grafana/grafana/issues/12164) ### Breaking changes * **Internal Metrics** Edition has been added to the build_info metric. This will break any Graphite queries using this metric. Edition will be a new label for the Prometheus metric. [#15363](https://github.com/grafana/grafana/pull/15363) -### 6.0.0-beta1 fixes +### Bug fixes -* **Postgres**: Fix default port not added when port not configured [#15189](https://github.com/grafana/grafana/issues/15189) -* **Alerting**: Fixes crash bug when alert notifier folders are missing [#15295](https://github.com/grafana/grafana/issues/15295) -* **Dashboard**: Fix save provisioned dashboard modal [#15219](https://github.com/grafana/grafana/pull/15219) -* **Dashboard**: Fix having a long query in prometheus dashboard query editor blocks 30% of the query field when on OSX and having native scrollbars [#15122](https://github.com/grafana/grafana/issues/15122) -* **Explore**: Fix issue with wrapping on long queries [#15222](https://github.com/grafana/grafana/issues/15222) -* **Explore**: Fix cut & paste adds newline before and after selection [#15223](https://github.com/grafana/grafana/issues/15223) -* **Dataproxy**: Fix global datasource proxy timeout not added to correct http client [#15258](https://github.com/grafana/grafana/issues/15258) [#5699](https://github.com/grafana/grafana/issues/5699) +* **Gauge**: Fix issue with gauge requests being cancelled [#15366](https://github.com/grafana/grafana/issues/15366) +* **Gauge**: Accept decimal inputs for thresholds [#15372](https://github.com/grafana/grafana/issues/15372) +* **UI**: Fix error caused by named colors that are not part of named colors palette [#15373](https://github.com/grafana/grafana/issues/15373) +* **Search**: Bug pressing special regexp chars in input fields [#12972](https://github.com/grafana/grafana/issues/12972) +* **Permissions**: No need to have edit permissions to be able to "Save as" [#13066](https://github.com/grafana/grafana/issues/13066) # 6.0.0-beta1 (2019-01-30) @@ -82,6 +90,13 @@ * **Prometheus**: Query for annotation always uses 60s step regardless of dashboard range, fixes [#14795](https://github.com/grafana/grafana/issues/14795) * **Annotations**: Fix creating annotation when graph panel has no data points position the popup outside viewport [#13765](https://github.com/grafana/grafana/issues/13765), thx [@banjeremy](https://github.com/banjeremy) * **Piechart/Flot**: Fixes multiple piechart instances with donut bug [#15062](https://github.com/grafana/grafana/pull/15062) +* **Postgres**: Fix default port not added when port not configured [#15189](https://github.com/grafana/grafana/issues/15189) +* **Alerting**: Fixes crash bug when alert notifier folders are missing [#15295](https://github.com/grafana/grafana/issues/15295) +* **Dashboard**: Fix save provisioned dashboard modal [#15219](https://github.com/grafana/grafana/pull/15219) +* **Dashboard**: Fix having a long query in prometheus dashboard query editor blocks 30% of the query field when on OSX and having native scrollbars [#15122](https://github.com/grafana/grafana/issues/15122) +* **Explore**: Fix issue with wrapping on long queries [#15222](https://github.com/grafana/grafana/issues/15222) +* **Explore**: Fix cut & paste adds newline before and after selection [#15223](https://github.com/grafana/grafana/issues/15223) +* **Dataproxy**: Fix global datasource proxy timeout not added to correct http client [#15258](https://github.com/grafana/grafana/issues/15258) [#5699](https://github.com/grafana/grafana/issues/5699) ### Breaking changes * **Text Panel**: The text panel does no longer by default allow unsantizied HTML. [#4117](https://github.com/grafana/grafana/issues/4117). This means that if you have text panels with scripts tags they will no longer work as before. To enable unsafe javascript execution in text panels enable the settings `disable_sanitize_html` under the section `[panels]` in your Grafana ini file, or set env variable `GF_PANELS_DISABLE_SANITIZE_HTML=true`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b2ba090fe1..677a12831dc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,49 +8,47 @@ Contributions take the form of pull requests that will be reviewed by the core t * If you have a trivial fix or improvement, go ahead and create a pull request. -* If you plan to do something more involved, discuss your idea on the respective [issue](https://github.com/grafana/grafana/issues) or create a [new issue](https://github.com/grafana/grafana/issues/new) if it does not exist. This will avoid unnecessary work and surely give you and us a good deal of inspiration. +* If you plan to do something more involved, discuss your idea on the respective [issue](https://github.com/grafana/grafana/issues) or create a [new issue](https://github.com/grafana/grafana/issues/new) if it does not exist. This will avoid unnecessary work and surely give you and us a good deal of inspiration. +* Sign our [CLA](http://docs.grafana.org/contribute/cla/). + +* For changes in the backend, follow the style guides used in Go [Code Review Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments) and Peter Bourgon's [Go: Best Practices for Production Environments](http://peter.bourgon.org/go-in-production/#formatting-and-style) ## Steps to Contribute Should you wish to work on a GitHub issue, check first if it is not already assigned to someone. If it is free, you claim it by commenting on the issue that you want to work on it. This is to prevent duplicated efforts from contributors on the same issue. -Please check the [`beginner friendly`](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) label to find issues that are good for getting started. If you have questions about one of the issues, with or without the tag, please comment on them and one of the core team or the original poster will clarify it. +Please check the [`beginner friendly`](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) and [`help wanted`](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) labels to find issues that are good for getting started. If you have questions about one of the issues, with or without the tag, please comment on them and one of the core team or the original poster will clarify it. - - -## Setup - -Follow the setup guide in README.md - -### Rebuild frontend assets on source change -``` -yarn watch -``` - -### Rerun tests on source change -``` -yarn jest -``` - -### Run tests for backend assets before commit -``` -test -z "$(gofmt -s -l . | grep -v -E 'vendor/(github.com|golang.org|gopkg.in)' | tee /dev/stderr)" -``` - -### Run tests for frontend assets before commit -``` -yarn test -go test -v ./pkg/... -``` +To setup a local development environment we recommend reading [Building Grafana from source](http://docs.grafana.org/project/building_from_source/) ## Pull Request Checklist * Branch from the master branch and, if needed, rebase to the current master branch before submitting your pull request. If it doesn't merge cleanly with master you may be asked to rebase your changes. -* Commits should be as small as possible, while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests). - * If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment. * Add tests relevant to the fixed bug or new feature. + +### Pull requests with new features +Commits should be as small as possible, while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests). + +Make sure to include `closes #` or `fixes #` in the pull request description. + +### Pull requests with bug fixes +Please make all changes in one commit if possible. Include `closes #12345` in bottom of the commit message. +A commit message for a bug fix should look something like this. + +``` +avoid infinite loop in the dashboard provisioner + +if one dashboard with an uid is refered to by two +provsioners each provisioner overwrite each other. +filling up dashboard_versions quite fast if using +default settings. + +closes #12864 +``` + +If the pull request needs changes before its merged the new commits should be rebased into one commit before its merged. \ No newline at end of file diff --git a/devenv/datasources.yaml b/devenv/datasources.yaml index d4457faaebf..1922743fca8 100644 --- a/devenv/datasources.yaml +++ b/devenv/datasources.yaml @@ -11,11 +11,11 @@ datasources: - name: gdev-prometheus type: prometheus access: proxy - isDefault: true url: http://localhost:9090 - name: gdev-testdata type: testdata + isDefault: true - name: gdev-influxdb type: influxdb diff --git a/devenv/docker/ha_test/docker-compose.yaml b/devenv/docker/ha_test/docker-compose.yaml index 8087894c56e..a215513c568 100644 --- a/devenv/docker/ha_test/docker-compose.yaml +++ b/devenv/docker/ha_test/docker-compose.yaml @@ -7,6 +7,13 @@ services: - "80:80" volumes: - /var/run/docker.sock:/tmp/docker.sock:ro + depends_on: + db: + condition: service_healthy + logging: + driver: "fluentd" + options: + tag: nginx db: image: mysql:5.6 @@ -66,6 +73,8 @@ services: # - GF_DATABASE_SSL_MODE=disable # - GF_SESSION_PROVIDER=postgres # - GF_SESSION_PROVIDER_CONFIG=user=grafana password=password host=db port=5432 dbname=grafana sslmode=disable + - GF_SERVER_ROUTER_LOGGING=true + - GF_LOG_CONSOLE_FORMAT=json - GF_LOG_FILTERS=alerting.notifier:debug,alerting.notifier.slack:debug,auth:debug - GF_AUTH_TOKEN_ROTATION_INTERVAL_MINUTES=2 ports: @@ -73,6 +82,10 @@ services: depends_on: db: condition: service_healthy + logging: + driver: "fluentd" + options: + tag: grafana prometheus: image: prom/prometheus:v2.4.2 @@ -82,3 +95,21 @@ services: - VIRTUAL_HOST=prometheus.loc ports: - 9090 + + loki: + image: grafana/loki:master + environment: + - VIRTUAL_HOST=loki.loc + ports: + - 3100 + command: -config.file=/etc/loki/local-config.yaml + + fluentd: + image: grafana/fluent-plugin-loki:master + volumes: + - ./fluentd/fluentd.conf:/fluentd/etc/fluentd.conf + links: + - loki + ports: + - "24224:24224" + - "24224:24224/udp" diff --git a/devenv/docker/ha_test/fluentd/fluentd.conf b/devenv/docker/ha_test/fluentd/fluentd.conf new file mode 100644 index 00000000000..58859441d96 --- /dev/null +++ b/devenv/docker/ha_test/fluentd/fluentd.conf @@ -0,0 +1,73 @@ + + @type forward + port 24224 + bind 0.0.0.0 + + + + @type parser + + @type json + json_parser json + + replace_invalid_sequence true + emit_invalid_record_to_error false + key_name log + reserve_data true + remove_key_name_field true + + + + @type parser + format /^.*m(?[^ ]*) (?[^ ]*) \- \- \[(? + + + @type record_transformer + remove_keys "source,t" + + + + @type copy + + @type stdout + output_type json + + + @type loki + url "http://loki:3100" + extra_labels {"app":"grafana"} + label_keys "container_name,container_id,logger" + flush_interval 10s + flush_at_shutdown true + buffer_chunk_limit 1m + + + + + @type record_transformer + + lvl "info" + + + + + @type copy + + @type stdout + output_type json + + + @type loki + url "http://loki:3100" + extra_labels {"app":"nginx"} + label_keys "container_name,container_id" + flush_interval 10s + flush_at_shutdown true + buffer_chunk_limit 1m + + \ No newline at end of file diff --git a/devenv/docker/ha_test/grafana/provisioning/datasources/datasources.yaml b/devenv/docker/ha_test/grafana/provisioning/datasources/datasources.yaml index 8d59793be16..3cf02b6a9b6 100644 --- a/devenv/docker/ha_test/grafana/provisioning/datasources/datasources.yaml +++ b/devenv/docker/ha_test/grafana/provisioning/datasources/datasources.yaml @@ -8,4 +8,9 @@ datasources: jsonData: timeInterval: 10s queryTimeout: 30s - httpMethod: POST \ No newline at end of file + httpMethod: POST + + - name: Loki + type: loki + access: proxy + url: http://loki:3100 diff --git a/devenv/docker/ha_test/prometheus/prometheus.yml b/devenv/docker/ha_test/prometheus/prometheus.yml index 0950bad6f7d..ab1711e9c6e 100644 --- a/devenv/docker/ha_test/prometheus/prometheus.yml +++ b/devenv/docker/ha_test/prometheus/prometheus.yml @@ -36,4 +36,12 @@ scrape_configs: - 'mysqld-exporter' type: 'A' port: 9104 + refresh_interval: 10s + + - job_name: 'loki' + dns_sd_configs: + - names: + - 'loki' + type: 'A' + port: 3100 refresh_interval: 10s \ No newline at end of file diff --git a/docs/sources/auth/generic-oauth.md b/docs/sources/auth/generic-oauth.md index c3c44426ba7..ac5801dbe1d 100644 --- a/docs/sources/auth/generic-oauth.md +++ b/docs/sources/auth/generic-oauth.md @@ -211,6 +211,8 @@ allowed_organizations = ## Set up OAuth2 with non-compliant providers +> Only available in Grafana v6.0 and above. + Some OAuth2 providers might not support `client_id` and `client_secret` passed via Basic Authentication HTTP header, which results in `invalid_client` error. To allow Grafana to authenticate via these type of providers, the client identifiers must be send via POST body, which can be enabled via the following settings: diff --git a/docs/sources/auth/overview.md b/docs/sources/auth/overview.md index 1d0b0d89b3f..fc22d6b2d7f 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. diff --git a/docs/sources/features/datasources/index.md b/docs/sources/features/datasources/index.md index a892f38a448..42ce3f84819 100644 --- a/docs/sources/features/datasources/index.md +++ b/docs/sources/features/datasources/index.md @@ -13,7 +13,6 @@ weight = 5 Grafana supports many different storage backends for your time series data (Data Source). Each Data Source has a specific Query Editor that is customized for the features and capabilities that the particular Data Source exposes. - ## Querying The query language and capabilities of each Data Source are obviously very different. You can combine data from multiple Data Sources onto a single Dashboard, but each Panel is tied to a specific Data Source that belongs to a particular Organization. @@ -28,6 +27,7 @@ The following datasources are officially supported: * [InfluxDB]({{< relref "influxdb.md" >}}) * [OpenTSDB]({{< relref "opentsdb.md" >}}) * [Prometheus]({{< relref "prometheus.md" >}}) +* [Loki]({{< relref "loki.md" >}}) * [MySQL]({{< relref "mysql.md" >}}) * [Postgres]({{< relref "postgres.md" >}}) * [Microsoft SQL Server (MSSQL)]({{< relref "mssql.md" >}}) diff --git a/docs/sources/features/datasources/loki.md b/docs/sources/features/datasources/loki.md new file mode 100644 index 00000000000..d43ef982b4b --- /dev/null +++ b/docs/sources/features/datasources/loki.md @@ -0,0 +1,119 @@ ++++ +title = "Using Loki in Grafana" +description = "Guide for using Loki in Grafana" +keywords = ["grafana", "loki", "logging", "guide"] +type = "docs" +aliases = ["/datasources/loki"] +[menu.docs] +name = "Loki" +parent = "datasources" +weight = 11 ++++ + +# Using Loki in Grafana + +> BETA: Querying Loki data requires Grafana's Explore section. +> Grafana v6.x comes with Explore enabled by default. +> In Grafana v5.3.x and v5.4.x. you need to enable Explore manually. +> Viewing Loki data in dashboard panels is not supported yet, but is being worked on. + +Grafana ships with built-in support for Loki, Grafana's log aggregation system. +Just add it as a datasource and you are ready to query your log data in [Explore](/features/explore). + +## Adding the data source to Grafana + +1. Open Grafana and make sure you are logged in. +2. In the side menu under the `Configuration` link you should find a link named `Data Sources`. +3. Click the `Add data source` button at the top. +4. Select `Loki` from the list of data sources. + +> NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. + +| Name | Description | +| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| _Name_ | The datasource name. This is how you refer to the datasource in panels, queries, and Explore. | +| _Default_ | Default datasource means that it will be pre-selected for new panels. | +| _URL_ | The URL of the Loki instance, e.g., `http://localhost:3100` | +| _Maximum lines_ | Upper limit for number of log lines returned by Loki (default is 1000). Decrease if your browser is sluggish when displaying logs in Explore. | + +## Querying Logs + +Querying and displaying log data from Loki is available via [Explore](/features/explore). +Select the Loki data source, and then enter a log query to display your logs. + +> Viewing Loki data in dashboard panels is not supported yet, but is being worked on. + +### Log Queries + +A log query consists of two parts: **log stream selector**, and a **search expression**. For performance reasons you need to start by choosing a log stream by selecting a log label. + +The Logs Explorer (the `Log labels` button) next to the query field shows a list of labels of available log streams. An alternative way to write a query is to use the query field's autocomplete - you start by typing a left curly brace `{` and the autocomplete menu will suggest a list of labels. Press the `enter` key to execute the query. + +Once the result is returned, the log panel shows a list of log rows and a bar chart where the x-axis shows the time and the y-axis shows the frequency/count. + +
+ +
+ +
+ +### Log Stream Selector + +For the label part of the query expression, wrap it in curly braces `{}` and then use the key value syntax for selecting labels. Multiple label expressions are separated by a comma: + +`{app="mysql",name="mysql-backup"}` + +The following label matching operators are currently supported: + +* `=` exactly equal. +* `!=` not equal. +* `=~` regex-match. +* `!~` do not regex-match. + +Examples: + +* `{name=~"mysql.+"}` +* `{name!~"mysql.+"}` + +The [same rules that apply for Prometheus Label Selectors](https://prometheus.io/docs/prometheus/latest/querying/basics/#instant-vector-selectors) apply for Loki Log Stream Selectors. + +Another way to add a label selector, is in the table section, clicking on the **Filter** button beside a label will add the label to the query expression. This even works for multiple queries and will the label selector to each query. + +### Search Expression + +After writing the Log Stream Selector, you can filter the results further by writing a search expression. The search expression can be just text or a regex expression. + +Example queries: + +* `{job="mysql"} error` +* `{name="kafka"} tsdb-ops.*io:2003` +* `{instance=~"kafka-[23]",name="kafka"} kafka.server:type=ReplicaManager` + +## Templating + +Template variables are not yet supported by Loki. + +## Annotations + +Annotations are not yet supported by Loki. + +## Configure the Datasource with Provisioning + +You can set up the datasource via config files with Grafana's provisioning system. +You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](/administration/provisioning/#datasources) + +Here is an example: + +```yaml +apiVersion: 1 + +datasources: + - name: Loki + type: loki + url: http://localhost:3100 + jsonData: + maxLines: 1000 +``` diff --git a/docs/sources/features/explore/index.md b/docs/sources/features/explore/index.md index 25af18c2a3d..bf5811baea6 100644 --- a/docs/sources/features/explore/index.md +++ b/docs/sources/features/explore/index.md @@ -67,9 +67,9 @@ The autocomplete menu can be trigger by pressing Ctrl + Space. The Autocomplete Suggestions can appear under the query field - click on them to update your query with the suggested change. -- For counters (monotonously increasing metrics), a rate function will be suggested. -- For buckets, a histogram function will be suggested. -- For recording rules, possible to expand the rules. +* For counters (monotonously increasing metrics), a rate function will be suggested. +* For buckets, a histogram function will be suggested. +* For recording rules, possible to expand the rules. ### Table Filters @@ -79,6 +79,8 @@ Click on the filter button - - - -
- -#### Log Stream Selector - -For the label part of the query expression, wrap it in curly braces `{}` and then use the key value syntax for selecting labels. Multiple label expressions are separated by a comma: - -`{app="mysql",name="mysql-backup"}` - -The following label matching operators are currently supported: - -- `=` exactly equal. -- `!=` not equal. -- `=~` regex-match. -- `!~` do not regex-match. - -Examples: - -- `{name=~"mysql.+"}` -- `{name!~"mysql.+"}` - -The [same rules that apply for Prometheus Label Selectors](https://prometheus.io/docs/prometheus/latest/querying/basics/#instant-vector-selectors) apply for Loki Log Stream Selectors. - -Another way to add a label selector, is in the table section, clicking on the **Filter** button beside a label will add the label to the query expression. This even works for multiple queries and will the label selector to each query. - -#### Search Expression - -After writing the Log Stream Selector, you can filter the results further by writing a search expression. The search expression can be just text or a regex expression. - -Example queries: - -- `{job="mysql"} error` -- `{name="kafka"} tsdb-ops.*io:2003` -- `{instance=~"kafka-[23]",name="kafka"} kafka.server:type=ReplicaManager` - ### Deduping Log data can be very repetitive and Explore can help by hiding duplicate log lines. There are a few different deduplication algorithms that you can use: -- `exact` Exact matches are done on the whole line, except for date fields. -- `numbers` Matches on the line after stripping out numbers (durations, IP addresses etc.). -- `signature` The most aggressive deduping - strips all letters and numbers, and matches on the remaining whitespace and punctuation. +* `exact` Exact matches are done on the whole line, except for date fields. +* `numbers` Matches on the line after stripping out numbers (durations, IP addresses etc.). +* `signature` The most aggressive deduping - strips all letters and numbers, and matches on the remaining whitespace and punctuation. ### Timestamp, Local time and Labels There are some other check boxes under the logging graph apart from the Deduping options. -- Timestamp: shows/hides the Timestamp column -- Local time: shows/hides the Local time column -- Labels: shows/hides the label filters column +* Timestamp: shows/hides the Timestamp column +* Local time: shows/hides the Local time column +* Labels: shows/hides the label filters column diff --git a/docs/sources/guides/whats-new-in-v6-0.md b/docs/sources/guides/whats-new-in-v6-0.md index 61eec0ac390..2ba7e86b385 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-improved-security" >}}) makes Grafana easier to deploy & improves security. ## Explore @@ -113,30 +114,42 @@ 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 & improved security -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 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. + +## Named Colors {{< docs-imagebox img="/img/docs/v60/named_colors.png" max-width="400px" class="docs-image--right" caption="Named Colors" >}} @@ -148,12 +161,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. diff --git a/docs/sources/installation/configuration.md b/docs/sources/installation/configuration.md index d85e39146dc..f0418ad31a6 100644 --- a/docs/sources/installation/configuration.md +++ b/docs/sources/installation/configuration.md @@ -160,6 +160,13 @@ The path to the directory where the front end files (HTML, JS, and CSS files). Default to `public` which is why the Grafana binary needs to be executed with working directory set to the installation path. +### enable_gzip + +Set this option to `true` to enable HTTP compression, this can improve +transfer speed and bandwidth utilization. It is recommended that most +users set it to `true`. By default it is set to `false` for compatibility +reasons. + ### cert_file Path to the certificate file (if `protocol` is set to `https`). @@ -594,7 +601,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 diff --git a/docs/sources/installation/upgrading.md b/docs/sources/installation/upgrading.md index a476a38c3c5..e235f25b9e9 100644 --- a/docs/sources/installation/upgrading.md +++ b/docs/sources/installation/upgrading.md @@ -117,3 +117,34 @@ 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 +``` + +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 diff --git a/docs/sources/reference/templating.md b/docs/sources/reference/templating.md index bf3fbd6a229..b00e44943ef 100644 --- a/docs/sources/reference/templating.md +++ b/docs/sources/reference/templating.md @@ -38,22 +38,81 @@ documentation article for details on value escaping during interpolation. ### Advanced Formatting Options -> Only available in Grafana v5.1+. - The formatting of the variable interpolation depends on the data source but there are some situations where you might want to change the default formatting. For example, the default for the MySql datasource is to join multiple values as comma-separated with quotes: `'server01','server02'`. In some cases you might want to have a comma-separated string without quotes: `server01,server02`. This is now possible with the advanced formatting options. Syntax: `${var_name:option}` -Filter Option | Example | Raw | Interpolated | Description ------------- | ------------- | ------------- | ------------- | ------------- -`glob` | ${servers:glob} | `'test1', 'test2'` | `{test1,test2}` | (Default) Formats multi-value variable into a glob (for Graphite queries) -`regex` | ${servers:regex} | `'test.', 'test2'` | (test\.|test2) | Formats multi-value variable into a regex string -`pipe` | ${servers:pipe} | `'test.', 'test2'` | test.|test2 | Formats multi-value variable into a pipe-separated string -`csv`| ${servers:csv} | `'test1', 'test2'` | `test1,test2` | Formats multi-value variable as a comma-separated string -`json`| ${servers:json} | `'test1', 'test2'` | `["test1","test2"]` | Formats multi-value variable as a JSON string -`distributed`| ${servers:distributed} | `'test1', 'test2'` | `test1,servers=test2` | Formats multi-value variable in custom format for OpenTSDB. -`lucene`| ${servers:lucene} | `'test', 'test2'` | `("test" OR "test2")` | Formats multi-value variable as a lucene expression. -`percentencode` | ${servers:percentencode} | `'foo()bar BAZ', 'test2'` | `{foo%28%29bar%20BAZ%2Ctest2}` | Formats multi-value variable into a glob, percent-encoded. +#### Glob +Formats multi-value variable into a glob (for Graphite queries). + +```bash +servers = ['test1', 'test2'] +String to interpolate: '${servers:glob}' +Interpolation result: '{test1,test2}' +``` + +### Regex +Formats multi-value variable into a regex string. + +```bash +servers = ['test1.', 'test2'] +String to interpolate: '${servers:regex}' +Interpolation result: '(test\.|test2)' +``` + +### Pipe +Formats multi-value variable into a pipe-separated string. + +```bash +servers = ['test1.', 'test2'] +String to interpolate: '${servers:pipe}' +Interpolation result: 'test.|test2' +``` + +### Csv +Formats multi-value variable as a comma-separated string. + +```bash +servers = ['test1', 'test2'] +String to interpolate: '${servers:csv}' +Interpolation result: 'test,test2' +``` + +### Json +Formats multi-value variable as a comma-separated string. + +```bash +servers = ['test1', 'test2'] +String to interpolate: '${servers:json}' +Interpolation result: '["test1", "test2"]' +``` + +### Distributed +Formats multi-value variable in custom format for OpenTSDB. + +```bash +servers = ['test1', 'test2'] +String to interpolate: '${servers:distributed}' +Interpolation result: 'test1,servers=test2' +``` + +### Lucene +Formats multi-value variable in lucene format for Elasticsearch. + +```bash +servers = ['test1', 'test2'] +String to interpolate: '${servers:lucene}' +Interpolation result: '("test1" OR "test2")' +``` + +### Percentencode +Formats single & multi valued variables for use in URL parameters. + +```bash +servers = ['foo()bar BAZ', 'test2'] +String to interpolate: '${servers:lucene}' +Interpolation result: 'foo%28%29bar%20BAZ%2Ctest2' +``` Test the formatting options on the [Grafana Play site](http://play.grafana.org/d/cJtIfcWiz/template-variable-formatting-options?orgId=1). diff --git a/docs/sources/tutorials/ha_setup.md b/docs/sources/tutorials/ha_setup.md index f141392e223..f20a9933126 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,8 +24,14 @@ 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/). + 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 @@ -41,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. diff --git a/package.json b/package.json index 0076af4c0bd..71339bee2be 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "postcss-browser-reporter": "^0.5.0", "postcss-loader": "^2.0.6", "postcss-reporter": "^5.0.0", - "prettier": "1.9.2", + "prettier": "1.16.4", "react-hot-loader": "^4.3.6", "react-test-renderer": "^16.5.0", "redux-mock-store": "^1.5.3", @@ -128,7 +128,8 @@ "jest": "jest --notify --watch", "api-tests": "jest --notify --watch --config=tests/api/jest.js", "storybook": "cd packages/grafana-ui && yarn storybook", - "themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts" + "themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts", + "prettier:check": "prettier --list-different \"**/*.{ts,tsx,scss}\"" }, "husky": { "hooks": { @@ -136,11 +137,7 @@ } }, "lint-staged": { - "*.{ts,tsx}": [ - "prettier --write", - "git add" - ], - "*.scss": [ + "*.{ts,tsx,json,scss}": [ "prettier --write", "git add" ], @@ -164,6 +161,7 @@ "angular-native-dragdrop": "1.2.2", "angular-route": "1.6.6", "angular-sanitize": "1.6.6", + "ansicolor": "1.1.78", "baron": "^3.0.3", "brace": "^0.10.0", "classnames": "^2.2.6", diff --git a/packages/grafana-ui/src/components/ColorPicker/ColorPicker.story.tsx b/packages/grafana-ui/src/components/ColorPicker/ColorPicker.story.tsx index 1fb31e86d72..f7fa71391ae 100644 --- a/packages/grafana-ui/src/components/ColorPicker/ColorPicker.story.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/ColorPicker.story.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { storiesOf } from '@storybook/react'; -import { boolean } from '@storybook/addon-knobs'; +import { boolean } from '@storybook/addon-knobs'; import { SeriesColorPicker, ColorPicker } from './ColorPicker'; import { action } from '@storybook/addon-actions'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; diff --git a/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx b/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx index a48ecc44c45..27371d5515f 100644 --- a/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/ColorPicker.tsx @@ -30,7 +30,7 @@ export const warnAboutColorPickerPropsDeprecation = (componentName: string, prop export const colorPickerFactory = ( popover: React.ComponentType, - displayName = 'ColorPicker', + displayName = 'ColorPicker' ) => { return class ColorPicker extends Component { static displayName = displayName; diff --git a/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.test.tsx b/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.test.tsx index 444f0e658c8..7a5000653d4 100644 --- a/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.test.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.test.tsx @@ -15,7 +15,7 @@ describe('ColorPickerPopover', () => { describe('rendering', () => { it('should render provided color as selected if color provided by name', () => { - const wrapper = mount( {}} theme={getTheme()}/>); + const wrapper = mount( {}} theme={getTheme()} />); const selectedSwatch = wrapper.find(ColorSwatch).findWhere(node => node.key() === BasicGreen.name); const notSelectedSwatches = wrapper.find(ColorSwatch).filterWhere(node => node.prop('isSelected') === false); @@ -25,7 +25,9 @@ describe('ColorPickerPopover', () => { }); it('should render provided color as selected if color provided by hex', () => { - const wrapper = mount( {}} theme={getTheme()} />); + const wrapper = mount( + {}} theme={getTheme()} /> + ); const selectedSwatch = wrapper.find(ColorSwatch).findWhere(node => node.key() === BasicGreen.name); const notSelectedSwatches = wrapper.find(ColorSwatch).filterWhere(node => node.prop('isSelected') === false); @@ -46,7 +48,11 @@ describe('ColorPickerPopover', () => { it('should pass hex color value to onChange prop by default', () => { wrapper = mount( - + ); const basicBlueSwatch = wrapper.find(ColorSwatch).findWhere(node => node.key() === BasicBlue.name); diff --git a/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx b/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx index b4c77a5e373..d3d70175c4b 100644 --- a/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/ColorPickerPopover.tsx @@ -119,4 +119,3 @@ export class ColorPickerPopover extends React ); } } - diff --git a/packages/grafana-ui/src/components/ColorPicker/NamedColorsPalette.test.tsx b/packages/grafana-ui/src/components/ColorPicker/NamedColorsPalette.test.tsx index 7a1ba95e81d..1f2ce33d235 100644 --- a/packages/grafana-ui/src/components/ColorPicker/NamedColorsPalette.test.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/NamedColorsPalette.test.tsx @@ -7,7 +7,6 @@ import { getTheme } from '../../themes'; import { GrafanaThemeType } from '../../types'; describe('NamedColorsPalette', () => { - const BasicGreen = getColorDefinitionByName('green'); describe('theme support for named colors', () => { @@ -23,13 +22,15 @@ describe('NamedColorsPalette', () => { expect(selectedSwatch.prop('color')).toBe(BasicGreen.variants.dark); wrapper.unmount(); - wrapper = mount( {}} />); + wrapper = mount( + {}} /> + ); selectedSwatch = wrapper.find(ColorSwatch).findWhere(node => node.key() === BasicGreen.name); expect(selectedSwatch.prop('color')).toBe(BasicGreen.variants.light); }); it('should render dar variant of provided color when theme not provided', () => { - wrapper = mount( {}} theme={getTheme()}/>); + wrapper = mount( {}} theme={getTheme()} />); selectedSwatch = wrapper.find(ColorSwatch).findWhere(node => node.key() === BasicGreen.name); expect(selectedSwatch.prop('color')).toBe(BasicGreen.variants.dark); }); diff --git a/packages/grafana-ui/src/components/ColorPicker/SpectrumPalettePointer.tsx b/packages/grafana-ui/src/components/ColorPicker/SpectrumPalettePointer.tsx index 7e3b2cf06a3..5790de86e29 100644 --- a/packages/grafana-ui/src/components/ColorPicker/SpectrumPalettePointer.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/SpectrumPalettePointer.tsx @@ -15,7 +15,6 @@ const SpectrumPalettePointer: React.FunctionComponent = ({ children }) => { + return
{children}
; +}; + +export { EmptySearchResult }; diff --git a/packages/grafana-ui/src/components/EmptySearchResult/_EmptySearchResult.scss b/packages/grafana-ui/src/components/EmptySearchResult/_EmptySearchResult.scss new file mode 100644 index 00000000000..72e31b3828d --- /dev/null +++ b/packages/grafana-ui/src/components/EmptySearchResult/_EmptySearchResult.scss @@ -0,0 +1,8 @@ +.empty-search-result { + border-left: 3px solid $info-box-border-color; + background-color: $empty-list-cta-bg; + padding: $spacer; + min-width: 350px; + border-radius: $border-radius; + margin-bottom: $spacer * 2; +} diff --git a/packages/grafana-ui/src/components/FormLabel/FormLabel.tsx b/packages/grafana-ui/src/components/FormLabel/FormLabel.tsx index 0cf7857b0d9..eceaa064808 100644 --- a/packages/grafana-ui/src/components/FormLabel/FormLabel.tsx +++ b/packages/grafana-ui/src/components/FormLabel/FormLabel.tsx @@ -31,7 +31,7 @@ export const FormLabel: FunctionComponent = ({