Question about cardinality with dynamic label values


we’ve got a use case where I think we need a lot of dynamic labels but I am not 100% sure since it is against best practices.

We run a platform where users create specific data. We want to use loki to scrape that data and show it to the users as their history. loki will be part of the app then.

According to best practices I would leave out any labels and filter for the user and then for the kind of events with line filters.

My idea was to add the user id to the labels and leave it at one stream per user id. In the end it would create a couple of thousand streams. The queriers would always only search within a userid and not beyond.

Would you recommend creating a label value per user id or against it?


I think it would be fine. The recommendation for labels isn’t so much about the number of potential values, rather that to make sure the potential values are “bounded”. For example, hostname is fine, instance id is fine, user id I’d say is fine, but using client IP addresses for labels is probably not fine.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.