Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save felixkrohn/c659872f18fbda4fdbd709fbdcd18bbd to your computer and use it in GitHub Desktop.
Save felixkrohn/c659872f18fbda4fdbd709fbdcd18bbd to your computer and use it in GitHub Desktop.
  • log into a router pod (oc rsh -n default router-YY-XXXXX)
  • confirm the socket used by haproxy is /var/lib/haproxy/run/haproxy.sock (using ps ax)
  • connect to the socket with socat socat /var/lib/haproxy/run/haproxy.sock stdio
  • use "prompt" and "help" for the corrsponding actions, or directly call echo "prompt" | socat /var/lib/haproxy/run/haproxy.sock stdio echo "help" | socat /var/lib/haproxy/run/haproxy.sock stdio
  • get raw stats in CSV format. note the "iid" value for the backend you're debugging echo "show stat" | socat /var/lib/haproxy/run/haproxy.sock stdio
  • get "typed" stats in the format [BS].IID.x.FIELD-ID.FIELD-Description with the value in the last column echo "show stat typed" | socat /var/lib/haproxy/run/haproxy.sock stdio

The fields are mapped to prometheus values by the openshift-router-project, which contains code very similar to the prometheus haproxy exporter: https://github.com/openshift/router/blob/master/pkg/router/metrics/haproxy/haproxy.go#L276 https://github.com/bcicen/go-haproxy/blob/master/stat.go#L72

For example field 60 is mapped to "http_average_response_latency_milliseconds", which gets exported to "haproxy_server_http_average_response_latency_milliseconds" on prometheus.

The corresponding CSV fields are described here: https://cbonte.github.io/haproxy-dconv/1.5/configuration.html#9.1 or https://www.haproxy.org/download/1.8/doc/management.txt (see chapter " 9.1. CSV format")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment