Grafana显示MySQL连接数

时间:2019-03-11 16:40:49

标签: mysql connection grafana status

如何编写由仪表板运行的查询以获取MySQL活动连接?

有MySQL查询,例如:

show status like 'Connections';

show status where `variable_name` = 'Threads_connected';

当从MySQL控制台客户端使用时可以提供预期的结果

但是,如果Grafana查询如下所示,如何使用它们:

SELECT
  date_time AS "time",
  interesting_data AS "measurement"
FROM test
WHERE
  $__timeFilter(date_time)
ORDER BY date_time

由于没有带日期/时间戳的表,我想查询一下,我将date_time更改为NOW():

  SELECT
  NOW() AS "time",
  6 as "connections";

并且仪表板显示了硬编码的号码,但是如何使用真实查询获取真实的连接号码?

1 个答案:

答案 0 :(得分:1)

查询information_schema.processlist

SELECT 
  NOW() AS "time", 
  count(*) AS "count"
FROM information_schema.processlist;