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

Expose cardinality of labels as metrics #15505

Open
Amoolaa opened this issue Dec 20, 2024 · 2 comments
Open

Expose cardinality of labels as metrics #15505

Amoolaa opened this issue Dec 20, 2024 · 2 comments
Labels
type/feature Something new we should do

Comments

@Amoolaa
Copy link

Amoolaa commented Dec 20, 2024

Is your feature request related to a problem? Please describe.
In our multi-tenanted setup, we frequently have teams using high cardinality loki labels and not following labelling best practices.

Describe the solution you'd like
While this output is exposed in logcli via something like logcli series '{}' --since=1h --analyze-labels, my proposal is to expose this data under a metrics endpoint.

It allows:

  • Users to quickly view this data in a dashboard and adjust their labelling practices
  • A historic view on cardinality counts
  • Alerting on high cardinality counts, for either us (the platform team) or the users

I think giving some sort of out-of-the-box functionality (vs getting users to logcli their way to view this data) will be beneficial to users and platforms teams for monitoring usage.

Describe alternatives you've considered
Writing our own service that calls the logcli endpoint, parses the output and exposes as metrics. This isn't hard to do, but if there's an opportunity to contribute to the upstream project for others, why not?

Even just giving an option to expose the output of the --analyze-labels as json would be better, for parsing reasons

@mveitas
Copy link
Contributor

mveitas commented Dec 20, 2024

100% agree with this and in support of exposing this information

@JStickler JStickler added the type/feature Something new we should do label Jan 6, 2025
@Amoolaa
Copy link
Author

Amoolaa commented Jan 10, 2025

Just to give some more thought on what I'm looking to do - create counter loki_stream_label_value_count with label_name as label and the number of unique values as the value. Haven't really looked at where it would make sense to do it here but if I was running as a standalone service I'd probably just query intervals of 5 mins and aggregate there. My only concern is that this could be contributing to the cardinality issue if there many label names - why it might make more sense to just expose an endpoint, like Mimir does and use some JSON-parsing datasource to visualise this data in Grafana.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature Something new we should do
Projects
None yet
Development

No branches or pull requests

3 participants