docs: influxdb docs update
This commit is contained in:
@@ -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
|
||||

|
||||
|
||||
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,9 +126,41 @@ 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.
|
||||
|
||||

|
||||
```sql
|
||||
SHOW TAG KEYS [FROM <measurement_name>]
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
`$<varname>` 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user