Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caffeine: allow specifying custom metric labels #603

Open
aaabramov opened this issue Nov 17, 2020 · 1 comment
Open

Caffeine: allow specifying custom metric labels #603

aaabramov opened this issue Nov 17, 2020 · 1 comment

Comments

@aaabramov
Copy link

aaabramov commented Nov 17, 2020

Allow library users to specify custom labels for CacheMetricsCollector.
Please upvote this issue if you would like this feature to be merged.


Let's say we are having k8s cluster with 10 different apps. Each of it uses caffeine as a cache. But single prometheus scrapper.

Currently, the only way to distinguish cache metrics provided by this library between apps is to modify somehow cacheName parameter (either we can prefix it with domain, e.g. users_the_cache_name, dashboards_the_cache_name, etc. or with postfix). This makes creating Grafana dashboards pretty difficult as we have to rely on regexes of cache label.

In order to create cache dashboard for users service we have to write something like

sum(rate(caffeine_cache_miss_total{cache~="users_.*"}[5m])) by (cache)

I think would be easier for users to specify their own labels and create Grafana dashboard like this:

Map<String, String> labels = new HashMap<String, String>() {{
    put("app", "users-service");
}};

CacheMetricsCollector coll = new CacheMetricsCollector(labels);
sum(rate(caffeine_cache_miss_total{app="users-service"}[5m])) by (cache)

NOTE:
Implemented in scope of #602 but has some drawbacks (see PR comments).

@zorba128
Copy link

See #901 and #905 - same problem, other solution.

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

No branches or pull requests

2 participants