title: Logging query response time at load-balancer
body: <p>I have three MySQL database servers setup with master-master circular replication. The replication is working, so that is good.
  I am using <a href="https://www.digitalocean.com/community/tutorials/how-to-use-haproxy-to-set-up-mysql-load-balancing--3" rel="nofollow">HAProxy for loadbalancing</a> with rsyslog,
  here is my haproxy.cfg:</p>
  
  <pre><code>global
      log 127.0.0.1 local0 notice
      user haproxy
      group haproxy
  
  defaults
      log global
      retries 2
      timeout connect 3000
      timeout server 5000
      timeout client 5000
  
  listen mysql-cluster
      bind 0.0.0.0:3306
      mode tcp
      option tcplog
      log global
      option mysql-check user haproxy_check
      balance roundrobin
      server database1 10.2.10.102:3306 check
      server database2 10.2.10.103:3306 check
      server database3 10.2.10.104:3306 check
  </code></pre>
  
  <p>I have uncommented the following lines from /etc/rsyslog.conf:</p>
  
  <pre><code># provides UDP syslog reception
  $ModLoad imudp
  $UDPServerAddress 127.0.0.1
  $UDPServerRun 514
  
  # provides TCP syslog reception
  $ModLoad imtcp
  $InputTCPServerRun 514
  </code></pre>
  
  <p>and this in /etc/rsyslog.d/haproxy.conf:</p>
  
  <pre><code>if ($programname == 'haproxy') then -/var/log/haproxy.log
  </code></pre>
  
  <p>The log is working in a way:</p>
  
  <pre><code>May 27 18:44:38 localhost haproxy[26517]: Proxy mysql-cluster started.
  May 27 18:44:38 localhost haproxy[26517]: Proxy mysql-cluster started.
  May 27 18:45:02 localhost haproxy[26535]: Proxy mysql-cluster started.
  </code></pre>
  
  <p>But it does not show any entries for requests to MySQL such as when I run this command on the HAproxy VM:</p>
  
  <pre><code>mysql -h 127.0.0.1 -u haproxy_root -p$MYSQL_PASSWORD -e "show tables in mydatabase"
  </code></pre>
  
  <p>My HAproxy version is 1.5
  I want to know if I can log response times for MySQL queries in HAproxy, and how to do that?</p>