HAProxy Enterprise Documentation 2.0r1

show stat

Get statistics that describe traffic flowing through the load balancer.

Description

The show stat command returns the current values of all statistics metrics. You can format the data as:

  • Comma-separated values (CSV)

  • Typed

  • JSON

CSV format

The command returns data in the CSV format by default. The field names make up the first line:

$ echo "show stat" | sudo socat stdio /var/run/hapee-2.0/hapee-lb.sock

# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,agent_status,agent_code,agent_duration,check_desc,agent_desc,check_rise,check_fall,check_health,agent_rise,agent_fall,agent_health,addr,cookie,mode,algo,conn_rate,conn_rate_max,conn_tot,intercepted,dcon,dses,wrew,connect,reuse,cache_lookups,cache_hits,srv_icur,src_ilim,qtime_max,ctime_max,rtime_max,ttime_max,eint,idle_conn_cur,safe_conn_cur,used_conn_cur,need_conn_est,
fe_main,FRONTEND,,,0,3,5000,3,1735,869,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,2,,,,2,0,2,0,0,0,,0,2,4,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,0,2,3,0,0,0,0,,,0,0,,,,,,,0,,,,,
webservers,s1,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,100,1,0,0,0,12210,0,,1,3,1,,0,,2,0,,0,L4OK,,0,0,0,0,0,0,0,,,,0,0,0,,,,,-1,,,0,0,0,0,,,,Layer4 check passed,,2,3,4,,,,127.0.0.1:8080,,http,,,,,,,,0,0,0,,,0,,0,0,0,0,0,0,0,0,0,
webservers,s2,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,100,1,0,0,0,12210,0,,1,3,2,,0,,2,0,,0,L4OK,,0,0,0,0,0,0,0,,,,0,0,0,,,,,-1,,,0,0,0,0,,,,Layer4 check passed,,2,3,4,,,,127.0.0.1:8081,,http,,,,,,,,0,0,0,,,0,,0,0,0,0,0,0,0,0,0,
webservers,BACKEND,0,0,0,0,500,0,0,0,0,0,,0,0,0,0,UP,200,2,0,,0,12210,0,,1,3,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,0,0,0,0,0,0,0,-1,,,0,0,0,0,,,,,,,,,,,,,,http,roundrobin,,,,,,,0,0,0,0,0,,,0,0,0,0,0,,,,,

Each line represents a frontend, listen, backend or server from your configuration. To see a description of each field, run show stat with the typed format and the desc parameter.

Typed format

Specify the typed parameter to enable the typed format, wherein each metric is on its own line.

$ echo "show stat typed" | sudo socat stdio /var/run/hapee-2.0/hapee-lb.sock

F.2.0.0.pxname.1:KNS:str:fe_main
F.2.0.1.svname.1:KNS:str:FRONTEND
F.2.0.4.scur.1:MGP:u32:0
F.2.0.5.smax.1:MMP:u32:3
F.2.0.6.slim.1:CLP:u32:5000
F.2.0.7.stot.1:MCP:u64:3
F.2.0.8.bin.1:MCP:u64:1735

Each line begins with a dot-delimited value (e.g. F.2.0.0.pxname.1) that has these fields:

  • a letter that identifies the proxy type: an F (frontend), B (backend), L (listen), or S (server).

  • a number that represents a unique ID for the proxy; This corresponds to the iid column in the CSV output.

  • a number that applies only to server lines and is zero otherwise; It represents the server's unique ID and corresponds to the sid column in the CSV output.

  • a number that increments for each field in the same group.

  • the name of the field (e.g. pxname).

  • the process number, starting at 1.

The rest of the values are separated by colons. They break down as follows:

  • three letters that correspond to the field's origin, nature, and scope of the variable:

    • Origin can be M (metric), S (status), K (key), C (config), or P (product).

    • Nature can be G (gauge), L (limit), m (min), M (max), R (rate), C (counter), D (duration), A (age), T (time), N (name), O (output), or a (average).

    • Scope can be P (process), S (service), s (system), or C (cluster).

  • the field's type (e.g. str for string and u32 for unsigned 32-bit integer);

  • the value itself.

Add the desc parameter to the command to append a description of each line:

$ echo "show stat typed desc" | sudo socat stdio /var/run/hapee-2.0/hapee-lb.sock

F.2.0.0.pxname.1:KNS:str:fe_main:"Proxy name"
F.2.0.1.svname.1:KNS:str:FRONTEND:"Server name"
F.2.0.4.scur.1:MGP:u32:0:"Current number of sessions on the frontend, backend or server"
F.2.0.5.smax.1:MMP:u32:3:"Highest value of scur encountered since process started"
F.2.0.6.slim.1:CLP:u32:5000:"Frontend/listener/server's maxconn, backend's fullconn"
F.2.0.7.stot.1:MCP:u64:3:"Total number of sessions since process started"
F.2.0.8.bin.1:MCP:u64:1735:"Total number of request bytes since process started"

JSON format

Specify the json parameter to enable the JSON format. To make it human-readable, pipe the result to a JSON formatting tool, such as Python's json.tool.

$ echo "show stat json" | sudo socat stdio /var/run/hapee-2.0/hapee-lb.sock | python3 -m json.tool | less

[
 [
     {
         "objType": "Frontend",
         "proxyId": 2,
         "id": 0,
         "field": {
             "pos": 0,
             "name": "pxname"
         },
         "processNum": 1,
         "tags": {
             "origin": "Key",
             "nature": "Name",
             "scope": "Service"
         },
         "value": {
             "type": "str",
             "value": "fe_main"
         }
     },
     {
         "objType": "Frontend",
         "proxyId": 2,
         "id": 0,
         "field": {
             "pos": 1,
             "name": "svname"
         },
         "processNum": 1,
         "tags": {
             "origin": "Key",
             "nature": "Name",
             "scope": "Service"
         },
         "value": {
             "type": "str",
             "value": "FRONTEND"
         }
     },

The format of the JSON document is described in a schema, which you can get by calling show schema json.

Filtering

By default, show stat returns metrics for all proxy sections in your configuration. However, you can add a filter to return only the data that you want to see.

Specify three values:

  • either the proxy name or its numeric iid value

  • a numeric type: 1 for frontends, 2 for backends, 4 for servers, and -1 for everything. Add these numbers to see multiple types at once.

  • A server's sid value or -1.

Below, we show all servers in the backend webservers by specifying the section's name followed by 4 for servers and then -1:

$ echo "show stat webservers 4 -1" | sudo socat stdio /var/run/hapee-2.0/hapee-lb.sock
# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,agent_status,agent_code,agent_duration,check_desc,agent_desc,check_rise,check_fall,check_health,agent_rise,agent_fall,agent_health,addr,cookie,mode,algo,conn_rate,conn_rate_max,conn_tot,intercepted,dcon,dses,wrew,connect,reuse,cache_lookups,cache_hits,srv_icur,src_ilim,qtime_max,ctime_max,rtime_max,ttime_max,eint,idle_conn_cur,safe_conn_cur,used_conn_cur,need_conn_est,
webservers,server1,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,100,1,0,0,0,14207,0,,1,3,1,,0,,2,0,,0,L4OK,,0,0,0,0,0,0,0,,,,0,0,0,,,,,-1,,,0,0,0,0,,,,Layer4 check passed,,2,3,4,,,,127.0.0.1:8080,,http,,,,,,,,0,0,0,,,0,,0,0,0,0,0,0,0,0,0,
webservers,server2,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,100,1,0,0,0,14207,0,,1,3,2,,0,,2,0,,0,L4OK,,0,0,0,0,0,0,0,,,,0,0,0,,,,,-1,,,0,0,0,0,,,,Layer4 check passed,,2,3,4,,,,127.0.0.1:8081,,http,,,,,,,,0,0,0,,,0,,0,0,0,0,0,0,0,0,0,

Examples

In the example below, we get the current values for statistics in the standard CSV format. Then, we pipe the results to the cut and column commands to display only the proxy and server name, the number of retries, the status, the number of 4xx and 5xx HTTP error responses, the request rate, and the average response time.

$ echo "show stat" | sudo socat stdio /var/run/hapee-2.0/hapee-lb.sock | cut -d "," -f 1-2,16,18,43,44,47,61 | column -s, -t

# pxname    svname  wretr  status  hrsp_4xx  hrsp_5xx  req_rate  rtime
webservers  s1      0      UP      0         0         0
webservers  s2      0      UP      0         0         0

Add the watch command to update these numbers every two seconds:

$ watch 'echo "show stat" | sudo socat stdio /var/run/hapee-2.0/hapee-lb.sock | cut -d "," -f 1-2,16,18,43,44,47,61 | column -s, -t'

See also


Next up

Lua scripts