Mysql – Store regular MySQL query results in a timeseries DB

influx-dbMySQL

I'm looking into installing a timeseries database like InfluxDB or Prometheus to handle data for our Grafana monitoring system.

One of the things I like to do is run a couple of MySQL queries every few minutes to gather business metrics (like number of subscribers or application usage metrics).

Documentation for these timeseries databases feature plenty of examples of how to get MySQL performance metrics into their stores but I can't find any that demonstrates how to store data from queries.

Google search results seem to be completely drowned out by the more typical use case of gathering MySQL performance metrics.

Is this at all possible with either InfluxDB or Prometheus and where can I find information on how to set this up?

Best Answer

You can write a simple script, which would periodically execute SQL query and push its results to a TSDB via one of the supported data ingestion protocols. Various TSDBs support various data ingestion protocols: Influx line protocol, Graphite plaintext protocol, OpenTSDB telnet put protocol, JSON, CSV, etc. For example, all these protocols are supported by VictoriaMetrics - see these docs for details.