Adding logging/monitoring before reaching limit #285
Unanswered
dmitry-naumovich
asked this question in
Q&A
Replies: 1 comment 2 replies
-
I'm not sure but can you use something like this: But all customers in your configuration use the same rate limit key. If you want to rate limit independently you should consider to add a cache-key. If you want to implement you own metric handler you can provide a bean which implements MetricHandler. It will automatically be picked up. @Component
public class DebugMetricHandler implements MetricHandler {
@Override
public void handle(MetricType type, String name, long tokens, List<MetricTagResult> tags) {
// your code here
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, our application uses bucket4j-spring-boot-starter to implement throttling for some of our API-s which are used by external partners.
Our configuration looks like:
Everything works perfectly and out-of-the-box. But we want to add alerts sent from Grafana based on the reaching 50% of the limit. We also have prometheus configured. So we would like to expose the metrics which show the current load of each API.
Currently the only metrics we get in the prometheus is bucket4j_summary_consumed_total per each tag, but we need not the total but the amount of consumed buckets per second and per minute to understand how much buckets were consumed and how much are left. This would allow us (with knowing the bandwith capacity) to create alerts.
But as far as I understand, there are no other default metrics, so I assume I have to write custom filter and somehow calculate the current load of APIs.
I have found the FilterConfiguration class which holds the collection of rate limit checks which I could re-use in my custom filter to analyze the amount of remaining and consumed buckets but I can't access it:
private List<RateLimitCheck<R>> rateLimitChecks = new ArrayList<>();
Questions which I have:
Any help appreciated, thank you!
Beta Was this translation helpful? Give feedback.
All reactions