From d3ab1c1c1e4b137ca99a7ebfb30fec1d85be35fb Mon Sep 17 00:00:00 2001 From: Sol <94075844+sjd210@users.noreply.github.com> Date: Tue, 18 Jul 2023 20:37:07 +0100 Subject: [PATCH] Docs: Added queried table to start of Time Series section (#70594) * Added table being queried to start of Time Series section * Update _index.md --- docs/sources/datasources/mysql/_index.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/sources/datasources/mysql/_index.md b/docs/sources/datasources/mysql/_index.md index 0e93cea6c5a..79739603b30 100644 --- a/docs/sources/datasources/mysql/_index.md +++ b/docs/sources/datasources/mysql/_index.md @@ -281,7 +281,21 @@ The resulting table panel: ## Time series queries -If you set Format as to _Time series_, then the query must have a column named time that returns either a SQL datetime or any numeric datatype representing Unix epoch in seconds. In addition, result sets of time series queries must be sorted by time for panels to properly visualize the result. +The examples in this section query the following table: + +```text ++---------------------+--------------+---------------------+----------+ +| time_date_time | value_double | CreatedAt | hostname | ++---------------------+--------------+---------------------+----------+ +| 2020-01-02 03:05:00 | 3.0 | 2020-01-02 03:05:00 | 10.0.1.1 | +| 2020-01-02 03:06:00 | 4.0 | 2020-01-02 03:06:00 | 10.0.1.2 | +| 2020-01-02 03:10:00 | 6.0 | 2020-01-02 03:10:00 | 10.0.1.1 | +| 2020-01-02 03:11:00 | 7.0 | 2020-01-02 03:11:00 | 10.0.1.2 | +| 2020-01-02 03:20:00 | 5.0 | 2020-01-02 03:20:00 | 10.0.1.2 | ++---------------------+--------------+---------------------+----------+ +``` + +If the `Format as` query option is set to `Time Series` then the query must have a column named time that returns either a SQL datetime or any numeric datatype representing Unix epoch in seconds. In addition, result sets of time series queries must be sorted by time for panels to properly visualize the result. A time series query result is returned in a [wide data frame format]({{< relref "../../developers/plugins/introduction-to-plugin-development/data-frames#wide-format" >}}). Any column except time or of type string transforms into value fields in the data frame query result. Any string column transforms into field labels in the data frame query result. @@ -312,6 +326,7 @@ Data frame result: +---------------------+-----------------+ | 2020-01-02 03:05:00 | 3 | | 2020-01-02 03:10:00 | 6 | +| 2020-01-02 03:20:00 | 5 | +---------------------+-----------------+ ``` @@ -341,6 +356,8 @@ Data frame result: +---------------------+---------------------------+---------------------------+ | 2020-01-02 03:05:00 | 3 | 4 | | 2020-01-02 03:10:00 | 6 | 7 | +| 2020-01-02 03:15:00 | 0 | 0 | +| 2020-01-02 03:20:00 | 0 | 5 | +---------------------+---------------------------+---------------------------+ ``` @@ -365,8 +382,9 @@ Data frame result: | Labels: | Labels: | Labels: | | Type: []time.Time | Type: []float64 | Type: []float64 | +---------------------+-----------------+-----------------+ -| 2020-01-02 03:04:00 | 3 | 4 | -| 2020-01-02 03:05:00 | 6 | 7 | +| 2020-01-02 03:05:00 | 3 | 4 | +| 2020-01-02 03:10:00 | 6 | 7 | +| 2020-01-02 03:20:00 | 5 | 5 | +---------------------+-----------------+-----------------+ ```