forked from criteo-forks/jmx_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow caching regular expression matching in rules (prometheus#518)
* Allow caching regular expression matching in rules This improves performance for some use cases. The exporter is configured with a set of rules to match regular expressions against bean names. Regular expressions can be CPU-intensive, and matching the same bean names over the same patterns is time-consuming when there are tens of thousands of bean names (e.g: exposed by Kafka). Using a single `ConcurrentHashMap` to store the result of pattern matching here. The `MatchedRule` class was introduced here to "store" this result. Each rule in the configuration leads to a `MatchedRule` which helps build the set of metrics to expose to Prometheus. The mapping between a bean name + attributes to a `MatchedRule` is done once. Some (in Kafka, most) bean names may not match any rule, so caching of `MatchedRule.unmatched()` helps prevent re-computation of bean names to non-existent rules. The logic to map a bean name to a Prometheus MetricFamilySample is unchanged from the upstream, the `MatchedRule` was introduced only to be able to cache the results. Caching is disabled by default (behaviour unchanged), and can be enabled by setting `cacheRules: true` in the configuration. Signed-off-by: Flavien Raynaud <flavr@yelp.com> * Cache regular expression matching per rule Instead of having a global `cacheRules` flag, have a per-rule `cache` flag (default: false). Rules that do not have the `cache` flag set will have the default behaviour. In order to allow caching of rules with values that change over time (e.g: gauges), a new per-rule `matchBeanValue` flag has also been added (default: true). Disabling the flag will not add the bean value to the expression when matching against the list of rules (slightly different behaviour than before, but toggleable per rule) and allow caching of just the bean name (no matter the value). Signed-off-by: Flavien Raynaud <flavr@yelp.com>
- Loading branch information
1 parent
767d205
commit 4ec9bb8
Showing
5 changed files
with
297 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.