From 8b2bdd807bc6e2499128524739ae99a9ca7413f0 Mon Sep 17 00:00:00 2001 From: Alexandre de Verteuil Date: Wed, 8 Apr 2020 20:32:45 -0400 Subject: [PATCH] Docs: Add SQL region annotation examples (#23268) Add region annotation examples for SQL data sources in docs. Co-authored-by: Marcus Efraimsson --- docs/sources/features/datasources/mssql.md | 19 ++++++++++++++++++- docs/sources/features/datasources/mysql.md | 18 +++++++++++++++++- docs/sources/features/datasources/postgres.md | 18 +++++++++++++++++- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/docs/sources/features/datasources/mssql.md b/docs/sources/features/datasources/mssql.md index 1f10d6687fd..21d1e1de407 100644 --- a/docs/sources/features/datasources/mssql.md +++ b/docs/sources/features/datasources/mssql.md @@ -381,7 +381,7 @@ Read more about variable formatting options in the [Variables]({{< relref "../.. 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. -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. tags | Optional field name to use for event tags as a comma separated string. @@ -411,6 +411,23 @@ WHERE 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:** ```sql diff --git a/docs/sources/features/datasources/mysql.md b/docs/sources/features/datasources/mysql.md index 71ba037c613..7b507de2022 100755 --- a/docs/sources/features/datasources/mysql.md +++ b/docs/sources/features/datasources/mysql.md @@ -350,6 +350,22 @@ WHERE $__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:** ```sql @@ -366,7 +382,7 @@ WHERE 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. -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. tags | Optional field name to use for event tags as a comma separated string. diff --git a/docs/sources/features/datasources/postgres.md b/docs/sources/features/datasources/postgres.md index 6b7138a4fa0..d3be554752f 100755 --- a/docs/sources/features/datasources/postgres.md +++ b/docs/sources/features/datasources/postgres.md @@ -354,6 +354,22 @@ WHERE $__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:** ```sql @@ -370,7 +386,7 @@ WHERE 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. -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. tags | Optional field name to use for event tags as a comma separated string.