diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fe9edf30eb..181ba0719cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ -# 5.4.0 (unreleased) +# 5.5.0 (unreleased) + +### Minor + +* **Elasticsearch**: Add support for offset in date histogram aggregation [#12653](https://github.com/grafana/grafana/issues/12653), thx [@mattiarossi](https://github.com/mattiarossi) +* **Auth**: Prevent password reset when login form is disabled or either LDAP or Auth Proxy is enabled [#14246](https://github.com/grafana/grafana/issues/14246), thx [@SilverFire](https://github.com/SilverFire) +* **Dataproxy**: Override incoming Authorization header [#13815](https://github.com/grafana/grafana/issues/13815), thx [@kornholi](https://github.com/kornholi) + +# 5.4.0 (2018-12-03) * **Cloudwatch**: Fix invalid time range causes segmentation fault [#14150](https://github.com/grafana/grafana/issues/14150) +* **Cloudwatch**: AWS/CodeBuild metrics and dimensions [#14167](https://github.com/grafana/grafana/issues/14167), thx [@mmcoltman](https://github.com/mmcoltman) +* **MySQL**: Fix `$__timeFrom()` and `$__timeTo()` should respect local time zone [#14228](https://github.com/grafana/grafana/issues/14228) ### 5.4.0-beta1 fixes * **Graph**: Fix legend always visible even if configured to be hidden [#14144](https://github.com/grafana/grafana/issues/14144) @@ -160,7 +170,7 @@ See [security announcement](https://community.grafana.com/t/grafana-5-3-3-and-4- * **Alerting**: Fix rendering timeout which could cause notifications to not be sent due to rendering timing out [#12151](https://github.com/grafana/grafana/issues/12151) * **Docker**: Make it possible to set a specific plugin url [#12861](https://github.com/grafana/grafana/pull/12861), thx [ClementGautier](https://github.com/ClementGautier) * **GrafanaCli**: Fixed issue with grafana-cli install plugin resulting in corrupt http response from source error. Fixes [#13079](https://github.com/grafana/grafana/issues/13079) -* **Provisioning**: Should allow one default datasource per organisation [#12229](https://github.com/grafana/grafana/issues/12229) +* **Provisioning**: Should allow one default datasource per organization [#12229](https://github.com/grafana/grafana/issues/12229) * **Github OAuth**: Allow changes of user info at Github to be synched to Grafana when signing in [#11818](https://github.com/grafana/grafana/issues/11818), thx [@rwaweber](https://github.com/rwaweber) * **OAuth**: Fix overriding tls_skip_verify_insecure using environment variable [#12747](https://github.com/grafana/grafana/issues/12747), thx [@jangaraj](https://github.com/jangaraj) * **Prometheus**: Fix graph panel bar width issue in aligned prometheus queries [#12379](https://github.com/grafana/grafana/issues/12379) @@ -283,7 +293,7 @@ See [security announcement](https://community.grafana.com/t/grafana-5-2-3-and-4- * **Dashboard**: Prevent double-click when saving dashboard [#11963](https://github.com/grafana/grafana/issues/11963) * **Dashboard**: AutoFocus the add-panel search filter [#12189](https://github.com/grafana/grafana/pull/12189) thx [@ryantxu](https://github.com/ryantxu) * **Units**: W/m2 (energy), l/h (flow) and kPa (pressure) [#11233](https://github.com/grafana/grafana/pull/11233), thx [@flopp999](https://github.com/flopp999) -* **Units**: Litre/min (flow) and milliLitre/min (flow) [#12282](https://github.com/grafana/grafana/pull/12282), thx [@flopp999](https://github.com/flopp999) +* **Units**: Liter/min (flow) and milliLiter/min (flow) [#12282](https://github.com/grafana/grafana/pull/12282), thx [@flopp999](https://github.com/flopp999) * **Alerting**: Fix mobile notifications for Microsoft Teams alert notifier [#11484](https://github.com/grafana/grafana/pull/11484), thx [@manacker](https://github.com/manacker) * **Influxdb**: Add support for mode function [#12286](https://github.com/grafana/grafana/issues/12286) * **Cloudwatch**: Fixes panic caused by bad timerange settings [#12199](https://github.com/grafana/grafana/issues/12199) @@ -418,7 +428,7 @@ See [security announcement](https://community.grafana.com/t/grafana-5-2-3-and-4- * **Units**: Use B/s instead Bps for Bytes per second [#9342](https://github.com/grafana/grafana/pull/9342), thx [@mayli](https://github.com/mayli) * **Units**: Radiation units [#11001](https://github.com/grafana/grafana/issues/11001), thx [@victorclaessen](https://github.com/victorclaessen) * **Units**: Timeticks unit [#11183](https://github.com/grafana/grafana/pull/11183), thx [@jtyr](https://github.com/jtyr) -* **Units**: Concentration units and "Normal cubic metre" [#11211](https://github.com/grafana/grafana/issues/11211), thx [@flopp999](https://github.com/flopp999) +* **Units**: Concentration units and "Normal cubic meter" [#11211](https://github.com/grafana/grafana/issues/11211), thx [@flopp999](https://github.com/flopp999) * **Units**: New currency - Czech koruna [#11384](https://github.com/grafana/grafana/pull/11384), thx [@Rohlik](https://github.com/Rohlik) * **Avatar**: Fix DISABLE_GRAVATAR option [#11095](https://github.com/grafana/grafana/issues/11095) * **Heatmap**: Disable log scale when using time time series buckets [#10792](https://github.com/grafana/grafana/issues/10792) @@ -735,7 +745,7 @@ See [security announcement](https://community.grafana.com/t/grafana-5-2-3-and-4- ## Enhancements * **GitHub OAuth**: Support for GitHub organizations with 100+ teams. [#8846](https://github.com/grafana/grafana/issues/8846), thx [@skwashd](https://github.com/skwashd) -* **Graphite**: Calls to Graphite api /metrics/find now include panel or dashboad time range (from & until) in most cases, [#8055](https://github.com/grafana/grafana/issues/8055) +* **Graphite**: Calls to Graphite api /metrics/find now include panel or dashboard time range (from & until) in most cases, [#8055](https://github.com/grafana/grafana/issues/8055) * **Graphite**: Added new graphite 1.0 functions, available if you set version to 1.0.x in data source settings. New Functions: mapSeries, reduceSeries, isNonNull, groupByNodes, offsetToZero, grep, weightedAverage, removeEmptySeries, aggregateLine, averageOutsidePercentile, delay, exponentialMovingAverage, fallbackSeries, integralByInterval, interpolate, invert, linearRegression, movingMin, movingMax, movingSum, multiplySeriesWithWildcards, pow, powSeries, removeBetweenPercentile, squareRoot, timeSlice, closes [#8261](https://github.com/grafana/grafana/issues/8261) - **Elasticsearch**: Ad-hoc filters now use query phrase match filters instead of term filters, works on non keyword/raw fields [#9095](https://github.com/grafana/grafana/issues/9095). @@ -900,7 +910,7 @@ Pull Request: [#8472](https://github.com/grafana/grafana/pull/8472) * **InfluxDB**: Influxb Datasource test passes even if the Database doesn't exist [#7864](https://github.com/grafana/grafana/issues/7864) * **Prometheus**: Displaying Prometheus annotations is incredibly slow [#7750](https://github.com/grafana/grafana/issues/7750), thx [@mtanda](https://github.com/mtanda) * **Graphite**: grafana generates empty find query to graphite -> 422 Unprocessable Entity [#7740](https://github.com/grafana/grafana/issues/7740) -* **Admin**: make organisation filter case insensitive [#8194](https://github.com/grafana/grafana/issues/8194), thx [@Alexander-N](https://github.com/Alexander-N) +* **Admin**: make organization filter case insensitive [#8194](https://github.com/grafana/grafana/issues/8194), thx [@Alexander-N](https://github.com/Alexander-N) ## Changes * **Elasticsearch**: Changed elasticsearch Terms aggregation to default to Min Doc Count to 1, and sort order to Top [#8321](https://github.com/grafana/grafana/issues/8321) @@ -1028,7 +1038,7 @@ Pull Request: [#8472](https://github.com/grafana/grafana/pull/8472) * **CLI**: Make it possible to reset the admin password using the grafana-cli. [#5479](https://github.com/grafana/grafana/issues/5479) * **Influxdb**: Support multiple tags in InfluxDB annotations. [#4550](https://github.com/grafana/grafana/pull/4550), thx [@adrianlzt](https://github.com/adrianlzt) * **LDAP**: Basic Auth now supports LDAP username and password, [#6940](https://github.com/grafana/grafana/pull/6940), thx [@utkarshcmu](https://github.com/utkarshcmu) -* **LDAP**: Now works with Auth Proxy, role and organisation mapping & sync will regularly be performed. [#6895](https://github.com/grafana/grafana/pull/6895), thx [@Seuf](https://github.com/seuf) +* **LDAP**: Now works with Auth Proxy, role and organization mapping & sync will regularly be performed. [#6895](https://github.com/grafana/grafana/pull/6895), thx [@Seuf](https://github.com/seuf) * **Alerting**: Adds OK as no data option. [#6866](https://github.com/grafana/grafana/issues/6866) * **Alert list**: Order alerts based on state. [#6676](https://github.com/grafana/grafana/issues/6676) * **Alerting**: Add api endpoint for pausing all alerts. [#6589](https://github.com/grafana/grafana/issues/6589) @@ -1167,7 +1177,7 @@ due to too many connections/file handles on the data source backend. This proble * **Scripts**: Use restart instead of start for deb package script, closes [#5282](https://github.com/grafana/grafana/pull/5282) * **Logging**: Moved to structured logging lib, and moved to component specific level filters via config file, closes [#4590](https://github.com/grafana/grafana/issues/4590) * **OpenTSDB**: Support nested template variables in tag_values function, closes [#4398](https://github.com/grafana/grafana/issues/4398) -* **Datasource**: Pending data source requests are cancelled before new ones are issues (Graphite & Prometheus), closes [#5321](https://github.com/grafana/grafana/issues/5321) +* **Datasource**: Pending data source requests are canceled before new ones are issues (Graphite & Prometheus), closes [#5321](https://github.com/grafana/grafana/issues/5321) ### Breaking changes * **Logging** : Changed default logging output format (now structured into message, and key value pairs, with logger key acting as component). You can also no change in config to json log output. @@ -1871,7 +1881,7 @@ Read this [blog post](https://grafana.com/blog/2014/09/11/grafana-1.8.0-rc1-rele #### Fixes - [Issue #126](https://github.com/grafana/grafana/issues/126). Graphite query lexer change, can now handle regex parameters for aliasSub function -- [Issue #447](https://github.com/grafana/grafana/issues/447). Filter option loading when having muliple nested filters now works better. Options are now reloaded correctly and there are no multiple renders/refresh in between. +- [Issue #447](https://github.com/grafana/grafana/issues/447). Filter option loading when having multiple nested filters now works better. Options are now reloaded correctly and there are no multiple renders/refresh in between. - [Issue #412](https://github.com/grafana/grafana/issues/412). After a filter option is changed and a nested template param is reloaded, if the current value exists after the options are reloaded the current selected value is kept. - [Issue #460](https://github.com/grafana/grafana/issues/460). Legend Current value did not display when value was zero - [Issue #328](https://github.com/grafana/grafana/issues/328). Fix to series toggling bug that caused annotations to be hidden when toggling/hiding series. @@ -1906,7 +1916,7 @@ Read this [blog post](https://grafana.com/blog/2014/09/11/grafana-1.8.0-rc1-rele - Graphite errors are now much easier to see and troubleshoot with the new inspector ([Issue #265](https://github.com/grafana/grafana/issues/265)) - Use influxdb aliases to distinguish between multiple columns ([Issue #283](https://github.com/grafana/grafana/issues/283)) - Correction to ms axis formater, now formats days correctly. ([Issue #189](https://github.com/grafana/grafana/issues/189)) -- Css fix for Firefox and using top menu dropdowns in panel fullscren / edit mode ([Issue #106](https://github.com/grafana/grafana/issues/106)) +- Css fix for Firefox and using top menu dropdowns in panel fullscreen / edit mode ([Issue #106](https://github.com/grafana/grafana/issues/106)) - Browser page title is now Grafana - {{dashboard title}} ([Issue #294](https://github.com/grafana/grafana/issues/294)) - Disable auto refresh zooming in (every time you change to an absolute time range), refresh will be restored when you change time range back to relative ([Issue #282](https://github.com/grafana/grafana/issues/282)) - More graphite functions diff --git a/README.md b/README.md index 5882ea8a6a3..269c525e983 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ Choose this option to build on platforms other than linux/amd64 and/or not have The resulting image will be tagged as `grafana/grafana:dev` +Notice: If you are using Docker for MacOS, be sure to let limit of Memory bigger than 2 GiB (at docker -> Perferences -> Advanced), otherwize you may faild at `grunt build` + ### Dev config Create a custom.ini in the conf directory to override default configuration options. diff --git a/UPGRADING_DEPENDENCIES.md b/UPGRADING_DEPENDENCIES.md index f3d2adbd71a..7d489556981 100644 --- a/UPGRADING_DEPENDENCIES.md +++ b/UPGRADING_DEPENDENCIES.md @@ -47,7 +47,7 @@ Our builds run on CircleCI through our build script. ### grafana/build-container -The main build step (in CircleCI) is built using a custom build container that comes pre-baked with some of the neccesary dependencies. +The main build step (in CircleCI) is built using a custom build container that comes pre-baked with some of the necessary dependencies. Link: [grafana-build-container](https://github.com/grafana/grafana-build-container) @@ -86,4 +86,4 @@ There is a Docker build for Grafana in the root of the project that allows anyon ### Local developer environments -Please send out a notice in the grafana-dev slack channel when updating Go or Node.js to make it easier for everyone to update their local developer environments. \ No newline at end of file +Please send out a notice in the grafana-dev slack channel when updating Go or Node.js to make it easier for everyone to update their local developer environments. diff --git a/conf/defaults.ini b/conf/defaults.ini index 306c625d980..a9aa2239b16 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -34,7 +34,7 @@ protocol = http # The ip address to bind to, empty will bind to all interfaces http_addr = -# The http port to use +# The http port to use http_port = 3000 # The public facing domain name used to access grafana from a browser @@ -166,7 +166,7 @@ google_tag_manager_id = # default admin user, created on startup admin_user = admin -# default admin password, can be changed before first start of grafana, or in profile settings +# default admin password, can be changed before first start of grafana, or in profile settings admin_password = admin # used for signing @@ -372,7 +372,7 @@ templates_pattern = emails/*.html #################################### Logging ########################## [log] -# Either "console", "file", "syslog". Default is console and file +# Either "console", "file", "syslog". Default is console and file # Use space to separate multiple modes, e.g. "console file" mode = console file @@ -565,4 +565,3 @@ enable_alpha = false [enterprise] license_path = - diff --git a/conf/provisioning/datasources/sample.yaml b/conf/provisioning/datasources/sample.yaml index 37487dc4b3b..7bef8618a31 100644 --- a/conf/provisioning/datasources/sample.yaml +++ b/conf/provisioning/datasources/sample.yaml @@ -7,7 +7,7 @@ apiVersion: 1 # orgId: 1 # # list of datasources to insert/update depending -# # on what's available in the datbase +# # on what's available in the database #datasources: # # name of the datasource. Required # - name: Graphite diff --git a/conf/sample.ini b/conf/sample.ini index c6b716a731d..3c61b2b61d1 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -145,6 +145,9 @@ log_queries = # Google Analytics universal tracking code, only enabled if you specify an id here ;google_analytics_ua_id = +# Google Tag Manager ID, only enabled if you specify an id here +;google_tag_manager_id = + #################################### Security #################################### [security] # default admin user, created on startup diff --git a/docs/sources/administration/provisioning.md b/docs/sources/administration/provisioning.md index 60e89b486a5..b2a1b1f42e7 100644 --- a/docs/sources/administration/provisioning.md +++ b/docs/sources/administration/provisioning.md @@ -230,4 +230,4 @@ By default Grafana will delete dashboards in the database if the file is removed > **Note.** Provisioning allows you to overwrite existing dashboards > which leads to problems if you re-use settings that are supposed to be unique. > Be careful not to re-use the same `title` multiple times within a folder -> or `uid` within the same installation as this will cause weird behaviours. +> or `uid` within the same installation as this will cause weird behaviors. diff --git a/docs/sources/alerting/notifications.md b/docs/sources/alerting/notifications.md index 54d046749a9..e791492495e 100644 --- a/docs/sources/alerting/notifications.md +++ b/docs/sources/alerting/notifications.md @@ -136,7 +136,7 @@ In DingTalk PC Client: 2. Click "Robot Manage" item in the pop menu, there will be a new panel call "Robot Manage". -3. In the "Robot Manage" panel, select "customised: customised robot with Webhook". +3. In the "Robot Manage" panel, select "customized: customized robot with Webhook". 4. In the next new panel named "robot detail", click "Add" button. diff --git a/docs/sources/auth/ldap.md b/docs/sources/auth/ldap.md index 4313b563d9e..d0ae9094d66 100644 --- a/docs/sources/auth/ldap.md +++ b/docs/sources/auth/ldap.md @@ -163,9 +163,9 @@ org_role = "Viewer" Setting | Required | Description | Default ------------ | ------------ | ------------- | ------------- `group_dn` | Yes | LDAP distinguished name (DN) of LDAP group. If you want to match all (or no LDAP groups) then you can use wildcard (`"*"`) | -`org_role` | Yes | Assign users of `group_dn` the organisation role `"Admin"`, `"Editor"` or `"Viewer"` | +`org_role` | Yes | Assign users of `group_dn` the organization role `"Admin"`, `"Editor"` or `"Viewer"` | `org_id` | No | The Grafana organization database id. Setting this allows for multiple group_dn's to be assigned to the same `org_role` provided the `org_id` differs | `1` (default org id) -`grafana_admin` | No | When `true` makes user of `group_dn` Grafana server admin. A Grafana server admin has admin access over all organisations and users. Available in Grafana v5.3 and above | `false` +`grafana_admin` | No | When `true` makes user of `group_dn` Grafana server admin. A Grafana server admin has admin access over all organizations and users. Available in Grafana v5.3 and above | `false` ### Nested/recursive group membership diff --git a/docs/sources/contribute/cla.md b/docs/sources/contribute/cla.md index a073a9a4eae..9a78b651d28 100644 --- a/docs/sources/contribute/cla.md +++ b/docs/sources/contribute/cla.md @@ -1,6 +1,6 @@ +++ -title = "Contributor Licence Agreement (CLA)" -description = "Contributor Licence Agreement (CLA)" +title = "Contributor License Agreement (CLA)" +description = "Contributor License Agreement (CLA)" type = "docs" aliases = ["/project/cla", "docs/contributing/cla.html"] [menu.docs] diff --git a/docs/sources/enterprise/index.md b/docs/sources/enterprise/index.md index f65fa55f02b..5d524dcbee2 100644 --- a/docs/sources/enterprise/index.md +++ b/docs/sources/enterprise/index.md @@ -31,7 +31,7 @@ Datasource permissions allow you to restrict query access to only specific Teams ### Premium Plugins -With a Grafana Enterprise licence you will get access to premium plugins, including: +With a Grafana Enterprise license you will get access to premium plugins, including: * [Splunk](https://grafana.com/plugins/grafana-splunk-datasource) * [AppDynamics](https://grafana.com/plugins/dlopes7-appdynamics-datasource) diff --git a/docs/sources/features/datasources/mysql.md b/docs/sources/features/datasources/mysql.md index bc4e4df6cf9..371c92cde70 100644 --- a/docs/sources/features/datasources/mysql.md +++ b/docs/sources/features/datasources/mysql.md @@ -133,9 +133,9 @@ Macro example | Description ------------ | ------------- *$__time(dateColumn)* | Will be replaced by an expression to convert to a UNIX timestamp and rename the column to `time_sec`. For example, *UNIX_TIMESTAMP(dateColumn) as time_sec* *$__timeEpoch(dateColumn)* | Will be replaced by an expression to convert to a UNIX timestamp and rename the column to `time_sec`. For example, *UNIX_TIMESTAMP(dateColumn) as time_sec* -*$__timeFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name. For example, *dateColumn BETWEEN '2017-04-21T05:01:17Z' AND '2017-04-21T05:06:17Z'* -*$__timeFrom()* | Will be replaced by the start of the currently active time selection. For example, *'2017-04-21T05:01:17Z'* -*$__timeTo()* | Will be replaced by the end of the currently active time selection. For example, *'2017-04-21T05:06:17Z'* +*$__timeFilter(dateColumn)* | Will be replaced by a time range filter using the specified column name. For example, *dateColumn BETWEEN FROM_UNIXTIME(1494410783) AND FROM_UNIXTIME(1494410983)* +*$__timeFrom()* | Will be replaced by the start of the currently active time selection. For example, *FROM_UNIXTIME(1494410783)* +*$__timeTo()* | Will be replaced by the end of the currently active time selection. For example, *FROM_UNIXTIME(1494410983)* *$__timeGroup(dateColumn,'5m')* | Will be replaced by an expression usable in GROUP BY clause. For example, *cast(cast(UNIX_TIMESTAMP(dateColumn)/(300) as signed)*300 as signed),* *$__timeGroup(dateColumn,'5m', 0)* | Same as above but with a fill parameter so missing points in that series will be added by grafana and 0 will be used as value. *$__timeGroup(dateColumn,'5m', NULL)* | Same as above but NULL will be used as value for missing points. diff --git a/docs/sources/guides/whats-new-in-v4.md b/docs/sources/guides/whats-new-in-v4.md index 7b0d2259580..1b4ed1c2a65 100644 --- a/docs/sources/guides/whats-new-in-v4.md +++ b/docs/sources/guides/whats-new-in-v4.md @@ -134,7 +134,7 @@ continue work on a `build mode` for a future release. The new row menu automatically slides out when you mouse over the edge of the row. You no longer need to hover over the small green icon and then click it to expand the row menu. -There are some minor improvements to drag and drop behaviour. Now when dragging a panel from one row +There are some minor improvements to drag and drop behavior. Now when dragging a panel from one row to another you will insert the panel and Grafana will automatically make room for it. When you drag a panel within a row you will simply reorder the panels. diff --git a/docs/sources/http_api/index.md b/docs/sources/http_api/index.md index 2a74917a9fd..9e3d69363e8 100644 --- a/docs/sources/http_api/index.md +++ b/docs/sources/http_api/index.md @@ -26,7 +26,7 @@ dashboards, creating users and updating data sources. * [Folder Permissions API]({{< relref "http_api/folder_permissions.md" >}}) * [Folder/dashboard search API]({{< relref "/http_api/folder_dashboard_search.md" >}}) * [Data Source API]({{< relref "http_api/data_source.md" >}}) -* [Organisation API]({{< relref "http_api/org.md" >}}) +* [Organization API]({{< relref "http_api/org.md" >}}) * [Snapshot API]({{< relref "http_api/snapshot.md" >}}) * [Annotations API]({{< relref "http_api/annotations.md" >}}) * [Alerting API]({{< relref "http_api/alerting.md" >}}) diff --git a/docs/sources/http_api/org.md b/docs/sources/http_api/org.md index c55107d42f8..d1eb4ea0972 100644 --- a/docs/sources/http_api/org.md +++ b/docs/sources/http_api/org.md @@ -1,24 +1,24 @@ +++ -title = "Organisation HTTP API " -description = "Grafana Organisation HTTP API" -keywords = ["grafana", "http", "documentation", "api", "organisation"] -aliases = ["/http_api/organisation/"] +title = "Organization HTTP API " +description = "Grafana Organization HTTP API" +keywords = ["grafana", "http", "documentation", "api", "organization"] +aliases = ["/http_api/organization/"] type = "docs" [menu.docs] -name = "Organisation" +name = "Organization" parent = "http_api" +++ -# Organisation API +# Organization API -The Organisation HTTP API is divided in two resources, `/api/org` (current organisation) -and `/api/orgs` (admin organisations). One big difference between these are that -the admin of all organisations API only works with basic authentication, see [Admin Organisations API](#admin-organisations-api) for more information. +The Organization HTTP API is divided in two resources, `/api/org` (current organization) +and `/api/orgs` (admin organizations). One big difference between these are that +the admin of all organizations API only works with basic authentication, see [Admin Organizations API](#admin-organizations-api) for more information. -## Current Organisation API +## Current Organization API -### Get current Organisation +### Get current Organization `GET /api/org/` @@ -43,7 +43,7 @@ Content-Type: application/json } ``` -### Get all users within the current organisation +### Get all users within the current organization `GET /api/org/users` @@ -99,7 +99,7 @@ Content-Type: application/json {"message":"Organization user updated"} ``` -### Delete user in current organisation +### Delete user in current organization `DELETE /api/org/users/:userId` @@ -121,7 +121,7 @@ Content-Type: application/json {"message":"User removed from organization"} ``` -### Update current Organisation +### Update current Organization `PUT /api/org` @@ -147,11 +147,11 @@ Content-Type: application/json {"message":"Organization updated"} ``` -### Add a new user to the current organisation +### Add a new user to the current organization `POST /api/org/users` -Adds a global user to the current organisation. +Adds a global user to the current organization. **Example Request**: @@ -176,19 +176,19 @@ Content-Type: application/json {"message":"User added to organization"} ``` -## Admin Organisations API +## Admin Organizations API -The Admin Organisations HTTP API does not currently work with an API Token. API Tokens are currently +The Admin Organizations HTTP API does not currently work with an API Token. API Tokens are currently only linked to an organization and an organization role. They cannot be given the permission of server admin, only users can be given that permission. So in order to use these API calls you will have to use Basic Auth and the Grafana user must have the Grafana Admin permission (The default admin user is called `admin` and has permission to use this API). -### Get Organisation by Id +### Get Organization by Id `GET /api/orgs/:orgId` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -217,11 +217,11 @@ Content-Type: application/json } } ``` -### Get Organisation by Name +### Get Organization by Name `GET /api/orgs/name/:orgName` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -251,11 +251,11 @@ Content-Type: application/json } ``` -### Create Organisation +### Create Organization `POST /api/orgs` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -284,11 +284,11 @@ Content-Type: application/json } ``` -### Search all Organisations +### Search all Organizations `GET /api/orgs` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -314,12 +314,12 @@ Content-Type: application/json ] ``` -### Update Organisation +### Update Organization `PUT /api/orgs/:orgId` -Update Organisation, fields *Address 1*, *Address 2*, *City* are not implemented yet. -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Update Organization, fields *Address 1*, *Address 2*, *City* are not implemented yet. +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -342,11 +342,11 @@ Content-Type: application/json {"message":"Organization updated"} ``` -### Delete Organisation +### Delete Organization `DELETE /api/orgs/:orgId` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -364,11 +364,11 @@ Content-Type: application/json {"message":"Organization deleted"} ``` -### Get Users in Organisation +### Get Users in Organization `GET /api/orgs/:orgId/users` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -397,11 +397,11 @@ Content-Type: application/json ] ``` -### Add User in Organisation +### Add User in Organization `POST /api/orgs/:orgId/users` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -425,11 +425,11 @@ Content-Type: application/json {"message":"User added to organization"} ``` -### Update Users in Organisation +### Update Users in Organization `PATCH /api/orgs/:orgId/users/:userId` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: @@ -452,11 +452,11 @@ Content-Type: application/json {"message":"Organization user updated"} ``` -### Delete User in Organisation +### Delete User in Organization `DELETE /api/orgs/:orgId/users/:userId` -Only works with Basic Authentication (username and password), see [introduction](#admin-organisations-api). +Only works with Basic Authentication (username and password), see [introduction](#admin-organizations-api). **Example Request**: diff --git a/docs/sources/http_api/user.md b/docs/sources/http_api/user.md index 047d4473603..a7b6c96aac5 100644 --- a/docs/sources/http_api/user.md +++ b/docs/sources/http_api/user.md @@ -196,7 +196,7 @@ Content-Type: application/json {"message":"User updated"} ``` -## Get Organisations for user +## Get Organizations for user `GET /api/users/:id/orgs` @@ -367,11 +367,11 @@ Content-Type: application/json {"message":"Active organization changed"} ``` -## Organisations of the actual User +## Organizations of the actual User `GET /api/user/orgs` -Return a list of all organisations of the current user. +Return a list of all organizations of the current user. **Example Request**: diff --git a/docs/sources/reference/export_import.md b/docs/sources/reference/export_import.md index 31f32d890f6..501e9aca62b 100644 --- a/docs/sources/reference/export_import.md +++ b/docs/sources/reference/export_import.md @@ -107,3 +107,5 @@ it as usual and then update the data source option in the metrics tab so that th data source. Another alternative is to open the json file in a a text editor and update the data source properties to value that matches a name of your data source. +## Note +In Grafana v5.3.4+ the export modal has new checkbox for sharing for external use (other instances). If the checkbox is not checked then the `__inputs` section will not be included in the exported JSON file. diff --git a/docs/versions.json b/docs/versions.json index 48962a783ae..b1e447d5aa0 100644 --- a/docs/versions.json +++ b/docs/versions.json @@ -1,5 +1,6 @@ [ - { "version": "v5.3", "path": "/", "archived": false, "current": true }, + { "version": "v5.4", "path": "/", "archived": false, "current": true }, + { "version": "v5.3", "path": "/v5.3", "archived": true }, { "version": "v5.2", "path": "/v5.2", "archived": true }, { "version": "v5.1", "path": "/v5.1", "archived": true }, { "version": "v5.0", "path": "/v5.0", "archived": true }, diff --git a/latest.json b/latest.json index 5e72c11c1f2..d36158608bf 100644 --- a/latest.json +++ b/latest.json @@ -1,4 +1,4 @@ { - "stable": "5.3.4", - "testing": "5.3.4" + "stable": "5.4.0", + "testing": "5.4.0" } diff --git a/package.json b/package.json index 68b7647fb58..f5e6e22a8a2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "company": "Grafana Labs" }, "name": "grafana", - "version": "5.4.0-pre1", + "version": "5.5.0-pre1", "repository": { "type": "git", "url": "http://github.com/grafana/grafana.git" diff --git a/pkg/api/password.go b/pkg/api/password.go index 7dd901c898e..4776c6a3064 100644 --- a/pkg/api/password.go +++ b/pkg/api/password.go @@ -4,10 +4,18 @@ import ( "github.com/grafana/grafana/pkg/api/dtos" "github.com/grafana/grafana/pkg/bus" m "github.com/grafana/grafana/pkg/models" + "github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/util" ) func SendResetPasswordEmail(c *m.ReqContext, form dtos.SendResetPasswordEmailForm) Response { + if setting.LdapEnabled || setting.AuthProxyEnabled { + return Error(401, "Not allowed to reset password when LDAP or Auth Proxy is enabled", nil) + } + if setting.DisableLoginForm { + return Error(401, "Not allowed to reset password when login form is disabled", nil) + } + userQuery := m.GetUserByLoginQuery{LoginOrEmail: form.UserOrEmail} if err := bus.Dispatch(&userQuery); err != nil { diff --git a/pkg/api/pluginproxy/ds_auth_provider.go b/pkg/api/pluginproxy/ds_auth_provider.go index edf43085c7c..5c5776eec07 100644 --- a/pkg/api/pluginproxy/ds_auth_provider.go +++ b/pkg/api/pluginproxy/ds_auth_provider.go @@ -51,7 +51,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route if token, err := tokenProvider.getAccessToken(data); err != nil { logger.Error("Failed to get access token", "error", err) } else { - req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token)) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) } } @@ -60,7 +60,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route if token, err := tokenProvider.getJwtAccessToken(ctx, data); err != nil { logger.Error("Failed to get access token", "error", err) } else { - req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token)) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) } } @@ -73,7 +73,7 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route if err != nil { logger.Error("Failed to get default access token from meta data server", "error", err) } else { - req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) } } } diff --git a/pkg/tsdb/cloudwatch/metric_find_query.go b/pkg/tsdb/cloudwatch/metric_find_query.go index 76eadf1c8dc..dd026bbb79e 100644 --- a/pkg/tsdb/cloudwatch/metric_find_query.go +++ b/pkg/tsdb/cloudwatch/metric_find_query.go @@ -47,6 +47,7 @@ func init() { "AWS/CloudFront": {"Requests", "BytesDownloaded", "BytesUploaded", "TotalErrorRate", "4xxErrorRate", "5xxErrorRate"}, "AWS/CloudSearch": {"SuccessfulRequests", "SearchableDocuments", "IndexUtilization", "Partitions"}, "AWS/CloudHSM": {"HsmUnhealthy", "HsmTemperature", "HsmKeysSessionOccupied", "HsmKeysTokenOccupied", "HsmSslCtxsOccupied", "HsmSessionCount", "HsmUsersAvailable", "HsmUsersMax", "InterfaceEth2OctetsInput", "InterfaceEth2OctetsOutput"}, + "AWS/CodeBuild": {"BuildDuration", "Builds", "DownloadSourceDuration", "Duration", "FailedBuilds", "FinalizingDuration", "InstallDuration", "PostBuildDuration", "PreBuildDuration", "ProvisioningDuration", "QueuedDuration", "SubmittedDuration", "SucceededBuilds", "UploadArtifactsDuration"}, "AWS/Connect": {"CallsBreachingConcurrencyQuota", "CallBackNotDialableNumber", "CallRecordingUploadError", "CallsPerInterval", "ConcurrentCalls", "ConcurrentCallsPercentage", "ContactFlowErrors", "ContactFlowFatalErrors", "LongestQueueWaitTime", "MissedCalls", "MisconfiguredPhoneNumbers", "PublicSigningKeyUsage", "QueueCapacityExceededError", "QueueSize", "ThrottledCalls", "ToInstancePacketLossRate"}, "AWS/DMS": {"FreeableMemory", "WriteIOPS", "ReadIOPS", "WriteThroughput", "ReadThroughput", "WriteLatency", "ReadLatency", "SwapUsage", "NetworkTransmitThroughput", "NetworkReceiveThroughput", "FullLoadThroughputBandwidthSource", "FullLoadThroughputBandwidthTarget", "FullLoadThroughputRowsSource", "FullLoadThroughputRowsTarget", "CDCIncomingChanges", "CDCChangesMemorySource", "CDCChangesMemoryTarget", "CDCChangesDiskSource", "CDCChangesDiskTarget", "CDCThroughputBandwidthTarget", "CDCThroughputRowsSource", "CDCThroughputRowsTarget", "CDCLatencySource", "CDCLatencyTarget"}, "AWS/DX": {"ConnectionState", "ConnectionBpsEgress", "ConnectionBpsIngress", "ConnectionPpsEgress", "ConnectionPpsIngress", "ConnectionCRCErrorCount", "ConnectionLightLevelTx", "ConnectionLightLevelRx"}, @@ -123,6 +124,7 @@ func init() { "AWS/CloudFront": {"DistributionId", "Region"}, "AWS/CloudSearch": {}, "AWS/CloudHSM": {"Region", "ClusterId", "HsmId"}, + "AWS/CodeBuild": {"ProjectName"}, "AWS/Connect": {"InstanceId", "MetricGroup", "Participant", "QueueName", "Stream Type", "Type of Connection"}, "AWS/DMS": {"ReplicationInstanceIdentifier", "ReplicationTaskIdentifier"}, "AWS/DX": {"ConnectionId"}, diff --git a/pkg/tsdb/elasticsearch/client/models.go b/pkg/tsdb/elasticsearch/client/models.go index a0d257d01a6..5307dc34b27 100644 --- a/pkg/tsdb/elasticsearch/client/models.go +++ b/pkg/tsdb/elasticsearch/client/models.go @@ -240,6 +240,7 @@ type DateHistogramAgg struct { Missing *string `json:"missing,omitempty"` ExtendedBounds *ExtendedBounds `json:"extended_bounds"` Format string `json:"format"` + Offset string `json:"offset,omitempty"` } // FiltersAggregation represents a filters aggregation diff --git a/pkg/tsdb/elasticsearch/time_series_query.go b/pkg/tsdb/elasticsearch/time_series_query.go index 869e23e21ce..a25c3cf693d 100644 --- a/pkg/tsdb/elasticsearch/time_series_query.go +++ b/pkg/tsdb/elasticsearch/time_series_query.go @@ -134,6 +134,10 @@ func addDateHistogramAgg(aggBuilder es.AggBuilder, bucketAgg *BucketAgg, timeFro a.Interval = "$__interval" } + if offset, err := bucketAgg.Settings.Get("offset").String(); err == nil { + a.Offset = offset + } + if missing, err := bucketAgg.Settings.Get("missing").String(); err == nil { a.Missing = &missing } diff --git a/pkg/tsdb/mssql/macros.go b/pkg/tsdb/mssql/macros.go index 0a260f7ad70..dac18f3ac03 100644 --- a/pkg/tsdb/mssql/macros.go +++ b/pkg/tsdb/mssql/macros.go @@ -66,6 +66,10 @@ func (m *msSqlMacroEngine) evaluateMacro(name string, args []string) (string, er } return fmt.Sprintf("%s BETWEEN '%s' AND '%s'", args[0], m.timeRange.GetFromAsTimeUTC().Format(time.RFC3339), m.timeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil + case "__timeFrom": + return fmt.Sprintf("'%s'", m.timeRange.GetFromAsTimeUTC().Format(time.RFC3339)), nil + case "__timeTo": + return fmt.Sprintf("'%s'", m.timeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil case "__timeGroup": if len(args) < 2 { return "", fmt.Errorf("macro %v needs time column and interval", name) diff --git a/pkg/tsdb/mssql/macros_test.go b/pkg/tsdb/mssql/macros_test.go index 7456238efa4..43cbe9fefda 100644 --- a/pkg/tsdb/mssql/macros_test.go +++ b/pkg/tsdb/mssql/macros_test.go @@ -52,6 +52,20 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339))) }) + Convey("interpolate __timeFrom function", func() { + sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom()") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "select '2018-04-12T18:00:00Z'") + }) + + Convey("interpolate __timeTo function", func() { + sql, err := engine.Interpolate(query, timeRange, "select $__timeTo()") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "select '2018-04-12T18:05:00Z'") + }) + Convey("interpolate __timeGroup function", func() { sql, err := engine.Interpolate(query, timeRange, "GROUP BY $__timeGroup(time_column,'5m')") So(err, ShouldBeNil) diff --git a/pkg/tsdb/mysql/macros.go b/pkg/tsdb/mysql/macros.go index 839f805568e..c0ed64aa65c 100644 --- a/pkg/tsdb/mysql/macros.go +++ b/pkg/tsdb/mysql/macros.go @@ -61,6 +61,10 @@ func (m *mySqlMacroEngine) evaluateMacro(name string, args []string) (string, er } return fmt.Sprintf("%s BETWEEN FROM_UNIXTIME(%d) AND FROM_UNIXTIME(%d)", args[0], m.timeRange.GetFromAsSecondsEpoch(), m.timeRange.GetToAsSecondsEpoch()), nil + case "__timeFrom": + return fmt.Sprintf("FROM_UNIXTIME(%d)", m.timeRange.GetFromAsSecondsEpoch()), nil + case "__timeTo": + return fmt.Sprintf("FROM_UNIXTIME(%d)", m.timeRange.GetToAsSecondsEpoch()), nil case "__timeGroup": if len(args) < 2 { return "", fmt.Errorf("macro %v needs time column and interval", name) diff --git a/pkg/tsdb/mysql/macros_test.go b/pkg/tsdb/mysql/macros_test.go index 24bf18873d5..49633347a4c 100644 --- a/pkg/tsdb/mysql/macros_test.go +++ b/pkg/tsdb/mysql/macros_test.go @@ -63,6 +63,20 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN FROM_UNIXTIME(%d) AND FROM_UNIXTIME(%d)", from.Unix(), to.Unix())) }) + Convey("interpolate __timeFrom function", func() { + sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom()") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", from.Unix())) + }) + + Convey("interpolate __timeTo function", func() { + sql, err := engine.Interpolate(query, timeRange, "select $__timeTo()") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, fmt.Sprintf("select FROM_UNIXTIME(%d)", to.Unix())) + }) + Convey("interpolate __unixEpochFilter function", func() { sql, err := engine.Interpolate(query, timeRange, "select $__unixEpochFilter(time)") So(err, ShouldBeNil) diff --git a/pkg/tsdb/mysql/mysql_test.go b/pkg/tsdb/mysql/mysql_test.go index 476e3ba6586..fe59a4b9d9d 100644 --- a/pkg/tsdb/mysql/mysql_test.go +++ b/pkg/tsdb/mysql/mysql_test.go @@ -761,7 +761,7 @@ func TestMySQL(t *testing.T) { { DataSource: &models.DataSource{JsonData: simplejson.New()}, Model: simplejson.NewFromAny(map[string]interface{}{ - "rawSql": `SELECT time FROM metric_values WHERE time > $__timeFrom() OR time < $__timeFrom() OR 1 < $__unixEpochFrom() OR $__unixEpochTo() > 1 ORDER BY 1`, + "rawSql": `SELECT time FROM metric_values WHERE time > $__timeFrom() OR time < $__timeTo() OR 1 < $__unixEpochFrom() OR $__unixEpochTo() > 1 ORDER BY 1`, "format": "time_series", }), RefId: "A", @@ -773,7 +773,7 @@ func TestMySQL(t *testing.T) { So(err, ShouldBeNil) queryResult := resp.Results["A"] So(queryResult.Error, ShouldBeNil) - So(queryResult.Meta.Get("sql").MustString(), ShouldEqual, "SELECT time FROM metric_values WHERE time > '2018-03-15T12:55:00Z' OR time < '2018-03-15T12:55:00Z' OR 1 < 1521118500 OR 1521118800 > 1 ORDER BY 1") + So(queryResult.Meta.Get("sql").MustString(), ShouldEqual, "SELECT time FROM metric_values WHERE time > FROM_UNIXTIME(1521118500) OR time < FROM_UNIXTIME(1521118800) OR 1 < 1521118500 OR 1521118800 > 1 ORDER BY 1") }) diff --git a/pkg/tsdb/postgres/macros.go b/pkg/tsdb/postgres/macros.go index 0fa5d8077e1..26a3d1e53ee 100644 --- a/pkg/tsdb/postgres/macros.go +++ b/pkg/tsdb/postgres/macros.go @@ -87,6 +87,10 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string, } return fmt.Sprintf("%s BETWEEN '%s' AND '%s'", args[0], m.timeRange.GetFromAsTimeUTC().Format(time.RFC3339), m.timeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil + case "__timeFrom": + return fmt.Sprintf("'%s'", m.timeRange.GetFromAsTimeUTC().Format(time.RFC3339)), nil + case "__timeTo": + return fmt.Sprintf("'%s'", m.timeRange.GetToAsTimeUTC().Format(time.RFC3339)), nil case "__timeGroup": if len(args) < 2 { return "", fmt.Errorf("macro %v needs time column and interval and optional fill value", name) diff --git a/pkg/tsdb/postgres/macros_test.go b/pkg/tsdb/postgres/macros_test.go index 8a3699f82b2..6a71caedeb9 100644 --- a/pkg/tsdb/postgres/macros_test.go +++ b/pkg/tsdb/postgres/macros_test.go @@ -44,6 +44,20 @@ func TestMacroEngine(t *testing.T) { So(sql, ShouldEqual, fmt.Sprintf("WHERE time_column BETWEEN '%s' AND '%s'", from.Format(time.RFC3339), to.Format(time.RFC3339))) }) + Convey("interpolate __timeFrom function", func() { + sql, err := engine.Interpolate(query, timeRange, "select $__timeFrom()") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "select '2018-04-12T18:00:00Z'") + }) + + Convey("interpolate __timeTo function", func() { + sql, err := engine.Interpolate(query, timeRange, "select $__timeTo()") + So(err, ShouldBeNil) + + So(sql, ShouldEqual, "select '2018-04-12T18:05:00Z'") + }) + Convey("interpolate __timeGroup function pre 5.3 compatibility", func() { sql, err := engine.Interpolate(query, timeRange, "SELECT $__timeGroup(time_column,'5m'), value") diff --git a/pkg/tsdb/sql_engine.go b/pkg/tsdb/sql_engine.go index 1a4e2bd3943..ab7230e9b02 100644 --- a/pkg/tsdb/sql_engine.go +++ b/pkg/tsdb/sql_engine.go @@ -196,8 +196,6 @@ var Interpolate = func(query *Query, timeRange *TimeRange, sql string) (string, sql = strings.Replace(sql, "$__interval_ms", strconv.FormatInt(interval.Milliseconds(), 10), -1) sql = strings.Replace(sql, "$__interval", interval.Text, -1) - sql = strings.Replace(sql, "$__timeFrom()", fmt.Sprintf("'%s'", timeRange.GetFromAsTimeUTC().Format(time.RFC3339)), -1) - sql = strings.Replace(sql, "$__timeTo()", fmt.Sprintf("'%s'", timeRange.GetToAsTimeUTC().Format(time.RFC3339)), -1) sql = strings.Replace(sql, "$__unixEpochFrom()", fmt.Sprintf("%d", timeRange.GetFromAsSecondsEpoch()), -1) sql = strings.Replace(sql, "$__unixEpochTo()", fmt.Sprintf("%d", timeRange.GetToAsSecondsEpoch()), -1) diff --git a/pkg/tsdb/sql_engine_test.go b/pkg/tsdb/sql_engine_test.go index bfcc82aac47..bc77a95734d 100644 --- a/pkg/tsdb/sql_engine_test.go +++ b/pkg/tsdb/sql_engine_test.go @@ -44,20 +44,6 @@ func TestSqlEngine(t *testing.T) { So(sql, ShouldEqual, "select 60000 ") }) - Convey("interpolate __timeFrom function", func() { - sql, err := Interpolate(query, timeRange, "select $__timeFrom()") - So(err, ShouldBeNil) - - So(sql, ShouldEqual, fmt.Sprintf("select '%s'", from.Format(time.RFC3339))) - }) - - Convey("interpolate __timeTo function", func() { - sql, err := Interpolate(query, timeRange, "select $__timeTo()") - So(err, ShouldBeNil) - - So(sql, ShouldEqual, fmt.Sprintf("select '%s'", to.Format(time.RFC3339))) - }) - Convey("interpolate __unixEpochFrom function", func() { sql, err := Interpolate(query, timeRange, "select $__unixEpochFrom()") So(err, ShouldBeNil) diff --git a/public/app/core/controllers/reset_password_ctrl.ts b/public/app/core/controllers/reset_password_ctrl.ts index 933655399e8..9ad6864ece2 100644 --- a/public/app/core/controllers/reset_password_ctrl.ts +++ b/public/app/core/controllers/reset_password_ctrl.ts @@ -1,4 +1,5 @@ import coreModule from '../core_module'; +import config from 'app/core/config'; export class ResetPasswordCtrl { /** @ngInject */ @@ -6,6 +7,9 @@ export class ResetPasswordCtrl { contextSrv.sidemenu = false; $scope.formModel = {}; $scope.mode = 'send'; + $scope.ldapEnabled = config.ldapEnabled; + $scope.authProxyEnabled = config.authProxyEnabled; + $scope.disableLoginForm = config.disableLoginForm; const params = $location.search(); if (params.code) { diff --git a/public/app/core/logs_model.ts b/public/app/core/logs_model.ts index 2485dbda40a..c05f5bab866 100644 --- a/public/app/core/logs_model.ts +++ b/public/app/core/logs_model.ts @@ -35,22 +35,30 @@ export interface LogRow { duplicates?: number; entry: string; key: string; // timestamp + labels - labels: string; + labels: LogsStreamLabels; logLevel: LogLevel; searchWords?: string[]; timestamp: string; // ISO with nanosec precision timeFromNow: string; timeEpochMs: number; timeLocal: string; - uniqueLabels?: string; + uniqueLabels?: LogsStreamLabels; +} + +export enum LogsMetaKind { + Number, + String, + LabelsMap, } export interface LogsMetaItem { label: string; - value: string; + value: string | number | LogsStreamLabels; + kind: LogsMetaKind; } export interface LogsModel { + id: string; // Identify one logs result from another meta?: LogsMetaItem[]; rows: LogRow[]; series?: TimeSeries[]; @@ -61,7 +69,7 @@ export interface LogsStream { entries: LogsStreamEntry[]; search?: string; parsedLabels?: LogsStreamLabels; - uniqueLabels?: string; + uniqueLabels?: LogsStreamLabels; } export interface LogsStreamEntry { diff --git a/public/app/core/utils/explore.test.ts b/public/app/core/utils/explore.test.ts index 37d3d3bfac9..7ceebbd8047 100644 --- a/public/app/core/utils/explore.test.ts +++ b/public/app/core/utils/explore.test.ts @@ -16,7 +16,7 @@ const DEFAULT_EXPLORE_STATE: ExploreState = { datasourceMissing: false, datasourceName: '', exploreDatasources: [], - graphRange: DEFAULT_RANGE, + graphInterval: 1000, history: [], initialQueries: [], queryTransactions: [], diff --git a/public/app/core/utils/explore.ts b/public/app/core/utils/explore.ts index 9ecc36a192f..be771c1b232 100644 --- a/public/app/core/utils/explore.ts +++ b/public/app/core/utils/explore.ts @@ -1,7 +1,10 @@ +import _ from 'lodash'; + import { renderUrl } from 'app/core/utils/url'; -import { ExploreState, ExploreUrlState, HistoryItem } from 'app/types/explore'; +import { ExploreState, ExploreUrlState, HistoryItem, QueryTransaction } from 'app/types/explore'; import { DataQuery, RawTimeRange } from 'app/types/series'; +import TableModel, { mergeTablesIntoModel } from 'app/core/table_model'; import kbn from 'app/core/utils/kbn'; import colors from 'app/core/utils/colors'; import TimeSeries from 'app/core/time_series2'; @@ -133,6 +136,35 @@ export function hasNonEmptyQuery(queries: DataQuery[]): boolean { return queries.some(query => Object.keys(query).length > 2); } +export function calculateResultsFromQueryTransactions( + queryTransactions: QueryTransaction[], + datasource: any, + graphInterval: number +) { + const graphResult = _.flatten( + queryTransactions.filter(qt => qt.resultType === 'Graph' && qt.done && qt.result).map(qt => qt.result) + ); + const tableResult = mergeTablesIntoModel( + new TableModel(), + ...queryTransactions.filter(qt => qt.resultType === 'Table' && qt.done && qt.result).map(qt => qt.result) + ); + const logsResult = + datasource && datasource.mergeStreams + ? datasource.mergeStreams( + _.flatten( + queryTransactions.filter(qt => qt.resultType === 'Logs' && qt.done && qt.result).map(qt => qt.result) + ), + graphInterval + ) + : undefined; + + return { + graphResult, + tableResult, + logsResult, + }; +} + export function getIntervals( range: RawTimeRange, datasource, diff --git a/public/app/core/utils/kbn.ts b/public/app/core/utils/kbn.ts index 5d417d24169..9caa5bf1a54 100644 --- a/public/app/core/utils/kbn.ts +++ b/public/app/core/utils/kbn.ts @@ -428,10 +428,16 @@ kbn.valueFormats.hex0x = (value, decimals) => { }; kbn.valueFormats.sci = (value, decimals) => { + if (value == null) { + return ''; + } return value.toExponential(decimals); }; kbn.valueFormats.locale = (value, decimals) => { + if (value == null) { + return ''; + } return value.toLocaleString(undefined, { maximumFractionDigits: decimals }); }; diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index d4e9b689495..3e35a68bf84 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -16,6 +16,7 @@ import { RawTimeRange, DataQuery } from 'app/types/series'; import store from 'app/core/store'; import { DEFAULT_RANGE, + calculateResultsFromQueryTransactions, ensureQueries, getIntervals, generateKey, @@ -28,7 +29,7 @@ import ResetStyles from 'app/core/components/Picker/ResetStyles'; import PickerOption from 'app/core/components/Picker/PickerOption'; import IndicatorsContainer from 'app/core/components/Picker/IndicatorsContainer'; import NoOptionsMessage from 'app/core/components/Picker/NoOptionsMessage'; -import TableModel, { mergeTablesIntoModel } from 'app/core/table_model'; +import TableModel from 'app/core/table_model'; import { DatasourceSrv } from 'app/features/plugins/datasource_srv'; import Panel from './Panel'; @@ -97,6 +98,11 @@ export class Explore extends React.PureComponent { * Local ID cache to compare requested vs selected datasource */ requestedDatasourceId: string; + scanTimer: NodeJS.Timer; + /** + * Timepicker to control scanning + */ + timepickerRef: React.RefObject; constructor(props) { super(props); @@ -110,6 +116,8 @@ export class Explore extends React.PureComponent { const { datasource, queries, range } = props.urlState as ExploreUrlState; initialQueries = ensureQueries(queries); const initialRange = range || { ...DEFAULT_RANGE }; + // Millies step for helper bar charts + const initialGraphInterval = 15 * 1000; this.state = { datasource: null, datasourceError: null, @@ -117,11 +125,14 @@ export class Explore extends React.PureComponent { datasourceMissing: false, datasourceName: datasource, exploreDatasources: [], - graphRange: initialRange, + graphInterval: initialGraphInterval, + graphResult: [], initialQueries, history: [], + logsResult: null, queryTransactions: [], range: initialRange, + scanning: false, showingGraph: true, showingLogs: true, showingStartPage: false, @@ -129,9 +140,11 @@ export class Explore extends React.PureComponent { supportsGraph: null, supportsLogs: null, supportsTable: null, + tableResult: new TableModel(), }; } this.modifiedQueries = initialQueries.slice(); + this.timepickerRef = React.createRef(); } async componentDidMount() { @@ -164,7 +177,13 @@ export class Explore extends React.PureComponent { } } + componentWillUnmount() { + clearTimeout(this.scanTimer); + } + async setDatasource(datasource: any, origin?: DataSource) { + const { initialQueries, range } = this.state; + const supportsGraph = datasource.meta.metrics; const supportsLogs = datasource.meta.logs; const supportsTable = datasource.meta.metrics; @@ -209,7 +228,7 @@ export class Explore extends React.PureComponent { } // Reset edit state with new queries - const nextQueries = this.state.initialQueries.map((q, i) => ({ + const nextQueries = initialQueries.map((q, i) => ({ ...modifiedQueries[i], ...generateQueryKeys(i), })); @@ -218,11 +237,15 @@ export class Explore extends React.PureComponent { // Custom components const StartPage = datasource.pluginExports.ExploreStartPage; + // Calculate graph bucketing interval + const graphInterval = getIntervals(range, datasource, this.el ? this.el.offsetWidth : 0).intervalMs; + this.setState( { StartPage, datasource, datasourceError, + graphInterval, history, supportsGraph, supportsLogs, @@ -317,11 +340,14 @@ export class Explore extends React.PureComponent { } }; - onChangeTime = (nextRange: RawTimeRange) => { + onChangeTime = (nextRange: RawTimeRange, scanning?: boolean) => { const range: RawTimeRange = { ...nextRange, }; - this.setState({ range }, () => this.onSubmit()); + if (this.state.scanning && !scanning) { + this.onStopScanning(); + } + this.setState({ range, scanning }, () => this.onSubmit()); }; onClickClear = () => { @@ -400,12 +426,19 @@ export class Explore extends React.PureComponent { this.setState( state => { const showingTable = !state.showingTable; - let nextQueryTransactions = state.queryTransactions; - if (!showingTable) { - // Discard transactions related to Table query - nextQueryTransactions = state.queryTransactions.filter(qt => qt.resultType !== 'Table'); + if (showingTable) { + return { showingTable, queryTransactions: state.queryTransactions }; } - return { queryTransactions: nextQueryTransactions, showingTable }; + + // Toggle off needs discarding of table queries + const nextQueryTransactions = state.queryTransactions.filter(qt => qt.resultType !== 'Table'); + const results = calculateResultsFromQueryTransactions( + nextQueryTransactions, + state.datasource, + state.graphInterval + ); + + return { ...results, queryTransactions: nextQueryTransactions, showingTable }; }, () => { if (this.state.showingTable) { @@ -415,8 +448,8 @@ export class Explore extends React.PureComponent { ); }; - onClickTableCell = (columnKey: string, rowValue: string) => { - this.onModifyQueries({ type: 'ADD_FILTER', key: columnKey, value: rowValue }); + onClickLabel = (key: string, value: string) => { + this.onModifyQueries({ type: 'ADD_FILTER', key, value }); }; onModifyQueries = (action, index?: number) => { @@ -486,8 +519,14 @@ export class Explore extends React.PureComponent { // Discard transactions related to row query const nextQueryTransactions = queryTransactions.filter(qt => qt.rowIndex !== index); + const results = calculateResultsFromQueryTransactions( + nextQueryTransactions, + state.datasource, + state.graphInterval + ); return { + ...results, initialQueries: nextQueries, queryTransactions: nextQueryTransactions, }; @@ -496,6 +535,24 @@ export class Explore extends React.PureComponent { ); }; + onStartScanning = () => { + this.setState({ scanning: true }, this.scanPreviousRange); + }; + + scanPreviousRange = () => { + const scanRange = this.timepickerRef.current.move(-1, true); + this.setState({ scanRange }); + }; + + onStopScanning = () => { + clearTimeout(this.scanTimer); + this.setState(state => { + const { queryTransactions } = state; + const nextQueryTransactions = queryTransactions.filter(qt => qt.scanning && !qt.done); + return { queryTransactions: nextQueryTransactions, scanning: false, scanRange: undefined }; + }); + }; + onSubmit = () => { const { showingLogs, showingGraph, showingTable, supportsGraph, supportsLogs, supportsTable } = this.state; // Keep table queries first since they need to return quickly @@ -532,8 +589,8 @@ export class Explore extends React.PureComponent { const configuredQueries = [ { - ...queryOptions, ...query, + ...queryOptions, }, ]; @@ -563,6 +620,7 @@ export class Explore extends React.PureComponent { done: false, latency: 0, options: queryOptions, + scanning: this.state.scanning, }; // Using updater style because we might be modifying queryTransactions in quick succession @@ -576,7 +634,14 @@ export class Explore extends React.PureComponent { // Append new transaction const nextQueryTransactions = [...remainingTransactions, transaction]; + const results = calculateResultsFromQueryTransactions( + nextQueryTransactions, + state.datasource, + state.graphInterval + ); + return { + ...results, queryTransactions: nextQueryTransactions, showingStartPage: false, }; @@ -599,7 +664,7 @@ export class Explore extends React.PureComponent { } this.setState(state => { - const { history, queryTransactions } = state; + const { history, queryTransactions, scanning } = state; // Transaction might have been discarded const transaction = queryTransactions.find(qt => qt.id === transactionId); @@ -627,22 +692,30 @@ export class Explore extends React.PureComponent { return qt; }); + const results = calculateResultsFromQueryTransactions( + nextQueryTransactions, + state.datasource, + state.graphInterval + ); + const nextHistory = updateHistory(history, datasourceId, queries); + // Keep scanning for results if this was the last scanning transaction + if (_.size(result) === 0 && scanning) { + const other = nextQueryTransactions.find(qt => qt.scanning && !qt.done); + if (!other) { + this.scanTimer = setTimeout(this.scanPreviousRange, 1000); + } + } + return { + ...results, history: nextHistory, queryTransactions: nextQueryTransactions, }; }); } - discardTransactions(rowIndex: number) { - this.setState(state => { - const remainingTransactions = state.queryTransactions.filter(qt => qt.rowIndex !== rowIndex); - return { queryTransactions: remainingTransactions }; - }); - } - failQueryTransaction(transactionId: string, response: any, datasourceId: string) { const { datasource } = this.state; if (datasource.meta.id !== datasourceId || response.cancelled) { @@ -654,14 +727,20 @@ export class Explore extends React.PureComponent { let error: string | JSX.Element = response; if (response.data) { - error = response.data.error; - if (response.data.response) { - error = ( - <> - {response.data.error} -
{response.data.response}
- - ); + if (typeof response.data === 'string') { + error = response.data; + } else if (response.data.error) { + error = response.data.error; + if (response.data.response) { + error = ( + <> + {response.data.error} +
{response.data.response}
+ + ); + } + } else { + throw new Error('Could not handle error response'); } } @@ -705,7 +784,6 @@ export class Explore extends React.PureComponent { const latency = Date.now() - now; const results = resultGetter ? resultGetter(res.data) : res.data; this.completeQueryTransaction(transaction.id, results, latency, queries, datasourceId); - this.setState({ graphRange: transaction.options.range }); } catch (response) { this.failQueryTransaction(transaction.id, response, datasourceId); } @@ -735,11 +813,14 @@ export class Explore extends React.PureComponent { datasourceLoading, datasourceMissing, exploreDatasources, - graphRange, + graphResult, history, initialQueries, + logsResult, queryTransactions, range, + scanning, + scanRange, showingGraph, showingLogs, showingStartPage, @@ -747,31 +828,14 @@ export class Explore extends React.PureComponent { supportsGraph, supportsLogs, supportsTable, + tableResult, } = this.state; const graphHeight = showingGraph && showingTable ? '200px' : '400px'; const exploreClass = split ? 'explore explore-split' : 'explore'; const selectedDatasource = datasource ? exploreDatasources.find(d => d.label === datasource.name) : undefined; - const graphRangeIntervals = getIntervals(graphRange, datasource, this.el ? this.el.offsetWidth : 0); const graphLoading = queryTransactions.some(qt => qt.resultType === 'Graph' && !qt.done); const tableLoading = queryTransactions.some(qt => qt.resultType === 'Table' && !qt.done); const logsLoading = queryTransactions.some(qt => qt.resultType === 'Logs' && !qt.done); - // TODO don't recreate those on each re-render - const graphResult = _.flatten( - queryTransactions.filter(qt => qt.resultType === 'Graph' && qt.done && qt.result).map(qt => qt.result) - ); - const tableResult = mergeTablesIntoModel( - new TableModel(), - ...queryTransactions.filter(qt => qt.resultType === 'Table' && qt.done && qt.result).map(qt => qt.result) - ); - const logsResult = - datasource && datasource.mergeStreams - ? datasource.mergeStreams( - _.flatten( - queryTransactions.filter(qt => qt.resultType === 'Logs' && qt.done && qt.result).map(qt => qt.result) - ), - graphRangeIntervals.intervalMs - ) - : undefined; const loading = queryTransactions.some(qt => !qt.done); return ( @@ -822,7 +886,7 @@ export class Explore extends React.PureComponent { ) : null} - +