Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 能否通过sql拿到当前数据库的线程信息?
【 TiDB Version】5.7.25-TiDB-v6.0.0
Question: Can we get the current database thread information through SQL?
Using SQL SHOW GLOBAL STATUS
WHERE
Variable_name LIKE ‘thread%’
OR Variable_name = ‘com_commit’
OR Variable_name = ‘com_rollback’
OR Variable_name = ‘questions’
OR Variable_name = ‘uptime’
MySQL:
TiDB:
Or is it possible to use SQL to monitor the current database status and obtain some values? Is there such an SQL? I haven’t found such documentation yet.
Can’t we use metrics? TiDB itself uses Prometheus, which I understand should be sufficient.
Directly using this won’t work?
Thank you, I just found the monitoring data in the METRICS related tables.
For integrating with internal company projects, only SQL methods can be used.
Well, each component of TiDB has a metrics API on the status port. If your company has specific format requirements, you can write a script in Python to fetch it
However, I still recommend using the official monitoring and alerting tools provided, as they are generally sufficient.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.