Web application to view and kill MySQL queries

Latest on Hackage:0.3.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

MIT licensed and maintained by Igor Pashev

My Watch

Web application for viewing and killing MySQL queries on multiple servers. Designed to work behind Sproxy.


MyWatch is written in Haskell with GHC. All required Haskell libraries are listed in mywatch.cabal. Use cabal-install to fetch and build all pre-requisites automatically.


$ git clone
$ cd mywatch
$ cabal install


Type mywatch --help to see usage summary:

  mywatch [options] MYCNF


  -d, --datadir=DIR        Data directory including static files [default: {cabal data dir}]

  -s, --socket=SOCK        Listen on this UNIX-socket [default: /tmp/mywatch.sock]
  -p, --port=PORT          Instead of UNIX-socket, listen on this TCP port (localhost)

  -h, --help               Show this message


The MYCNF argument denotes a MySQL client config file. Each section in this file describes a MySQL server where you can view processes. As usually, the “client” section applies internally to all other sections, but is ignored by MyWatch. Remember to make this file secret if it includes passwords, or use the !include directive. However, MyWatch does not parse included files for more sections.

host =
user = user1

host =
user = user2

!include /run/keys/my.secret.cnf

Sproxy Configuration

  • To access the service allow GET for /, /static/% and /serverlist.json.
  • To see processes on a particular MySQL server allow GET and (optional) HEAD for /server/:server/processlist.json. The latter is only required with Sproxy2 before version 1.95.0
  • To kill processes allow DELETE for /server/:server/process/%

Database Configuration

MyWatch needs the PROCESS privilege.

To be able to kill queries a procedure named mywatch_kill must exist in the mysql database. MyWatch invokes CALL mysql.mywatch_kill(id) for killing queries. It’s up to you how to implement this routine, for a safe example see sql/mywatch_kill.sql. Of course, MyWatch should be granted to execute this procedure. If this procedure does not exist, MyWatch will not show this possibility in user interface, API will work, but result in Internal Server Error (HTTP 500). There is no filtering at application level, though the “kill” button may not be shown in some circumstances.


MyWatch1 MyWatch2



  • Support Sproxy’s end-point /.sproxy/access to find servers, available to the current user, in one single HTTP request. This requires Sproxy2 >= 1.95.0. Fallback to old multiple-request way if that end-point returns error.


  • Compress all responses with gzip if acceptable


  • Allow killing queries via CALL mysql.mywatch_kill(id). You should have this routine on your database server and grant MyWatch privilege to execute it. Provided a safe example of this function.

  • Minor improvements in UI


  • Use location hash for server name
  • Compact server list (display: inline-block)


  • Request HEAD /server/:server/processlist.json before showing the server to user. This is to hide servers which are not allowed by Sproxy to this user.

  • Added a workaround for buggy haskell mysql package causing a heisenbug that random sections of the configuration files were not found by libmysqlclient.

  • Added a workaround for the way MariaDB’s libmysqlclient processes SSL options. SSL now works with MariaDB’s libmysqlclient.

  • Fixed parsing of GRANT queries (they have NULL states)


  • Initial version
  • Only view queries
comments powered byDisqus