diff --git a/CHANGELOG.md b/CHANGELOG.md index 167c6ad829a..30bcc05597a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * **Graph**: Support auto grid min/max when using log scale [#3090](https://github.com/grafana/grafana/issues/3090), thx [@bigbenhur](https://github.com/bigbenhur) * **Graph**: Support for histograms [#600](https://github.com/grafana/grafana/issues/600) * **Prometheus**: Support table response formats (column per label) [#6140](https://github.com/grafana/grafana/issues/6140), thx [@mtanda](https://github.com/mtanda) +* **Single Stat Panel**: support for non time series data [#6564](https://github.com/grafana/grafana/issues/6564) + ## Minor Enchancements diff --git a/docs/publish.sh b/docs/publish.sh new file mode 100755 index 00000000000..4b72f892179 --- /dev/null +++ b/docs/publish.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +make publish ENV=prod VERSION=root diff --git a/docs/sources/alerting/notifications.md b/docs/sources/alerting/notifications.md index d0dd19cbcdc..cd1316eb479 100644 --- a/docs/sources/alerting/notifications.md +++ b/docs/sources/alerting/notifications.md @@ -12,18 +12,18 @@ weight = 2 # Alert Notifications -{{< imgbox max-width="40%" img="/img/docs/v4/alert_notifications_menu.png" caption="Alerting notifications" >}} - > Alerting is only available in Grafana v4.0 and above. When an alert changes state it sends out notifications. Each alert rule can have multiple notifications. But in order to add a notification to an alert rule you first need -to add and configure a `notification` object. This is done from the Alerting/Notifications page. +to add and configure a `notification` channel (can be email, Pagerduty or other integration). This is done from the Notification Channels page. -## Notification Setup +## Notification Channel Setup -On the notifications list page hit the `New Notification` button to go the the page where you -can configure and setup a new notification. +{{< imgbox max-width="40%" img="/img/docs/v43/alert_notifications_menu.png" caption="Alerting Notification Channels" >}} + +On the Notification Channels page hit the `New Channel` button to go the the page where you +can configure and setup a new Notification Channel. You specify name and type, and type specific options. You can also test the notification to make sure it's working and setup correctly. @@ -32,15 +32,15 @@ sure it's working and setup correctly. When checked this option will make this notification used for all alert rules, existing and new. -## Supported notification types +## Supported Notification Types -Grafana ships with a set of notification types. More will be added in future releases. +Grafana ships with the following set of notification types: ### Email To enable email notification you have to setup [SMTP settings](/installation/configuration/#smtp) in the Grafana config. Email notification will upload an image of the alert graph to an -external image destination if available or fallback on attaching the image in the email. +external image destination if available or fallback to attaching the image in the email. ### Slack @@ -55,19 +55,29 @@ Setting | Description Recipient | allows you to override the slack recipient. Mention | make it possible to include a mention in the slack notification sent by Grafana. Ex @here or @channel +### PagerDuty + +To set up PagerDuty, all you have to do is to provide an api key. + +Setting | Description +---------- | ----------- +Integration Key | Integration key for pagerduty. +Auto resolve incidents | Resolve incidents in pagerduty once the alert goes back to ok + ### Webhook The webhook notification is a simple way to send information about an state change over HTTP to a custom endpoint. -Using this notification you could integrated Grafana into any system you choose, by yourself. +Using this notification you could integrate Grafana into any system you choose, by yourself. Example json body: + ```json { "title": "My alert", "ruleId": 1, "ruleName": "Load peaking!", "ruleUrl": "http://url.to.grafana/db/dashboard/my_dashboard?panelId=2", - "state": "Alerting", + "state": "alerting", "imageUrl": "http://s3.image.url", "message": "Load is peaking. Make sure the traffic is real and spin up more webfronts", "evalMatches": [ @@ -80,30 +90,38 @@ Example json body: } ``` -### PagerDuty +- **state** - The possible values for alert state are: `ok`, `paused`, `alerting`, `pending`, `no_data`. -To set up PagerDuty, all you have to do is to provide an api key. +### Other Supported Notification Channels -Setting | Description ----------- | ----------- -Integration Key | Integration key for pagerduty. -Auto resolve incidents | Resolve incidents in pagerduty once the alert goes back to ok +Grafana also supports the following Notification Channels: +- HipChat + +- VictorOps + +- Sensu + +- OpsGenie + +- Threema + +- Pushover + +- Telegram + +- LINE # Enable images in notifications {#external-image-store} -Grafana can render the panel associated with the alert rule and include that in the notification. Some types -of notifications require that this image be publicly accessable (Slack for example). In order to support -images in notifications like Slack Grafana can upload the image to an image store. It currently supports -Amazon S3 for this and Webdav. So to set that up you need to configure the -[external image uploader](/installation/configuration/#external-image-storage) in your grafana-server ini -config file. +Grafana can render the panel associated with the alert rule and include that in the notification. Most Notification Channels require that this image be publicly accessable (Slack and PagerDuty for example). In order to include images in alert notifications, Grafana can upload the image to an image store. It currently supports +Amazon S3 and Webdav for this. So to set that up you need to configure the [external image uploader](/installation/configuration/#external-image-storage) in your grafana-server ini config file. -This is an optional requirement, you can get slack and email notifications without setting this up. +Currently only the Email Channels attaches images if no external image store is specified. To include images in alert notifications for other channels then you need to set up an external image store. + +This is an optional requirement, you can get Slack and email notifications without setting this up. # Configure the link back to Grafana from alert notifications -All alert notifications contains a link back to the triggered alert in the Grafana instance. -This url is based on the [domain](/installation/configuration/#domain) setting in Grafana. - - +All alert notifications contains a link back to the triggered alert in the Grafana instance. +This url is based on the [domain](/installation/configuration/#domain) setting in Grafana. diff --git a/docs/sources/features/datasources/elasticsearch.md b/docs/sources/features/datasources/elasticsearch.md index 4f8bfaf968c..6462d026366 100644 --- a/docs/sources/features/datasources/elasticsearch.md +++ b/docs/sources/features/datasources/elasticsearch.md @@ -12,34 +12,29 @@ weight = 3 # Using Elasticsearch in Grafana -Grafana ships with advanced support for Elasticsearch. You can do many types of -simple or complex elasticsearch queries to visualize logs or metrics stored in elasticsearch. You can -also annotate your graphs with log events stored in elasticsearch. +Grafana ships with advanced support for Elasticsearch. You can do many types of simple or complex Elasticsearch queries to +visualize logs or metrics stored in Elasticsearch. You can also annotate your graphs with log events stored in Elasticsearch. ## Adding the data source -![](/img/docs/v2/add_Graphite.jpg) - -1. Open the side menu by clicking the the Grafana icon in the top header. +1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. +3. Click the `+ Add data source` button in the top header. +4. Select *Elasticsearch* from the *Type* dropdown. - > NOTE: If this link is missing in the side menu it means that your current user does not have the `Admin` role for the current organization. - -3. Click the `Add new` link in the top header. -4. Select `Elasticsearch` from the dropdown. +> 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 data source name, important that this is the same as in Grafana v1.x if you plan to import old dashboards. -Default | Default data source means that it will be pre-selected for new panels. -Url | The http protocol, ip and port of you elasticsearch server. -Access | Proxy = access via Grafana backend, Direct = access directly from browser. +*Name* | The data source name. This is how you refer to the data source in panels & queries. +*Default* | Default data source means that it will be pre-selected for new panels. +*Url* | The HTTP protocol, IP, and port of your Elasticsearch server. +*Access* | Proxy = access via Grafana backend, Direct = access directly from browser. -Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication details to the Data Source to the browser. - -Direct access is still supported because in some cases it may be useful to access a Data Source directly depending on the use case and topology of Grafana, the user, and the Data Source. +Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication to the browser. ### Direct access + If you select direct access you must update your Elasticsearch configuration to allow other domains to access Elasticsearch from the browser. You do this by specifying these to options in your **elasticsearch.yml** config file. @@ -50,46 +45,93 @@ Elasticsearch from the browser. You do this by specifying these to options in yo ![](/img/docs/elasticsearch/elasticsearch_ds_details.png) -Here you can specify a default for the `time field` and specify the name of your elasticsearch index. You can use +Here you can specify a default for the `time field` and specify the name of your Elasticsearch index. You can use a time pattern for the index name or a wildcard. +### Elasticsearch version + +Be sure to specify your Elasticsearch version in the version selection dropdown. This is very important as there are differences how queries are composed. Currently only 2.x and 5.x +are supported. + ## Metric Query editor ![](/img/docs/elasticsearch/query_editor.png) -The Elasticsearch query editor allows you to select multiple metrics and group by multiple terms or filters. Use the plus and minus icons to the right to add / remove -metrics or group bys. Some metrics and group by have options, click the option text to expand the the row to view and edit metric or group by options. +The Elasticsearch query editor allows you to select multiple metrics and group by multiple terms or filters. Use the plus and minus icons to the right to add/remove +metrics or group by clauses. Some metrics and group by clauses haves options, click the option text to expand the row to view and edit metric or group by options. + +## Series naming & alias patterns + +You can control the name for time series via the `Alias` input field. + +Pattern | Description +------------ | ------------- +*{{term fieldname}}* | replaced with value of a term group by +*{{metric}}* | replaced with metric name (ex. Average, Min, Max) +*{{field}}* | replaced with the metric field name ## Pipeline metrics -If you have Elasticsearch 2.x and Grafana 2.6 or above then you can use pipeline metric aggregations like -**Moving Average** and **Derivative**. Elasticsearch pipeline metrics require another metric to be based on. Use the eye icon next to the metric -to hide metrics from appearing in the graph. This is useful for metrics you only have in the query to be used -in a pipeline metric. +Some metric aggregations are called Pipeline aggregations, for example, *Moving Average* and *Derivative*. Elasticsearch pipeline metrics require another metric to be based on. Use the eye icon next to the metric to hide metrics from appearing in the graph. This is useful for metrics you only have in the query for use in a pipeline metric. ![](/img/docs/elasticsearch/pipeline_metrics_editor.png) ## Templating -The Elasticsearch datasource supports two types of queries you can use to fill template variables with values. +Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. +Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data +being displayed in your dashboard. -### Possible values for a field +Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different +types of template variables. -```json -{"find": "terms", "field": "@hostname"} +### Query variable + +The Elasticsearch data source supports two types of queries you can use in the *Query* field of *Query* variables. The query is written using a custom JSON string. + +Query | Description +------------ | ------------- +*{"find": "fields", "type": "keyword"} | Returns a list of field names with the index type `keyword`. +*{"find": "terms", "field": "@hostname"}* | Returns a list of values for a field using term aggregation. Query will user current dashboard time range as time range for query. +*{"find": "terms", "field": "@hostname", "query": ''}* | Returns a list of values for a field using term aggregation & and a specified lucene query filter. Query will use current dashboard time range as time range for query. + +You can use other variables inside the query. Example query definition for a variable named `$host`. + +``` +{"find": "terms", "field": "@hostname", "query": "@source:$source"} ``` -### Fields filtered by type -```json -{"find": "fields", "type": "string"} -``` +In the above example, we use another variable named `$source` inside the query definition. Whenever you change, via the dropdown, the current value of the ` $source` variable, it will trigger an update of the `$host` variable so it now only contains hostnames filtered by in this case the +`@source` document property. -### Fields filtered by type, with filter -```json -{"find": "fields", "type": "string", "query": } -``` +### Using variables in queries -### Multi format / All format -Use lucene format. +There are two syntaxes: +- `$` Example: @hostname:$hostname +- `[[varname]]` Example: @hostname:[[hostname]] +Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the *Multi-value* or *Include all value* +options are enabled, Grafana converts the labels from plain text to a lucene compatible condition. + +![](/img/docs/v43/elastic_templating_query.png) + +In the above example, we have a lucene query that filters documents based on the `@hostname` property using a variable named `$hostname`. It is also using +a variable in the *Terms* group by field input box. This allows you to use a variable to quickly change how the data is grouped. + +Example dashboard: +[Elasticsearch Templated Dashboard](http://play.grafana.org/dashboard/db/elasticsearch-templated) + +## Annotations + +[Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation +queries via the Dashboard menu / Annotations view. Grafana can query any Elasticsearch index +for annotation events. + +Name | Description +------------ | ------------- +Query | You can leave the search query blank or specify a lucene query +Time | The name of the time field, needs to be date field. +Title | The name of the field to use for the event title. +Tags | Optional field name to use for event tags (can be an array or a CSV string). +Text | Optional field name to use event text body. diff --git a/docs/sources/features/datasources/graphite.md b/docs/sources/features/datasources/graphite.md index 11e15ab503e..a625b93e8d8 100644 --- a/docs/sources/features/datasources/graphite.md +++ b/docs/sources/features/datasources/graphite.md @@ -18,28 +18,22 @@ change function parameters and much more. The editor can handle all types of gra queries through the use of query references. ## Adding the data source -![](/img/docs/v2/add_Graphite.jpg) -1. Open the side menu by clicking the the Grafana icon in the top header. +1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. +3. Click the `+ Add data source` button in the top header. +4. Select `Graphite` from the *Type* dropdown. - > NOTE: If this link is missing in the side menu it means that your current user does not have the `Admin` role for the current organization. - -3. Click the `Add new` link in the top header. -4. Select `Graphite` from the dropdown. +> 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 data source name, important that this is the same as in Grafana v1.x if you plan to import old dashboards. -Default | Default data source means that it will be pre-selected for new panels. -Url | The http protocol, ip and port of your graphite-web or graphite-api install. -Access | Proxy = access via Grafana backend, Direct = access directly from browser. - - -Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication details to the Data Source to the browser. - -Direct access is still supported because in some cases it may be useful to access a Data Source directly depending on the use case and topology of Grafana, the user, and the Data Source. +*Name* | The data source name. This is how you refer to the data source in panels & queries. +*Default* | Default data source means that it will be pre-selected for new panels. +*Url* | The HTTP protocol, IP, and port of your graphite-web or graphite-api install. +*Access* | Proxy = access via Grafana backend, Direct = access directly from browser. +Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication details to the browser. ## Metric editor @@ -50,6 +44,7 @@ or keyboard arrow keys. You can select a wildcard and still continue. ![](/img/docs/animated_gifs/graphite_query1.gif) ### Functions + Click the plus icon to the right to add a function. You can search for the function or select it from the menu. Once a function is selected it will be added and your focus will be in the text box of the first parameter. To later change a parameter just click on it and it will turn into a text box. To delete a function click the function name followed @@ -57,32 +52,61 @@ by the x icon. ![](/img/docs/animated_gifs/graphite_query2.gif) - ### Optional parameters + Some functions like aliasByNode support an optional second argument. To add this parameter specify for example 3,-2 as the first parameter and the function editor will adapt and move the -2 to a second parameter. To remove the second optional parameter just click on it and leave it blank and the editor will remove it. ![](/img/docs/animated_gifs/func_editor_optional_params.gif) +### Nested Queries + +You can reference queries by the row “letter” that they’re on (similar to Microsoft Excel). If you add a second query to a graph, you can reference the first query simply by typing in #A. This provides an easy and convenient way to build compounded queries. + ## Point consolidation -All Graphite metrics are consolidated so that Graphite doesn't return more data points than there are pixels in the graph. By default +All Graphite metrics are consolidated so that Graphite doesn't return more data points than there are pixels in the graph. By default, this consolidation is done using `avg` function. You can how Graphite consolidates metrics by adding the Graphite consolidateBy function. > *Notice* This means that legend summary values (max, min, total) cannot be all correct at the same time. They are calculated > client side by Grafana. And depending on your consolidation function only one or two can be correct at the same time. ## Templating -You can create a template variable in Grafana and have that variable filled with values from any Graphite metric exploration query. -You can then use this variable in your Graphite queries, either as part of a metric path or as arguments to functions. -For example a query like `prod.servers.*` will fill the variable with all possible -values that exists in the wildcard position. +Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. +Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data +being displayed in your dashboard. + +Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different +types of template variables. + +### Query variable + +The query you specify in the query field should be a metric find type of query. For example, a query like `prod.servers.*` will fill the +variable with all possible values that exist in the wildcard position. You can also create nested variables that use other variables in their definition. For example `apps.$app.servers.*` uses the variable `$app` in its query definition. +### Variable usage + +You can use a variable in a metric node path or as a parameter to a function. ![](/img/docs/v2/templated_variable_parameter.png) +There are two syntaxes: -## Query Reference -You can reference queries by the row “letter” that they’re on (similar to Microsoft Excel). If you add a second query to graph, you can reference the first query simply by typing in #A. This provides an easy and convenient way to build compounded queries. +- `$` Example: apps.frontend.$server.requests.count +- `[[varname]]` Example: apps.frontend.[[server]].requests.count + +Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. Use +the second syntax in expressions like `my.server[[serverNumber]].count`. + +Example: +[Graphite Templated Dashboard](http://play.grafana.org/dashboard/db/graphite-templated-nested) + +## Annotations + +[Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation +queries via the Dashboard menu / Annotations view. + +Graphite supports two ways to query annotations. A regular metric query, for this you use the `Graphite query` textbox. A Graphite events query, use the `Graphite event tags` textbox, +specify a tag or wildcard (leave empty should also work) diff --git a/docs/sources/features/datasources/influxdb.md b/docs/sources/features/datasources/influxdb.md index 03dc26bcc26..2837363e145 100644 --- a/docs/sources/features/datasources/influxdb.md +++ b/docs/sources/features/datasources/influxdb.md @@ -15,29 +15,29 @@ weight = 3 Grafana ships with very feature rich data source plugin for InfluxDB. Supporting a feature rich query editor, annotation and templating queries. ## Adding the data source -![](/img/docs/v2/add_Influx.jpg) -1. Open the side menu by clicking the the Grafana icon in the top header. +1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. +3. Click the `+ Add data source` button in the top header. +4. Select *InfluxDB* from the *Type* dropdown. - > NOTE: If this link is missing in the side menu it means that your current user does not have the `Admin` role for the current organization. - -3. Click the `Add new` link in the top header. +> 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 data source name, important that this is the same as in Grafana v1.x if you plan to import old dashboards. -Default | Default data source means that it will be pre-selected for new panels. -Url | The http protocol, ip and port of you influxdb api (influxdb api port is by default 8086) -Access | Proxy = access via Grafana backend, Direct = access directly from browser. -Database | Name of your influxdb database -User | Name of your database user -Password | Database user's password +*Name* | The data source name. This is how you refer to the data source in panels & queries. +*Default* | Default data source means that it will be pre-selected for new panels. +*Url* | The http protocol, ip and port of you influxdb api (influxdb api port is by default 8086) +*Access* | Proxy = access via Grafana backend, Direct = access directly from browser. +*Database* | Name of your influxdb database +*User* | Name of your database user +*Password* | Database user's password - > Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication details to the Data Source to the browser. - - > Direct access is still supported because in some cases it may be useful to access a Data Source directly depending on the use case and topology of Grafana, the user, and the Data Source. +### Proxy vs Direct access +Proxy access means that the Grafana backend will proxy all requests from the browser. So requests to InfluxDB will be channeled through +`grafana-server`. This means that the URL you specify needs to be accessable from the server you are running Grafana on. Proxy access +mode is also more secure as the username & password will never reach the browser. ## Query Editor @@ -100,11 +100,21 @@ change the option `Format As` to `Table` if you want to show raw data in the `Ta ## Templating -You can create a template variable in Grafana and have that variable filled with values from any InfluxDB metric exploration query. -You can then use this variable in your InfluxDB metric queries. -For example you can have a variable that contains all values for tag `hostname` if you specify a query like this -in the templating edit view. +Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. +Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data +being displayed in your dashboard. + +Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different +types of template variables. + +### Query variable + +If you add a template variable of the type `Query` you can write a InfluxDB exploration (meta data) query. These queries can +return things like measurement names, key names or key values. + +For example you can have a variable that contains all values for tag `hostname` if you specify a query like this in the templating variable *Query* setting. + ```sql SHOW TAG VALUES WITH KEY = "hostname" ``` @@ -116,12 +126,46 @@ the hosts variable only show hosts from the current selected region with a query SHOW TAG VALUES WITH KEY = "hostname" WHERE region =~ /$region/ ``` -> Always use `regex values` or `regex wildcard` for All format or multi select format. +You can fetch key names for a given measurement. -![](/img/docs/influxdb/templating_simple_ex1.png) +```sql +SHOW TAG KEYS [FROM ] +``` + +If you have a variable with key names you can use this variable in a group by clause. This will allow you to change group by using the variable dropdown a the top +of the dashboard. + +### Using variables in queries + +There are two syntaxes: + +`$` Example: + +```sql +SELECT mean("value") FROM "logins" WHERE "hostname" =~ /^$host$/ AND $timeFilter GROUP BY time($__interval), "hostname" +``` + +`[[varname]]` Example: + +```sql +SELECT mean("value") FROM "logins" WHERE "hostname" =~ /^[[host]]$/ AND $timeFilter GROUP BY time($__interval), "hostname" +``` + +Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the *Multi-value* or *Include all value* +options are enabled, Grafana converts the labels from plain text to a regex compatible string. Which means you have to use `=~` instead of `=`. + +Example Dashboard: +[InfluxDB Templated Dashboard](http://play.grafana.org/dashboard/db/influxdb-templated-queries) + +### Ad hoc filters variable + +InfluxDB supports the special `Ad hoc filters` variable type. This variable allows you to specify any number of key/value filters on the fly. These filters will automatically +be applied to all your InfluxDB queries. ## Annotations -Annotations allows you to overlay rich event information on top of graphs. + +[Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation +queries via the Dashboard menu / Annotations view. An example query: @@ -129,4 +173,8 @@ An example query: SELECT title, description from events WHERE $timeFilter order asc ``` +For InfluxDB you need to enter a query like in the above example. You need to have the ```where $timeFilter``` +part. If you only select one column you will not need to enter anything in the column mapping fields. The +Tags field can be a comma seperated string. + diff --git a/docs/sources/features/datasources/opentsdb.md b/docs/sources/features/datasources/opentsdb.md index 2b1c7e5c3f5..03795473ff7 100644 --- a/docs/sources/features/datasources/opentsdb.md +++ b/docs/sources/features/datasources/opentsdb.md @@ -12,59 +12,79 @@ weight = 5 # Using OpenTSDB in Grafana -{{< docs-imagebox img="/img/docs/v2/add_OpenTSDB.png" max-width="14rem" >}} +Grafana ships with advanced support for OpenTSDB. -The newest release of Grafana adds additional functionality when using an OpenTSDB Data source. +## Adding the data source -1. Open the side menu by clicking the the Grafana icon in the top header. +1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. +3. Click the `+ Add data source` button in the top header. +4. Select *OpenTSDB* from the *Type* dropdown. - > NOTE: If this link is missing in the side menu it means that your current user does not have the `Admin` role for the current organization. - -3. Click the `Add new` link in the top header. -4. Select `OpenTSDB` from the dropdown. +> 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 data source name, important that this is the same as in Grafana v1.x if you plan to import old dashboards. -Default | Default data source means that it will be pre-selected for new panels. -Url | The http protocol, ip and port of you opentsdb server (default port is usually 4242) -Access | Proxy = access via Grafana backend, Direct = access directly from browser. -Version | Version = opentsdb version, either <=2.1 or 2.2 -Resolution | Metrics from opentsdb may have datapoints with either second or millisecond resolution. +*Name* | The data source name. This is how you refer to the data source in panels & queries. +*Default* | Default data source means that it will be pre-selected for new panels. +*Url* | The http protocol, ip and port of you opentsdb server (default port is usually 4242) +*Access* | Proxy = access via Grafana backend, Direct = access directly from browser. +*Version* | Version = opentsdb version, either <=2.1 or 2.2 +*Resolution* | Metrics from opentsdb may have datapoints with either second or millisecond resolution. + ## Query editor -Open a graph in edit mode by click the title. Query editor will differ if the datasource has version <=2.1 or = 2.2. In the former version, only tags can be used to query opentsdb. But in the latter version, filters as well as tags can be used to query opentsdb. Fill Policy is also introduced in opentsdb 2.2. - > Note: While using Opentsdb 2.2 datasource, make sure you use either Filters or Tags as they are mutually exclusive. If used together, might give you weird results. +Open a graph in edit mode by click the title. Query editor will differ if the datasource has version <=2.1 or = 2.2. +In the former version, only tags can be used to query OpenTSDB. But in the latter version, filters as well as tags +can be used to query opentsdb. Fill Policy is also introduced in OpenTSDB 2.2. -![](/img/docs/v2/opentsdb_query_editor.png) +![](/img/docs/v43/opentsdb_query_editor.png) + +> Note: While using OpenTSDB 2.2 datasource, make sure you use either Filters or Tags as they are mutually exclusive. If used together, might give you weird results. ### Auto complete suggestions -As soon as you start typing metric names, tag names and tag values , you should see highlighted auto complete suggestions for them. - > Note: This is required for the OpenTSDB `suggest` api to work. +As soon as you start typing metric names, tag names and tag values , you should see highlighted auto complete suggestions for them. +The autocomplete only works if the OpenTSDB suggest api is enabled. ## Templating queries -Grafana's OpenTSDB data source now supports template variable values queries. This means you can create template variables that fetch the values from OpenTSDB (for example metric names, tag names, or tag values). The query editor is also enhanced to limiting tags by metric. + +Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. +Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data +being displayed in your dashboard. + +Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different +types of template variables. + +### Query variable + +Grafana's OpenTSDB data source supports template variable queries. This means you can create template variables +that fetch the values from OpenTSDB. For example, metric names, tag names, or tag values. When using OpenTSDB with a template variable of `query` type you can use following syntax for lookup. - metrics(prefix) // returns metric names with specific prefix (can be empty) - tag_names(cpu) // return tag names (i.e. keys) for a specific cpu metric - tag_values(cpu, hostname) // return tag values for metric cpu and tag key hostname - suggest_tagk(prefix) // return tag names (i.e. keys) for all metrics with specific prefix (can be empty) - suggest_tagv(prefix) // return tag values for all metrics with specific prefix (can be empty) +Query | Description +------------ | ------------- +*metrics(prefix)* | Returns metric names with specific prefix (can be empty) +*tag_names(cpu)* | Return tag names (i.e. keys) for a specific cpu metric +*tag_values(cpu, hostname)* | Return tag values for metric cpu and tag key hostname +*suggest_tagk(prefix)* | Return tag names (i.e. keys) for all metrics with specific prefix (can be empty) +*suggest_tagv(prefix)* | Return tag values for all metrics with specific prefix (can be empty) -If you do not see template variables being populated in `Preview of values` section, you need to enable `tsd.core.meta.enable_realtime_ts` in the OpenTSDB server settings. Also, to populate metadata of the existing time series data in OpenTSDB, you need to run `tsdb uid metasync` on the OpenTSDB server. +If you do not see template variables being populated in `Preview of values` section, you need to enable +`tsd.core.meta.enable_realtime_ts` in the OpenTSDB server settings. Also, to populate metadata of +the existing time series data in OpenTSDB, you need to run `tsdb uid metasync` on the OpenTSDB server. ### Nested Templating -One template variable can be used to filter tag values for another template varible. Very importantly, the order of the parameters matter in tag_values function. First parameter is the metric name, second parameter is the tag key for which you need to find tag values, and after that all other dependent template variables. Some examples are mentioned below to make nested template queries work successfully. +One template variable can be used to filter tag values for another template varible. First parameter is the metric name, +second parameter is the tag key for which you need to find tag values, and after that all other dependent template variables. +Some examples are mentioned below to make nested template queries work successfully. - tag_values(cpu, hostname, env=$env) // return tag values for cpu metric, selected env tag value and tag key hostname - tag_values(cpu, hostanme, env=$env, region=$region) // return tag values for cpu metric, selected env tag value, selected region tag value and tag key hostname +Query | Description +------------ | ------------- +*tag_values(cpu, hostname, env=$env)* | Return tag values for cpu metric, selected env tag value and tag key hostname +*tag_values(cpu, hostanme, env=$env, region=$region)* | Return tag values for cpu metric, selected env tag value, selected region tag value and tag key hostname -> Note: This is required for the OpenTSDB `lookup` api to work. - -For details on opentsdb metric queries checkout the official [OpenTSDB documentation](http://opentsdb.net/docs/build/html/index.html) +For details on OpenTSDB metric queries checkout the official [OpenTSDB documentation](http://opentsdb.net/docs/build/html/index.html) diff --git a/docs/sources/features/datasources/prometheus.md b/docs/sources/features/datasources/prometheus.md index 947d7426230..4b5c3f115e8 100644 --- a/docs/sources/features/datasources/prometheus.md +++ b/docs/sources/features/datasources/prometheus.md @@ -10,74 +10,86 @@ parent = "datasources" weight = 2 +++ - # Using Prometheus in Grafana -Grafana includes support for Prometheus Datasources. While the process of adding the datasource is similar to adding a Graphite or OpenTSDB datasource type, Prometheus does have a few different options for building queries. +Grafana includes built-in support for Prometheus. ## Adding the data source to Grafana -![](/img/docs/v2/add_Prometheus.png) - -1. Open the side menu by clicking the the Grafana icon in the top header. +1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. +3. Click the `+ Add data source` button in the top header. +4. Select `Prometheus` from the *Type* dropdown. - > NOTE: If this link is missing in the side menu it means that your current user does not have the `Admin` role for the current organization. +> 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. -3. Click the `Add new` link in the top header. -4. Select `Prometheus` from the dropdown. +## Data source options Name | Description ------------ | ------------- -Name | The data source name, important that this is the same as in Grafana v1.x if you plan to import old dashboards. -Default | Default data source means that it will be pre-selected for new panels. -Url | The http protocol, ip and port of you Prometheus server (default port is usually 9090) -Access | Proxy = access via Grafana backend, Direct = access directly from browser. -Basic Auth | Enable basic authentication to the Prometheus datasource. -User | Name of your Prometheus user -Password | Database user's password - - > Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication details to the Data Source to the browser. - - > Direct access is still supported because in some cases it may be useful to access a Data Source directly depending on the use case and topology of Grafana, the user, and the Data Source. +*Name* | The data source name. This is how you refer to the data source in panels & queries. +*Default* | Default data source means that it will be pre-selected for new panels. +*Url* | The http protocol, ip and port of you Prometheus server (default port is usually 9090) +*Access* | Proxy = access via Grafana backend, Direct = access directly from browser. +*Basic Auth* | Enable basic authentication to the Prometheus data source. +*User* | Name of your Prometheus user +*Password* | Database user's password ## Query editor -Open a graph in edit mode by click the title. -![](/img/v2/prometheus_editor.png) +Open a graph in edit mode by click the title > Edit (or by pressing `e` key while hovering over panel). -For details on Prometheus metric queries check out the Prometheus documentation -- [Query Metrics - Prometheus documentation](http://prometheus.io/docs/querying/basics/). - -## Templated queries - -Prometheus Datasource Plugin provides the following functions in `Variables values query` field in Templating Editor to query `metric names` and `labels names` on the Prometheus server. +![](/img/docs/v43/prometheus_query_editor.png) Name | Description ------- | -------- -`label_values(label)` | Returns a list of label values for the `label` in every metric. -`label_values(metric, label)` | Returns a list of label values for the `label` in the specified metric. -`metrics(metric)` | Returns a list of metrics matching the specified `metric` regex. -`query_result(query)` | Returns a list of Prometheus query result for the `query`. +*Query expression* | Prometheus query expression, check out the [Prometheus documentation](http://prometheus.io/docs/querying/basics/). +*Legend format* | Controls the name of the time series, using name or pattern. For example `{{hostname}}` will be replaced with label value for the label `hostname`. +*Min step* | Set a lower limit for the Prometheus step option. Step controls how big the jumps are when the Prometheus query engine performs range queries. Sadly there is no official prometheus documentation to link to for this very important option. +*Resolution* | Controls the step option. Small steps create high-resolution graphs but can be slow over larger time ranges, lowering the resolution can speed things up. `1/2` will try to set step option to generate 1 data point for every other pixel. A value of `1/10` will try to set step option so there is a data point every 10 pixels.*Metric lookup* | Search for metric names in this input field. +*Format as* | **(New in v4.3)** Switch between Table & Time series. Table format will only work in the Table panel. -For details of `metric names` & `label names`, and `label values`, please refer to the [Prometheus documentation](http://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). +## Templating -> Note: The part of queries is incompatible with the version before 2.6, if you specify like `foo.*`, please change like `metrics(foo.*)`. +Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. +Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data +being displayed in your dashboard. -You can create a template variable in Grafana and have that variable filled with values from any Prometheus metric exploration query. -You can then use this variable in your Prometheus metric queries. +Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different +types of template variables. -For example you can have a variable that contains all values for label `hostname` if you specify a query like this in the templating edit view. +### Query variable -```sql -label_values(hostname) -``` +Variable of the type *Query* allows you to query Prometheus for a list of metrics, labels or label values. The Prometheus data source plugin +provides the following functions you can use in the `Query` input field. -You can also use raw queries & regular expressions to extract anything you might need. +Name | Description +---- | -------- +*label_values(label)* | Returns a list of label values for the `label` in every metric. +*label_values(metric, label)* | Returns a list of label values for the `label` in the specified metric. +*metrics(metric)* | Returns a list of metrics matching the specified `metric` regex. +*query_result(query)* | Returns a list of Prometheus query result for the `query`. -### Using templated variables in queries +For details of *metric names*, *label names* and *label values* are please refer to the [Prometheus documentation](http://prometheus.io/docs/concepts/data_model/#metric-names-and-labels). -When the `Include All` option or `Multi-Value` option is enabled, Grafana converts the labels from plain text to a regex compatible string. -Which means you have to use `=~` instead of `=` in your Prometheus queries. For example `ALERTS{instance=~$instance}` instead of `ALERTS{instance=$instance}`. +### Using variables in queries -![](/img/docs/v2/prometheus_templating.png) +There are two syntaxes: + +- `$` Example: rate(http_requests_total{job=~"$job"}[5m]) +- `[[varname]]` Example: rate(http_requests_total{job="my[[job]]"}[5m]) + +Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the *Multi-value* or *Include all value* +options are enabled, Grafana converts the labels from plain text to a regex compatible string. Which means you have to use `=~` instead of `=`. + +## Annotations + +[Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation +queries via the Dashboard menu / Annotations view. + +Prometheus supports two ways to query annotations. + +- A regular metric query +- A Prometheus query for pending and firing alerts (for details see [Inspecting alerts during runtime](https://prometheus.io/docs/alerting/rules/#inspecting-alerts-during-runtime)) + +The step option is useful to limit the number of events returned from your query. diff --git a/docs/sources/http_api/admin.md b/docs/sources/http_api/admin.md index 950ea4c8202..9c2c6d14b31 100644 --- a/docs/sources/http_api/admin.md +++ b/docs/sources/http_api/admin.md @@ -280,14 +280,22 @@ Change password for specific user ## Pause all alerts -`DELETE /api/admin/pause-all-alerts` +`POST /api/admin/pause-all-alerts` **Example Request**: - DELETE /api/admin/pause-all-alerts HTTP/1.1 + POST /api/admin/pause-all-alerts HTTP/1.1 Accept: application/json Content-Type: application/json + { + "paused": true + } + +JSON Body schema: + +- **paused** – If true then all alerts are to be paused, false unpauses all alerts. + **Example Response**: HTTP/1.1 200 diff --git a/docs/sources/http_api/alerting.md b/docs/sources/http_api/alerting.md index 0a422e10f4d..1aab7253373 100644 --- a/docs/sources/http_api/alerting.md +++ b/docs/sources/http_api/alerting.md @@ -28,6 +28,17 @@ This API can also be used to create, update and delete alert notifications. Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk + Querystring Parameters: + + These parameters are used as querystring parameters. For example: + + `/api/alerts?dashboardId=1` + + - **dashboardId** – Return alerts for a specified dashboard. + - **panelId** – Return alerts for a specified panel on a dashboard. + - **limit** - Limit response to x number of alerts. + - **state** - Return alerts with one or more of the following alert states: `ALL`,`no_data`, `paused`, `alerting`, `ok`, `pending`. To specify multiple states use the following format: `?state=paused&state=alerting` + **Example Response**: HTTP/1.1 200 @@ -40,6 +51,13 @@ This API can also be used to create, update and delete alert notifications. "name": "fire place sensor", "message": "Someone is trying to break in through the fire place", "state": "alerting", + "evalDate": "0001-01-01T00:00:00Z", + "evalData": [ + { + "metric": "fire", + "tags": null, + "value": 5.349999999999999 + } "newStateDate": "2016-12-25", "executionError": "", "dashboardUri": "http://grafana.com/dashboard/db/sensors" @@ -73,7 +91,6 @@ This API can also be used to create, update and delete alert notifications. "dashboardUri": "http://grafana.com/dashboard/db/sensors" } - ## Pause alert `POST /api/alerts/:id/pause` @@ -86,10 +103,15 @@ This API can also be used to create, update and delete alert notifications. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk { - "alertId": 1, "paused": true } +The :id query parameter is the id of the alert to be paused or unpaused. + +JSON Body Schema: + +- **paused** – Can be `true` or `false`. True to pause an alert. False to unpause an alert. + **Example Response**: HTTP/1.1 200 @@ -111,6 +133,8 @@ This API can also be used to create, update and delete alert notifications. Content-Type: application/json Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk + + **Example Response**: HTTP/1.1 200 diff --git a/docs/sources/installation/configuration.md b/docs/sources/installation/configuration.md index 9cfee7140c4..bc1b0eaa360 100644 --- a/docs/sources/installation/configuration.md +++ b/docs/sources/installation/configuration.md @@ -229,6 +229,10 @@ Used for signing keep me logged in / remember me cookies. Set to `true` to disable the use of Gravatar for user profile images. Default is `false`. +### data_source_proxy_whitelist + +Define a white list of allowed ips/domains to use in data sources. Format: `ip_or_domain:port` separated by spaces +
## [users] diff --git a/docs/sources/installation/debian.md b/docs/sources/installation/debian.md index c82b7f1c0e5..2071ff1b79c 100644 --- a/docs/sources/installation/debian.md +++ b/docs/sources/installation/debian.md @@ -17,6 +17,9 @@ Description | Download ------------ | ------------- Stable for Debian-based Linux | [4.2.0 (x86-64 deb)](https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_4.2.0_amd64.deb) +Read [Upgrading Grafana]({{< relref "installation/upgrading.md" >}}) for tips and guidance on updating an existing +installation. + ## Install Stable ``` diff --git a/docs/sources/installation/ldap.md b/docs/sources/installation/ldap.md index e8e1c8e57bd..769ca3fd1ba 100644 --- a/docs/sources/installation/ldap.md +++ b/docs/sources/installation/ldap.md @@ -73,7 +73,7 @@ email = "email" [[servers.group_mappings]] group_dn = "cn=admins,dc=grafana,dc=org" org_role = "Admin" -# The Grafana organization database id, optional, if left out the default org (id 1) will be used +# The Grafana organization database id, optional, if left out the default org (id 1) will be used. Setting this allows for multiple group_dn's to be assigned to the same org_role provided the org_id differs # org_id = 1 [[servers.group_mappings]] diff --git a/docs/sources/installation/migrating_to2.md b/docs/sources/installation/migrating_to2.md index e7e2e96b6ad..a5d6f793ba6 100644 --- a/docs/sources/installation/migrating_to2.md +++ b/docs/sources/installation/migrating_to2.md @@ -3,9 +3,6 @@ title = "Migrating from older versions" description = "Upgrading & Migrating Grafana from older versions" keywords = ["grafana", "configuration", "documentation", "migration"] type = "docs" -[menu.docs] -parent = "installation" -weight = 10 +++ # Migrating from older versions diff --git a/docs/sources/installation/provisioning.md b/docs/sources/installation/provisioning.md deleted file mode 100644 index c3969bcf32d..00000000000 --- a/docs/sources/installation/provisioning.md +++ /dev/null @@ -1,34 +0,0 @@ -+++ -title = "Installing via provisioning tools" -description = "Guide to install Grafana via provisioning tools like puppet & chef" -keywords = ["grafana", "provisioning", "documentation", "puppet", "chef", "ansible"] -type = "docs" -aliases = ["docs/provisioning"] -[menu.docs] -parent = "installation" -weight = 8 -+++ - - -# Installing via provisioning tools - -Here are links for how to install Grafana (and some include Graphite or -InfluxDB as well) via a provisioning system. These are not maintained by -any core Grafana team member and might be out of date. - -### Puppet - -* [forge.puppetlabs.com/bfraser/grafana](https://forge.puppetlabs.com/bfraser/grafana) - -### Ansible - -* [github.com/picotrading/ansible-grafana](https://github.com/picotrading/ansible-grafana) - -### Docker -* [github.com/grafana/grafana-docker](https://github.com/grafana/grafana-docker) - -### Chef - -* [github.com/JonathanTron/chef-grafana](https://github.com/JonathanTron/chef-grafana) -* [github.com/Nordstrom/grafana2-cookbook](https://github.com/Nordstrom/grafana2-cookbook) - diff --git a/docs/sources/installation/rpm.md b/docs/sources/installation/rpm.md index c0952328cbe..69d676d6db8 100644 --- a/docs/sources/installation/rpm.md +++ b/docs/sources/installation/rpm.md @@ -17,6 +17,9 @@ Description | Download ------------ | ------------- Stable for CentOS / Fedora / OpenSuse / Redhat Linux | [4.2.0 (x86-64 rpm)](https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.2.0-1.x86_64.rpm) +Read [Upgrading Grafana]({{< relref "installation/upgrading.md" >}}) for tips and guidance on updating an existing +installation. + ## Install Stable You can install Grafana using Yum directly. diff --git a/docs/sources/installation/troubleshooting.md b/docs/sources/installation/troubleshooting.md index 6da8c4f64f8..a5a74c007aa 100644 --- a/docs/sources/installation/troubleshooting.md +++ b/docs/sources/installation/troubleshooting.md @@ -11,48 +11,24 @@ weight = 8 # Troubleshooting -This page is dedicated to helping you solve any problem you have getting -Grafana to work. Please review it before opening a new [GitHub -issue](https://github.com/grafana/grafana/issues/new) or asking a -question in the `#grafana` IRC channel on freenode. +## visualization & query issues -## General connection issues +The most common problems are related to the query & response from you data source. Even if it looks +like a bug or visualization issue in Grafana it is 99% of time a problem with the data source query or +the data source response. -When setting up Grafana for the first time you might experience issues -with Grafana being unable to query Graphite, OpenTSDB or InfluxDB. You -might not be able to get metric name completion or the graph might show -an error like this: +So make sure to check the query sent and the raw response, learn how in this guide: [How to troubleshoot metric query issues](https://community.grafana.com/t/how-to-troubleshoot-metric-query-issues/50) -![](/img/docs/v1/graph_timestore_error.png) +## Logging -For some types of errors, the `View details` link will show you error -details. For many types of HTTP connection errors, however, there is very -little information. The best way to troubleshoot these issues is use -the [Chrome developer tools](https://developer.chrome.com/devtools/index). -By pressing `F12` you can bring up the chrome dev tools. +If you encounter an error or problem it is a good idea to check the grafana server log. Usually +located at `/var/log/grafana/grafana.log` on unix systems or in `/data/log` on +other platforms & manual installs. -![](/img/docs/v1/toubleshooting_chrome_dev_tools.png) +You can enable more logging by changing log level in you grafana configuration file. -There are two important tabs in the Chrome developer tools: `Network` -and `Console`. The `Console` tab will show you Javascript errors and -HTTP request errors. In the Network tab you will be able to identify the -request that failed and review request and response parameters. This -information will be of great help in finding the cause of the error. +## FAQ -If you are unable to solve the issue, even after reading the remainder -of this troubleshooting guide, you should open a [GitHub support -issue](https://github.com/grafana/grafana/issues). Before you do that -please search the existing closed or open issues. Also if you need to -create a support issue, screen shots and or text information about the -chrome console error, request and response information from the -`Network` tab in Chrome developer tools are of great help. - -### Inspecting Grafana metric requests - -![](/img/docs/v1/toubleshooting_chrome_dev_tools_network.png) - -After opening the Chrome developer tools for the first time the -`Network` tab is empty. You will need to refresh the page to get -requests to show. For some type of errors, especially CORS-related, -there might not be a response at all. +Checkout the [FAQ](https://community.grafana.com/c/howto/faq) section on our community page for frequently +asked questions. diff --git a/docs/sources/installation/upgrading.md b/docs/sources/installation/upgrading.md new file mode 100644 index 00000000000..846a42b454c --- /dev/null +++ b/docs/sources/installation/upgrading.md @@ -0,0 +1,103 @@ ++++ +title = "Upgrading" +description = "Upgrading Grafana guide" +keywords = ["grafana", "configuration", "documentation", "upgrade"] +type = "docs" +[menu.docs] +name = "Upgrading" +identifier = "upgrading" +parent = "installation" +weight = 10 ++++ + +# Upgrading Grafana + +We recommend everyone to upgrade Grafana often to stay up to date with the latest fixes and enhancements. +In order make this a reality Grafana upgrades are backward compatible and the upgrade process is simple & quick. + +Upgrading is generally always safe (between many minor and one major version) and dashboards and graphs will look the same. There can be minor breaking changes in some edge cases which are usually outlined in the [Release Notes](https://community.grafana.com/c/releases) and [Changelog](https://github.com/grafana/grafana/blob/master/CHANGELOG.md) + +## Database Backup + +Before upgrading it can be a good idea to backup your Grafana database. This will ensure that you can always rollback to your previous version. During startup, Grafana will automatically migrate the database schema (if there are changes or new tables). Sometimes this can cause issues if you later want to downgrade. + +#### sqlite + +If you use sqlite you only need to make a backup of you `grafana.db` file. This is usually located at `/var/lib/grafana/grafana.db` on unix system. +If you are unsure what database you use and where it is stored check you grafana configuration file. If you +installed grafana to custom location using a binary tar/zip it is usally in `/data`. + +#### mysql + +``` +backup: +> mysqldump -u root -p[root_password] [grafana] > grafana_backup.sql + +restore: +> mysql -u root -p grafana < grafana_backup.sql +``` + +#### postgres + +``` +backup: +> pg_dump grafana > grafana_backup + +restore: +> psql grafana < grafana_backup +``` + +### Ubuntu / Debian + +If you installed grafana by downloading a debian package (`.deb`) you can just follow the same installation guide +and execute the same `dpkg -i` command but with the new package. It will upgrade your Grafana install. + +If you used our APT repository: + +``` +sudo apt-get update +sudo apt-get install grafana +``` + +#### Upgrading from binary tar file + +If you downloaded the binary tar package you can just download and extract a new package +and overwrite all your existing files. But this might overwrite your config changes. We +recommend you place your config changes in a file named `/conf/custom.ini` +as this will make upgrades easier without risking losing your config changes. + +### Centos / RHEL + +If you installed grafana by downloading a rpm package you can just follow the same installation guide +and execute the same `yum install` or `rpm -i` command but with the new package. It will upgrade your Grafana install. + +If you used our YUM repository: + +``` +sudo yum update grafana +``` + +### Docker + +This just an example, details depend on how you configured your grafana container. +``` +docker pull grafana +docker stop my-grafana-container +docker rm my-grafana-container +docker run --name=my-grafana-container --restart=always -v /var/lib/grafana:/var/lib/grafana +``` + +### Windows + +If you downloaded the windows binary package you can just download a newer package and extract +to the same location (and overwrite the existing files). This might overwrite your config changes. We +recommend you place your config changes in a file named `/conf/custom.ini` +as this will make upgrades easier without risking losing your config changes. + +## Upgrading form 1.x + +[Migrating from 1.x to 2.x]({{< relref "installation/migrating_to2.md" >}}) + +## Upgrading form 2.x + +We are not aware of any issues upgrading directly from 2.x to 4.x but to on the safe side go via 3.x. diff --git a/docs/sources/installation/windows.md b/docs/sources/installation/windows.md index 229654ef58e..d1327d80d3e 100644 --- a/docs/sources/installation/windows.md +++ b/docs/sources/installation/windows.md @@ -15,6 +15,9 @@ Description | Download ------------ | ------------- Latest stable package for Windows | [grafana.4.2.0.windows-x64.zip](https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.2.0.windows-x64.zip) +Read [Upgrading Grafana]({{< relref "installation/upgrading.md" >}}) for tips and guidance on updating an existing +installation. + ## Configure The zip file contains a folder with the current Grafana version. Extract diff --git a/docs/sources/reference/annotations.md b/docs/sources/reference/annotations.md index 8f2170ba145..63b2f5fc327 100644 --- a/docs/sources/reference/annotations.md +++ b/docs/sources/reference/annotations.md @@ -13,42 +13,28 @@ weight = 2 Annotations provide a way to mark points on the graph with rich events. When you hover over an annotation you can get title, tags, and text information for the event. -![](/img/docs/v1/annotated_graph1.png) +![](/img/docs/annotations/toggles.png) -To add an annotation query click dashboard settings icon in top menu and select `Annotations` from the -dropdown. This will open the `Annotations` edit view. Click the `Add` tab to add a new annotation query. +## Queries -> Note: Annotations apply to all graphs in a given dashboard, not on a per-panel basis. +Annotatation events are fetched via annotation queries. To add a new annotation query to a dashboard +open the dashboard settings menu, then select `Annotations`. This will open the dashboard annotations +settings view. To create a new annotation query hit the `New` button. -## Graphite annotations +![](/img/docs/annotations/new_query.png) -Graphite supports two ways to query annotations. +Specify a name for the annotation query. This name is given to the toggle (checkbox) that will allow +you to enable/disable showing annotation events from this query. For example you might have two +annotation queries named `Deploys` and `Outages`. The toggles will allow you to decide what annotations +to show. -- A regular metric query, use the `Graphite target expression` text input for this -- Graphite events query, use the `Graphite event tags` text input, specify an tag or wildcard (leave empty should also work) +### Annotation query details -## Elasticsearch annotations -![](/img/docs/v2/annotations_es.png) +The annotation query options are different for each data source. -Grafana can query any Elasticsearch index for annotation events. The index name can be the name of an alias or an index wildcard pattern. -You can leave the search query blank or specify a lucene query. +- [Graphite annotation queries]({{< relref "features/datasources/graphite.md#annotations" >}}) +- [Elasticsearch annotation queries]({{< relref "features/datasources/elasticsearch.md#annotations" >}}) +- [InfluxDB annotation queries]({{< relref "features/datasources/influxdb.md#annotations" >}}) +- [Prometheus annotation queries]({{< relref "features/datasources/prometheus.md#annotations" >}}) -If your elasticsearch document has a timestamp field other than `@timestamp` you will need to specify that. As well -as the name for the fields that should be used for the annotation title, tags and text. Tags and text are optional. -> **Note** The annotation timestamp field in elasticsearch need to be in UTC format. - -## InfluxDB Annotations -![](/img/docs/v2/annotations_influxdb.png) - -For InfluxDB you need to enter a query like in the above screenshot. You need to have the ```where $timeFilter``` part. -If you only select one column you will not need to enter anything in the column mapping fields. - -## Prometheus Annotations - -![](/img/docs/v3/annotations_prom.png) - -Prometheus supports two ways to query annotations. - -- A regular metric query -- A Prometheus query for pending and firing alerts (for details see [Inspecting alerts during runtime](https://prometheus.io/docs/alerting/rules/#inspecting-alerts-during-runtime)) diff --git a/docs/sources/reference/sharing.md b/docs/sources/reference/sharing.md index 5210b2811df..da89319f444 100644 --- a/docs/sources/reference/sharing.md +++ b/docs/sources/reference/sharing.md @@ -22,7 +22,7 @@ A dashboard snapshot is an instant way to share an interactive dashboard publicl (metric, template and annotation) and panel links, leaving only the visible metric data and series names embedded into your dashboard. Dashboard snapshots can be accessed by anyone who has the link and can reach the URL. -![](/img/docs/v2/dashboard_snapshot_dialog.png) +![](/img/docs/v4/share_panel_modal.png) ### Publish snapshots You can publish snapshots to you local instance or to [snapshot.raintank.io](http://snapshot.raintank.io). The later is a free service @@ -42,8 +42,8 @@ You can embed a panel using an iframe on another web site. This tab will show yo Example: ```html - + ``` Below there should be an interactive Grafana graph embedded in an iframe: - + diff --git a/docs/sources/reference/templating.md b/docs/sources/reference/templating.md index 636cc62a0c8..0405251f44d 100644 --- a/docs/sources/reference/templating.md +++ b/docs/sources/reference/templating.md @@ -10,76 +10,162 @@ weight = 1 # Templating - +Templating allows for more interactive and dynamic dashboards. Instead of hard-coding things like server, application +and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of +the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard. -Dashboard Templating allows you to make your Dashboards more interactive and dynamic. + -They’re one of the most powerful and most used features of Grafana, and they’ve recently gotten even more attention in Grafana 2.0 and Grafana 2.1. +## What is a variable? -You can create Dashboard Template variables that can be used practically anywhere in a Dashboard: data queries on individual Panels (within the Query Editor), the names in your legends, or titles in Panels and Rows. +A variable is a placeholder for a value. You can use variables in metric queries and in panel titles. So when you change +the value, using the dropdown at the top of the dashboard, your panel's metric queries will change to reflect the new value. -You can configure Dashboard Templating by clicking the dropdown cog on the top of the Dashboard while viewing it. +### Interpolation + +Panel titles and metric queries can refer to variables using two different syntaxes: + +- `$` Example: apps.frontend.$server.requests.count +- `[[varname]]` Example: apps.frontend.[[server]].requests.count + +Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of word. Use +the second syntax in expressions like `my.server[[serverNumber]].count`. + +Before queries are sent to your data source the query is **interpolated**, meaning the variable is replaced with its current value. During +interpolation the variable value might be **escaped** in order to conform to the syntax of the query language and where it is used. +For example, a variable used in a regex expression in an InfluxDB or Prometheus query will be regex escaped. Read the data source specific +documentation article for details on value escaping during interpolation. + +### Variable options + +A variable is presented as a dropdown select box at the top of the dashboard. It has a current value and a set of **options**. The **options** +is the set of values you can choose from. + +## Adding a variable + + + +You add variables via Dashboard cogs menu > Templating. This opens up a list of variables and a `New` button to create a new variable. + +### Basic variable options + +Option | Description +------- | -------- +*Name* | The name of the variable, this is the name you use when you refer to your variable in your metric queries. Must be unique and contain no white-spaces. +*Label* | The name of the dropdown for this variable. +*Hide* | Options to hide the dropdown select box. +*Type* | Defines the variable type. -## Variable types +### Variable types -There are three different types of Template variables: query, custom, and interval. +Type | Description +------- | -------- +*Query* | This variable type allows you to write a data source query that usually returns a list of metric names, tag values or keys. For example, a query that returns a list of server names, sensor ids or data centers. +*Interval* | This variable can represent time spans. Instead of hard-coding a group by time or date histogram interval, use a variable of this type. +*Datasource* | This type allows you to quickly change the data source for an entire Dashboard. Useful if you have multiple instances of a data source in for example different environments. +*Custom* | Define the variable options manually using a comma separated list. +*Constant* | Define a hidden constant. Useful for metric path prefixes for dashboards you want to share. During dashboard export, constant variables will be made into an import option. +*Ad hoc filters* | Very special kind of variable that only works with some data sources, InfluxDB & Elasticsearch currently. It allows you to add key/value filters that will automatically be added to all metric queries that use the specified data source. -They can all be used to create dynamic variables that you can use throughout the Dashboard, but they differ in how they get the data for their values. +### Query options +This variable type is the most powerful and complex as it can dynamically fetch its options using a data source query. -### Query +Option | Description +------- | -------- +*Data source* | The data source target for the query. +*Refresh* | Controls when to update the variable option list (values in the dropdown). **On Dashboard Load** will slow down dashboard load as the variable query needs to be completed before dashboard can be initialized. Set this only to **On Time Range Change** if your variable options query contains a time range filter or is dependent on dashboard time range. +*Query* | The data source specific query expression. +*Regex* | Regex to filter or capture specific parts of the names return by your data source query. Optional. +*Sort* | Define sort order for options in dropdown. **Disabled** means that the order of options returned by your data source query will be used. - > Note: The Query type is Data Source specific. Please consult the appropriate documentation for your particular Data Source. +### Query expressions -Query is the most common type of Template variable. Use the `Query` template type to generate a dynamic list of variables, simply by allowing Grafana to explore your Data Source metric namespace when the Dashboard loads. +The query expressions are different for each data source. -For example a query like `prod.servers.*` will fill the variable with all possible values that exists in that wildcard position (in the case of the Graphite Data Source). +- [Graphite templating queries]({{< relref "features/datasources/graphite.md#templating" >}}) +- [Elasticsearch templating queries]({{< relref "features/datasources/elasticsearch.md#templating" >}}) +- [InfluxDB templating queries]({{< relref "features/datasources/influxdb.md#templating" >}}) +- [Prometheus templating queries]({{< relref "features/datasources/prometheus.md#templating" >}}) +- [OpenTSDB templating queries]({{< relref "features/datasources/prometheus.md#templating" >}}) -You can even create nested variables that use other variables in their definition. For example `apps.$app.servers.*` uses the variable $app in its own query definition. +One thing to note is that query expressions can contain references to other variables and in effect create linked variables. +Grafana will detect this and automatically refresh a variable when one of it's containing variables change. -You can utilize the special ** All ** value to allow the Dashboard user to query for every single Query variable returned. Grafana will automatically translate ** All ** into the appropriate format for your Data Source. +## Selection Options -#### Multi-select -As of Grafana 2.1, it is now possible to select a subset of Query Template variables (previously it was possible to select an individual value or 'All', not multiple values that were less than All). This is accomplished via the Multi-Select option. If enabled, the Dashboard user will be able to enable and disable individual variables. +Option | Description +------- | -------- +*Mulit-value* | If enabled, the variable will support the selection of multiple options at the same time. +*Include All option* | Add a special `All` option whose value includes all options. +*Custom all value* | By default the `All` value will include all options in combined expression. This can become very long and can have performance problems. Many times it can be better to specify a custom all value, like a wildcard regex. To make it possible to have custom regex, globs or lucene syntax in the **Custom all value** option it is never escaped so you will have to think avbout what is a valid value for your data source. -The Multi-Select functionality is taken a step further with the introduction of Multi-Select Tagging. This functionality allows you to group individual Template variables together under a Tag or Group name. +### Formating multiple values -For example, if you were using Templating to list all 20 of your applications, you could use Multi-Select Tagging to group your applications by function or region or criticality, etc. +Interpolating a variable with multiple values selected is tricky as it is not straight forward how to format the multiple values to into a string that +is valid in the given context where the variable is used. Grafana tries to solve this by allowing each data source plugin to +inform the templating interpolation engine what format to use for multiple values. - > Note: Multi-Select Tagging functionality is currently experimental but is part of Grafana 2.1. To enable this feature click the enable icon when editing Template options for a particular variable. +**Graphite**, for example, uses glob expressions. A variable with multiple values would, in this case, be interpolated as `{host1,host2,host3}` if +the current variable value was *host1*, *host2* and *host3*. - +**InfluxDB and Prometheus** uses regex expressions, so the same variable +would be interpolated as `(host1|host2|host3)`. Every value would also be regex escaped if not, a value with a regex control character would +break the regex expression. -Grafana gets the list of tags and the list of values in each tag by performing two queries on your metric namespace. +**Elasticsearch** uses lucene query syntax, so the same variable would, in this case, be formatted as `("host1" OR "host2" OR "host3")`. In this case every value +needs to be escaped so that the value can contain lucene control words and quotation marks. -The Tags query returns a list of Tags. +#### Formating troubles -The Tag values query returns the values for a given Tag. +Automatic escaping & formatting can cause problems and it can be tricky to grasp the logic is behind it. +Especially for InfluxDB and Prometheus where the use of regex syntax requires that the variable is used in regex operator context. +If you do not want Grafana to do this automatic regex escaping and formatting your only option is to disable the *Multi-value* or *Include All option* +options. -Note: a proof of concept shim that translates the metric query into a SQL call is provided. This allows you to maintain your tag:value mapping independently of your Data Source. +### Value groups/tags -Once configured, Multi-Select Tagging provides a convenient way to group and your template variables, and slice your data in the exact way you want. The Tags can be seen on the right side of the template pull-down. +If you have a lot of options in the dropdown for a multi-value variable. You can use this feature to group the values into selectable tags. -![](/img/docs/v2/multi-select.gif) +Option | Description +------- | -------- +*Tags query* | Data source query that should return a list of tags +*Tag values query* | Data source query that should return a list of values for a specified tag key. Use `$tag` in the query to refer the currently selected tag. -### Interval +![](/img/docs/v4/variable_dropdown_tags.png) -Use the `Interval` type to create Template variables around time ranges (eg. `1m`,`1h`, `1d`). There is also a special `auto` option that will change depending on the current time range, you can specify how many times the current time range should be divided to calculate the current `auto` range. +### Interval variables -![](/img/docs/v2/templated_variable_parameter.png) +Use the `Interval` type to create a variable that represents a time span (eg. `1m`,`1h`, `1d`). There is also a special `auto` option that will change depending on the current time range. You can specify how many times the current time range should be divided to calculate the current `auto` timespan. -### Custom +This variable type is useful as a parameter to group by time (for InfluxDB), Date histogram interval (for Elasticsearch) or as a *summarize* function parameter (for Graphite). -Use the `Custom` type to manually create Template variables around explicit values that are hard-coded into the Dashboard, and not dependent on any Data Source. You can specify multiple Custom Template values by separating them with a comma. +## Repeating Panels -## Repeating Panels and Repeating Rows +Template variables can be very useful to dynamically change your queries across a whole dashboard. If you want +Grafana to dynamically create new panels or rows based on what values you have selected you can use the *Repeat* feature. -Template Variables can be very useful to dynamically change what you're visualizing on a given panel. Sometimes, you might want to create entire new Panels (or Rows) based on what Template Variables have been selected. This is now possible in Grafana 2.1. +If you have a variable with `Multi-value` or `Include all value` options enabled you can choose one panel or one row and have Grafana repeat that row +for every selected value. You find this option under the General tab in panel edit mode. Select the variable to repeat by, and a `min span`. +The `min span` controls how small Grafana will make the panels (if you have many values selected). Grafana will automatically adjust the width of +each repeated panel so that the whole row is filled. Currently, you cannot mix other panels on a row with a repeated panel. -Once you've got your Template variables (of any type) configured the way you'd like, check out the Repeating Panels and Repeating Row documentation +Only make changes to the first panel (the original template). To have the changes take effect on all panels you need to trigger a dynamic dashboard re-build. +You can do this by either changing the variable value (that is the basis for the repeat) or reload the dashboard. -## Screencast - Templated Graphite Queries +## Repeating Rows - +This option requires you to open the row options view. Hover over the row left side to trigger the row menu, in this menu click `Row Options`. This +opens the row options view. Here you find a *Repeat* dropdown where you can select the variable to repeat by. + +### URL state + +Variable values are always synced to the URL using the syntax `var-=value`. + +### Examples + +- [Graphite Templated Dashboard](http://play.grafana.org/dashboard/db/graphite-templated-nested) +- [Elasticsearch Templated Dashboard](http://play.grafana.org/dashboard/db/elasticsearch-templated) +- [InfluxDB Templated Dashboard](http://play.grafana.org/dashboard/db/influxdb-templated-queries) diff --git a/docs/sources/tutorials/screencasts.md b/docs/sources/tutorials/screencasts.md index f92ead64d49..e92a07c51a7 100644 --- a/docs/sources/tutorials/screencasts.md +++ b/docs/sources/tutorials/screencasts.md @@ -9,58 +9,116 @@ weight = 10 # Screencasts - -{{< screencast src="https://www.youtube.com/embed/sKNZMtoSHN4?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" >}} - -### Episode 7 - Beginners guide to building dashboards - -For newer users of Grafana, this screencast will familiarize you with the general UI and teach you how to build your first Dashboard. - -
- -{{< screencast src="https://www.youtube.com/embed/9ZCMVNxUf6s?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" >}} - -### Episode 6 - Adding data sources, users & organizations - -Now that Grafana has been installed, learn about adding data sources and get a closer look at adding and managing Users and Organizations. - -
- -{{< screencast src="https://www.youtube.com/embed/E-gMFv85FE8?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" >}} - -### Episode 5 - Installation & Configuration on Red Hat / CentOS - -This screencasts shows how to get Grafana 2.0 installed and configured quickly on RPM-based Linux operating systems. - -
-{{< screencast src="https://www.youtube.com/embed/JY22EBOR9hQ?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" >}} - -### Episode 4 - Installation & Configuration on Ubuntu / Debian - -Learn how to easily install the dependencies and packages to get Grafana 2.0 up and running on Ubuntu or Debian in just a few minutes. - -
- -{{< screencast src="https://www.youtube.com/embed/FC13uhFRsVw?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" >}} - -### Episode 3 - Whats New In Grafana 2.0 - -This screencast highlights many of the great new features that were included in the Grafana 2.0 release. - -
- -{{< screencast src="//www.youtube.com/embed/FhNUrueWwOk?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" >}} -### Episode 2 - Templated Graphite Queries - -The screencast focuses on Templating with the Graphite Data Source. Learn how to make dynamic and adaptable Dashboards for your Graphite metrics. - -
- -{{< screencast src="//www.youtube.com/embed/mgcJPREl3CU?list=PLDGkOdUX1Ujo3wHw9-z5Vo12YLqXRjzg2" >}} -### Episode 1 - Building Graphite Queries - -Learn how the Graphite Query Editor works, and how to use different graphing functions. There's also an introduction to graph display settings. - -
- + diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index f7e974db17a..4d84480a208 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -166,10 +166,12 @@ func getPanelSort(id string) int { sort = 3 case "text": sort = 4 - case "alertlist": + case "heatmap": sort = 5 - case "dashlist": + case "alertlist": sort = 6 + case "dashlist": + sort = 7 } return sort } diff --git a/pkg/components/imguploader/s3uploader.go b/pkg/components/imguploader/s3uploader.go index 4f8632f965c..2828008e9b7 100644 --- a/pkg/components/imguploader/s3uploader.go +++ b/pkg/components/imguploader/s3uploader.go @@ -78,5 +78,5 @@ func (u *S3Uploader) Upload(imageDiskPath string) (string, error) { return "", err } - return "https://" + u.bucket + ".s3.amazonaws.com/" + key, nil + return "https://" + u.bucket + ".s3-" + u.region + ".amazonaws.com/" + key, nil } diff --git a/pkg/social/generic_oauth.go b/pkg/social/generic_oauth.go index f0e36ac064c..04b0536852a 100644 --- a/pkg/social/generic_oauth.go +++ b/pkg/social/generic_oauth.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "io/ioutil" "net/http" "github.com/grafana/grafana/pkg/models" @@ -76,9 +77,11 @@ func (s *GenericOAuth) IsOrganizationMember(client *http.Client) bool { func (s *GenericOAuth) FetchPrivateEmail(client *http.Client) (string, error) { type Record struct { - Email string `json:"email"` - Primary bool `json:"primary"` - Verified bool `json:"verified"` + Email string `json:"email"` + Primary bool `json:"primary"` + IsPrimary bool `json:"is_primary"` + Verified bool `json:"verified"` + IsConfirmed bool `json:"is_confirmed"` } emailsUrl := fmt.Sprintf(s.apiUrl + "/emails") @@ -91,14 +94,30 @@ func (s *GenericOAuth) FetchPrivateEmail(client *http.Client) (string, error) { var records []Record - if err = json.NewDecoder(r.Body).Decode(&records); err != nil { + body, err := ioutil.ReadAll(r.Body) + if err != nil { return "", err } + err = json.Unmarshal(body, records) + if err != nil { + var data struct { + Values []Record `json:"values"` + } + + err = json.Unmarshal(body, &data) + if err != nil { + return "", err + } + + records = data.Values + } + var email = "" for _, record := range records { - if record.Primary { + if record.Primary || record.IsPrimary { email = record.Email + break } } @@ -161,11 +180,12 @@ func (s *GenericOAuth) FetchOrganizations(client *http.Client) ([]string, error) func (s *GenericOAuth) UserInfo(client *http.Client) (*BasicUserInfo, error) { var data struct { - Name string `json:"name"` - Login string `json:"login"` - Username string `json:"username"` - Email string `json:"email"` - Attributes map[string][]string `json:"attributes"` + Name string `json:"name"` + DisplayName string `json:"display_name"` + Login string `json:"login"` + Username string `json:"username"` + Email string `json:"email"` + Attributes map[string][]string `json:"attributes"` } var err error @@ -197,6 +217,10 @@ func (s *GenericOAuth) UserInfo(client *http.Client) (*BasicUserInfo, error) { } } + if userInfo.Name == "" && data.DisplayName != "" { + userInfo.Name = data.DisplayName + } + if userInfo.Login == "" && data.Username != "" { userInfo.Login = data.Username } diff --git a/public/app/core/services/segment_srv.js b/public/app/core/services/segment_srv.js index 096697052ce..f1733fcb3e6 100644 --- a/public/app/core/services/segment_srv.js +++ b/public/app/core/services/segment_srv.js @@ -13,6 +13,7 @@ function (angular, _, coreModule) { if (options === '*' || options.value === '*') { this.value = '*'; this.html = $sce.trustAsHtml(''); + this.type = options.type; this.expandable = true; return; } diff --git a/public/app/features/annotations/partials/editor.html b/public/app/features/annotations/partials/editor.html index 8b71e23f467..1506e1a0dc5 100644 --- a/public/app/features/annotations/partials/editor.html +++ b/public/app/features/annotations/partials/editor.html @@ -18,6 +18,12 @@
  • New Query
  • + +
  • + + Help + +