Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

429 status not reported from ratelimit middleware #29

Open
sporkmonger opened this issue Jul 31, 2017 · 8 comments
Open

429 status not reported from ratelimit middleware #29

sporkmonger opened this issue Jul 31, 2017 · 8 comments

Comments

@sporkmonger
Copy link

The https://github.com/xuqingfeng/caddy-rate-limit plugin sends 429 responses when rate limits are hit, but as best as I can tell, the prometheus plugin doesn't report them. The middleware return value is here: https://github.com/xuqingfeng/caddy-rate-limit/blob/master/ratelimit.go#L84

And it seems like https://github.com/miekg/caddy-prometheus/blob/master/handler.go#L25-L35 ought to handle it correctly, but for reasons unknown, no "429" appears anywhere in our metrics even though they do appear in our logs and we've been able to successfully trigger them manually and observe that there is indeed a 429 response coming across the wire.

@miekg
Copy link
Owner

miekg commented Aug 1, 2017 via email

@sporkmonger
Copy link
Author

Yup, printing status comes back 429.

@sporkmonger
Copy link
Author

Is it possible that the middleware chain was short circuited by the rate limit hit and prometheus plugin never gets called?

@miekg
Copy link
Owner

miekg commented Aug 1, 2017 via email

@sporkmonger
Copy link
Author

Just to confirm, prometheus should be first?

@miekg
Copy link
Owner

miekg commented Aug 1, 2017 via email

@gonzalop
Copy link

gonzalop commented Apr 5, 2019

I have a similar issue with 304s. I've tried having prometheus as the first line for the servers to no avail.

@krichprollsch
Copy link

krichprollsch commented Sep 11, 2019

Hello, I have the same issue too.
As @miekg said, I have fixed it by moving the prometheus declaration into caddyhttp/httpserver/plugin.go before ratelimit and re-building caddy from sources.

What about doing a PR on caddy to move prometheus earlier into the list?
Do you think it's a good idea? I suppose some other users encounter this issue too...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants