Reference
show table
List entries in a stick table.
Description Jump to heading
With no arguments, show table
lists all stick tables you’ve defined, but not the data within them.
When given the name of a stick table, it displays the records in that table.
You can also specify filter expressions where the stat name is preceded by data.
.
Examples Jump to heading
Consider this real-world example that uses a stick-table
to track clients that exceed a rate limit and bans clients that exceed the limit three times:
haproxy
frontend fe_mainbind :80# define stick tablestick-table type ip size 100k expire 24h store http_req_rate(5s),gpc0,gpt0# begin tracking requests where the key in the table# is the client's source IPhttp-request track-sc0 src# has the client exceeded 20 requests in 5 seconds?acl exceeds_rate_limit sc_http_req_rate(0) gt 20# flag them if they exceeded the limithttp-request sc-set-gpt0(0) 1 if exceeds_rate_limit# if they exceeded the limit 3 times, mark them as a known speederacl known_speeder sc_get_gpc0(0) ge 3# deny all clients that exceed the limit or are known speedershttp-request deny deny_status 429 if exceeds_rate_limit || known_speeder# count each time they exceed the limit if they were flaggedacl issue_speeding_ticket sc_get_gpt0(0) eq 1http-request sc-inc-gpc0(0) if issue_speeding_ticket# reset the flaghttp-request sc-set-gpt0(0) 0default_backend be_servers
haproxy
frontend fe_mainbind :80# define stick tablestick-table type ip size 100k expire 24h store http_req_rate(5s),gpc0,gpt0# begin tracking requests where the key in the table# is the client's source IPhttp-request track-sc0 src# has the client exceeded 20 requests in 5 seconds?acl exceeds_rate_limit sc_http_req_rate(0) gt 20# flag them if they exceeded the limithttp-request sc-set-gpt0(0) 1 if exceeds_rate_limit# if they exceeded the limit 3 times, mark them as a known speederacl known_speeder sc_get_gpc0(0) ge 3# deny all clients that exceed the limit or are known speedershttp-request deny deny_status 429 if exceeds_rate_limit || known_speeder# count each time they exceed the limit if they were flaggedacl issue_speeding_ticket sc_get_gpt0(0) eq 1http-request sc-inc-gpc0(0) if issue_speeding_ticket# reset the flaghttp-request sc-set-gpt0(0) 0default_backend be_servers
-
Use
show table
with no arguments to list the tables you’ve defined.nixecho "show table" | \sudo socat stdio tcp4-connect:127.0.0.1:9999nixecho "show table" | \sudo socat stdio tcp4-connect:127.0.0.1:9999outputtext# table: fe_main, type: ip, size:102400, used:3outputtext# table: fe_main, type: ip, size:102400, used:3Here, it lists one table.
-
Use
show table
with the name of the table to display the records in that table.nixecho "show table fe_main" | \sudo socat stdio tcp4-connect:127.0.0.1:9999nixecho "show table fe_main" | \sudo socat stdio tcp4-connect:127.0.0.1:9999outputtext# table: fe_main, type: ip, size:102400, used:10x5641b364f7e8: key=192.168.50.19 use=0 exp=86398242 gpt0=0 gpc0=3 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.24 use=0 exp=86398220 gpt0=0 gpc0=1 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.30 use=0 exp=86398250 gpt0=0 gpc0=0 http_req_rate(5000)=5outputtext# table: fe_main, type: ip, size:102400, used:10x5641b364f7e8: key=192.168.50.19 use=0 exp=86398242 gpt0=0 gpc0=3 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.24 use=0 exp=86398220 gpt0=0 gpc0=1 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.30 use=0 exp=86398250 gpt0=0 gpc0=0 http_req_rate(5000)=5Here, it lists records in the table
fe_main
.The
key
is the client’s IP address, and there are three counters tracked:gpt0
,gpc0
, andhttp_req_rate(5000)
. -
Use
show table
to display the records having a request rate greater than 4.nixecho "show table fe_main data.http_req_rate gt 4" | \sudo socat stdio tcp4-connect:127.0.0.1:9999nixecho "show table fe_main data.http_req_rate gt 4" | \sudo socat stdio tcp4-connect:127.0.0.1:9999outputtext# table: fe_main, type: ip, size:102400, used:10x5641b364f7e8: key=192.168.50.19 use=0 exp=86398242 gpt0=0 gpc0=3 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.24 use=0 exp=86398220 gpt0=0 gpc0=1 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.30 use=0 exp=86398250 gpt0=0 gpc0=0 http_req_rate(5000)=5outputtext# table: fe_main, type: ip, size:102400, used:10x5641b364f7e8: key=192.168.50.19 use=0 exp=86398242 gpt0=0 gpc0=3 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.24 use=0 exp=86398220 gpt0=0 gpc0=1 http_req_rate(5000)=50x5641b364f7e8: key=192.168.50.30 use=0 exp=86398250 gpt0=0 gpc0=0 http_req_rate(5000)=5
See also Jump to heading
Do you have any suggestions on how we can improve the content of this page?