I need to get the long running queries on mysql server for alerting purpose. Found a way but it doesn't work:
show full processlist;
It shows Select sleep(10); but doesn't show select * from my_custom_table;
You're probably going to like the mysql slow query log; see https://dev.mysql.com/doc/refman/5.7/en/slow-query-log.html . In a nutshell, it can log all queries that take longer than a given threshold for later analysis.
Please be sure to look for the version of the doc that corresponds with your mysql version, as this is a fast moving project these days and newer versions may have features that older versions don't .
Finally, be aware that the slow query log can fill up hard disks very quickly, so you have to keep an eye on things when it's enabled.