Add InfluxQL to Serverless Grafana doc (#5031)

* add influxql to serverless grafana doc

* Apply suggestions from code review

Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com>

---------

Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com>
pull/5035/head
Scott Anderson 2023-07-17 11:09:34 -06:00 committed by GitHub
parent 01fb78db09
commit 803df9b91b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 114 additions and 7 deletions

View File

@ -2,7 +2,8 @@
title: Use Grafana to query and visualize data
list_title: Use Grafana
description: >
Install and run [Grafana](https://grafana.com/) to query and visualize data stored in InfluxDB.
Install and run [Grafana](https://grafana.com/) to query and visualize data
stored in InfluxDB.
weight: 201
menu:
influxdb_cloud_dedicated:
@ -16,7 +17,7 @@ aliases:
- /influxdb/cloud-dedicated/process-data/tools/grafana/
---
Use [Grafana](https://grafana.com/) to query data stored in
Use [Grafana](https://grafana.com/) to query and visualize data stored in
{{% cloud-name %}}.
{{% cloud-name %}} supports both **SQL** and **InfluxQL** query languages.
Install the [Grafana FlightSQL plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/)
@ -28,7 +29,7 @@ Use the **InfluxDB** core Grafana plugin to query data with **InfluxQL**.
> [Grafana] provides you with tools to turn your time-series database (TSDB)
> data into insightful graphs and visualizations.
>
> {{% caption %}}[Grafana documentation](https://grafana.com/docs/grafana/latest/introduction/){{% /caption %}}
> {{% cite %}}[Grafana documentation](https://grafana.com/docs/grafana/latest/introduction/){{% /cite %}}
<!-- TOC -->
@ -54,6 +55,14 @@ If using **Grafana Cloud**, login to your Grafana Cloud instance.
If you want to query {{% cloud-name %}} with **SQL**, install the
[Grafana FlightSQL plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/).
{{% note %}}
#### Only required if using SQL
Installing the Grafana FlightSQL plugin is only required if using **SQL** to query
data from InfluxDB. If using **InfluxQL**, enable the
[Grafana InfluxDB core plugin](/influxdb/cloud-dedicated/process-data/visualize/grafana/?t=InfluxQL#create-a-datasource).
{{% /note %}}
{{< tabs-wrapper >}}
{{% tabs %}}
[Local Grafana](#)

View File

@ -35,7 +35,7 @@ to query InfluxDB with the Flight SQL protocol.
- [Install the FlightSQL plugin](#install-the-flightsql-plugin)
- [Use grafana-cli](#use-grafana-cli)
- [Use the Grafana UI](#use-the-grafana-ui)
- [Create and configure a FlightSQL datasource](#create-and-configure-a-flightsql-datasource)
- [Create a datasource](#create-a-datasource)
- [Query InfluxDB with Grafana](#query-influxdb-with-grafana)
- [Build visualizations with Grafana](#build-visualizations-with-grafana)
@ -50,6 +50,17 @@ If using **Grafana Cloud**, login to your Grafana Cloud instance.
## Install the FlightSQL plugin
If you want to query {{% cloud-name %}} with **SQL**, install the
[Grafana FlightSQL plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/).
{{% note %}}
#### Only required if using SQL
Installing the Grafana FlightSQL plugin is only required if using **SQL** to query
data from InfluxDB. If using **InfluxQL**, enable the
[Grafana InfluxDB core plugin](/influxdb/cloud-serverless/process-data/visualize/grafana/?t=InfluxQL#create-a-datasource).
{{% /note %}}
{{< tabs-wrapper >}}
{{% tabs %}}
[Local Grafana](#)
@ -98,7 +109,21 @@ Grafana Cloud instance.
{{% /tab-content %}}
{{< /tabs-wrapper >}}
## Create and configure a FlightSQL datasource
## Create a datasource
Which datasource you create depends on which query language you want to use to
query {{% cloud-name %}}:
- To query with **SQL**, create a **FlightSQL** datasource.
- To query with **InfluxQL**, create an **InfluxDB** datasource.
{{< tabs-wrapper >}}
{{% tabs %}}
[SQL](#)
[InfluxQL](#)
{{% /tabs %}}
{{% tab-content %}}
<!--------------------------------- BEGIN SQL --------------------------------->
1. In your Grafana user interface (UI), navigate to **Data Sources**.
2. Click **Add new data source**.
@ -132,11 +157,62 @@ Grafana Cloud instance.
If successful, click **Explore** to begin querying InfluxDB with Flight SQL and Grafana.
<!---------------------------------- END SQL ---------------------------------->
{{% /tab-content %}}
{{% tab-content %}}
<!------------------------------- BEGIN INFLUXQL ------------------------------>
{{% note %}}
#### Map databases and retention policies to buckets
To query {{% cloud-name %}} with InfluxQL, first map database and retention policy
(DBRP) combinations to your InfluxDB Cloud buckets. For more information, see
[Map databases and retention policies to buckets](/influxdb/cloud-serverless/query-data/influxql/dbrp/).
{{% /note %}}
1. In your Grafana user interface (UI), navigate to **Data Sources**.
2. Click **Add new data source**.
3. Search for and select the **InfluxDB** core plugin.
4. Provide a name for your datasource.
5. Under **Query Language**, select **InfluxQL**.
6. Under **HTTP**:
- **URL**: Provide your [{{% cloud-name %}} region URL](/influxdb/cloud-serverless/reference/regions/)
using the HTTPS protocol:
```
https://cloud2.influxdata.com
```
7. Under **InfluxDB Details**:
- **Database**: Provide a default database (bucket) name to query.
- **User**: Provide an arbitrary string.
_This credential is ingored when querying {{% cloud-name %}}, but it cannot be empty._
- **Password**: Provide an [API token](/influxdb/cloud-serverless/admin/tokens/)
with read access to the buckets you want to query.
7. Click **Save & test**.
{{< img-hd src="/img/influxdb/cloud-serverless-grafana-influxdb-datasource.png" alt="Grafana InfluxDB datasource for InfluxDB Cloud Serverless" />}}
<!-------------------------------- END INFLUXQL ------------------------------->
{{% /tab-content %}}
{{< /tabs-wrapper >}}
## Query InfluxDB with Grafana
After you [configure and save a FlightSQL datasource](#create-and-configure-a-flightsql-datasource),
After you [configure and save a FlightSQL or InfluxDB datasource](#create-a-datasource),
use Grafana to build, run, and inspect queries against your InfluxDB bucket.
{{< tabs-wrapper >}}
{{% tabs %}}
[SQL](#)
[InfluxQL](#)
{{% /tabs %}}
{{% tab-content %}}
<!--------------------------------- BEGIN SQL --------------------------------->
{{% note %}}
{{% sql/sql-schema-intro %}}
To learn more, see [Query Data](/influxdb/cloud-serverless/query-data/sql/).
@ -155,7 +231,29 @@ To learn more, see [Query Data](/influxdb/cloud-serverless/query-data/sql/).
SQL will return the aggregation for each group or partition.
4. Click **Run query** to execute the query.
{{< img-hd src="/img/influxdb/cloud-serverless-grafana-flightsql-explore-query-1.png" alt="Grafana Flight SQL datasource query" />}}
{{< img-hd src="/img/influxdb/cloud-serverless-grafana-flightsql-explore-query.png" alt="Grafana Flight SQL datasource query" />}}
<!---------------------------------- END SQL ---------------------------------->
{{% /tab-content %}}
{{% tab-content %}}
<!------------------------------- BEGIN INFLUXQL ------------------------------>
1. Click **Explore**.
2. In the dropdown, select the **InfluxDB** data source that you want to query.
3. Use the InfluxQL query form to build your query:
- **FROM**: Select the measurement that you want to query.
- **WHERE**: To filter the query results, enter a conditional expression.
- **SELECT**: Select fields to query and an aggregate function to apply to each.
The aggregate function is applied to each time interval defined in the
`GROUP BY` clause.
- **GROUP BY**: By default, Grafana groups data by time to downsample results
and improve query performance.
You can also add other tags to group by.
4. Click **Run query** to execute the query.
<!-------------------------------- END INFLUXQL ------------------------------->
{{% /tab-content %}}
{{< /tabs-wrapper >}}
To learn about query management and inspection in Grafana, see the [Grafana Explore documentation](https://grafana.com/docs/grafana/latest/explore/).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 KiB

After

Width:  |  Height:  |  Size: 518 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 530 KiB

After

Width:  |  Height:  |  Size: 501 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 KiB