Is there a command-line method to obtain the results displayed by the dashboard topsql?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 有没有命令行的方式 获取 dashboard topsql 展示的结果?

| username: MrSylar

After enabling dashboard topsql, it can display component SQL and CPU time. Is there a way to display this result via the command line?

| username: 小龙虾爱大龙虾 | Original post link

Why use the command line?

| username: 源de爸 | Original post link

Are you using the command line to retrieve it in order to create an alert and push it to DingTalk?

| username: MrSylar | Original post link

The purpose is to demonstrate in another place.

| username: MrSylar | Original post link

Not for alerts, for other requirements.

| username: TIDB-Learner | Original post link

The data sources are all under information_schema, right? Just do a select query :face_with_peeking_eye:

| username: 连连看db | Original post link

You can call its HTTP interface, wrap it yourself, and it can also be used.

| username: 随缘天空 | Original post link

Take a look at the console for the interfaces being called using F12, then try calling them with Postman.

| username: miya | Original post link

You can set up monitoring and alerts through Grafana, and top SQL will be sent to you in real-time via email. I’m not sure about the command line method. If any expert knows, I would like to learn as well.

| username: DBRE | Original post link

Also, the time range selection in the dashboard is not very user-friendly.

| username: DBRE | Original post link

You can consider using Filebeat to collect slow SQL logs and eventually store them in TiDB. You can then analyze the data however you want.

| username: DBAER | Original post link

Slow Query Log | PingCAP Documentation Center

Something like this?

| username: DBAER | Original post link

Additionally, you can also use this