Create a Custom MySQL Time Series Query

Video Lecture

Create a Custom MySQL Time Series Query Create a Custom MySQL Time Series Query Create a Custom MySQL Time Series Query

Description

We create a custom MySQL time series query that reads data from a our table in our MySQL database and formats the result set in a way that Grafana can use as a time series result set, and present that data in a graph along with the ability to filter that data using the Grafana user interface time filter drop down.

Create a Custom MySQL Time Series Query

Sample SQL Script

The final sql script used in this lecture is,

SELECT
  UNIX_TIMESTAMP(timest) as time,
  cast(variable_value as signed) as value,
  variable_name as metric
FROM my2.status
WHERE $__timeFilter(timest)
and variable_name = 'threads_running'
ORDER BY timest ASC