Commit 8b2bdd80 by Alexandre de Verteuil Committed by GitHub

Docs: Add SQL region annotation examples (#23268)

Add region annotation examples for SQL data sources in docs.

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
parent 263dcb14
...@@ -381,7 +381,7 @@ Read more about variable formatting options in the [Variables]({{< relref "../.. ...@@ -381,7 +381,7 @@ Read more about variable formatting options in the [Variables]({{< relref "../..
Name | Description Name | Description
------------ | ------------- ------------ | -------------
time | The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value. time | The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value.
timeend | Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. timeend | Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. (Grafana v6.6+)
text | Event description field. text | Event description field.
tags | Optional field name to use for event tags as a comma separated string. tags | Optional field name to use for event tags as a comma separated string.
...@@ -411,6 +411,23 @@ WHERE ...@@ -411,6 +411,23 @@ WHERE
ORDER BY 1 ORDER BY 1
``` ```
**Example region query using time and timeend columns with epoch values:**
> Only available in Grafana v6.6+.
```sql
SELECT
time_sec as time,
time_end_sec as timeend,
description as [text],
tags
FROM
[events]
WHERE
$__unixEpochFilter(time_sec)
ORDER BY 1
```
**Example query using time column of native SQL date/time data type:** **Example query using time column of native SQL date/time data type:**
```sql ```sql
......
...@@ -350,6 +350,22 @@ WHERE ...@@ -350,6 +350,22 @@ WHERE
$__unixEpochFilter(epoch_time) $__unixEpochFilter(epoch_time)
``` ```
**Example region query using time and timeend columns with epoch values:**
> Only available in Grafana v6.6+.
```sql
SELECT
epoch_time as time,
epoch_timeend as timeend,
metric1 as text,
CONCAT(tag1, ',', tag2) as tags
FROM
public.test_data
WHERE
$__unixEpochFilter(epoch_time)
```
**Example query using time column of native SQL date/time data type:** **Example query using time column of native SQL date/time data type:**
```sql ```sql
...@@ -366,7 +382,7 @@ WHERE ...@@ -366,7 +382,7 @@ WHERE
Name | Description Name | Description
------------ | ------------- ------------ | -------------
time | The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value. time | The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value.
timeend | Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. timeend | Optional name of the end date/time field. Could be a column with a native SQL date/time data type or epoch value. (Grafana v6.6+)
text | Event description field. text | Event description field.
tags | Optional field name to use for event tags as a comma separated string. tags | Optional field name to use for event tags as a comma separated string.
......
...@@ -354,6 +354,22 @@ WHERE ...@@ -354,6 +354,22 @@ WHERE
$__unixEpochFilter(epoch_time) $__unixEpochFilter(epoch_time)
``` ```
**Example region query using time and timeend columns with epoch values:**
> Only available in Grafana v6.6+.
```sql
SELECT
epoch_time as time,
epoch_time_end as timeend,
metric1 as text,
concat_ws(', ', metric1::text, metric2::text) as tags
FROM
public.test_data
WHERE
$__unixEpochFilter(epoch_time)
```
**Example query using time column of native SQL date/time data type:** **Example query using time column of native SQL date/time data type:**
```sql ```sql
...@@ -370,7 +386,7 @@ WHERE ...@@ -370,7 +386,7 @@ WHERE
Name | Description Name | Description
------------ | ------------- ------------ | -------------
time | The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value. time | The name of the date/time field. Could be a column with a native SQL date/time data type or epoch value.
timeend | Optional name of the time end field, needs to be date/time data type. If set, then annotations are marked as regions between time and time-end. timeend | Optional name of the time end field, needs to be date/time data type. If set, then annotations are marked as regions between time and time-end. (Grafana v6.6+)
text | Event description field. text | Event description field.
tags | Optional field name to use for event tags as a comma separated string. tags | Optional field name to use for event tags as a comma separated string.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment