Score:0

Haproxy rate limit monitoring

pm flag

I’m using rate limiting with my haproxy18 and I’d like to somehow squeeze out metrics from it based on ip addresses, who is close to the limit or how the users are hitting the limits.

This is my config related to rate limiting:

...
    stick-table type ip size 1m expire 10s store http_req_rate(10s)

    tcp-request inspect-delay 10s
    tcp-request content track-sc0 src
    http-request deny deny_status 429 if { sc_http_req_rate(0) gt 5000 }
...

At the moment what I can do is a very silly solution and I don’t like, in a while loop I’m listening the socket and I might redirect to a file the output:

while sleep 0.5;do
                printf 'show table https\nshow table http\n' |nc -U /var/lib/haproxy/stats done

This is the output of the while, what I'm interested in is the ip and the last number in the line:

0x561fd2fe50b0: key=10.118.171.119 use=6 exp=8726 http_req_rate(10000)=9
0x561fd31b0270: key=10.118.172.20 use=6 exp=9104 http_req_rate(10000)=10
0x561fd31d0ac0: key=10.118.172.192 use=34 exp=9999 http_req_rate(10000)=1736

I’d like to know is there any other more elegant solution please or how can I convert this to log entry?

I was thinking to put the date command like this but I should append all the lines in the table so I need to redirect this output to a file and edit then let the metric collector pick up, I assume there is some prettier solution.

while sleep 0.5;do date;printf 'show table https\nshow table http\n' |nc -U /var/lib/haproxy/stats;done

Thank you

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.