thanos icon indicating copy to clipboard operation
thanos copied to clipboard

Receive: Allow specifying tenant-specific external labels

Open fpetkovski opened this issue 2 years ago • 6 comments

Is your proposal related to a problem?

We would like to partition and select tenant blocks from Receivers in an arbitrary manner.

Describe the solution you'd like

I would like to be able to add additional external labels to tenants created in Thanos Receivers. Currently it is only possible to add external labels to Receivers directly, but not to individual tenants created in those Receivers. Having a header like THANOS-TENANT-LABELS that will set external labels when the tenant TSDB is created could be a possible solution.

Describe alternatives you've considered

Running tenant-specific Prometheus instances, but that can be hard to manage at a larger scale.

fpetkovski avatar Jun 22 '22 15:06 fpetkovski

I think this make a lot of sense. It's also something that could integrate pretty naturally into the tenant configuration file. If this were the path, we might want to change to yaml for the configuration so we can more naturally mirror a prometheus relabel-config.

squat avatar Jun 22 '22 15:06 squat

I think the tenant configuration file would also be a great place to add this 👍

fpetkovski avatar Jun 22 '22 16:06 fpetkovski

Hello, I'm interested in contributing to this project as a part of lfx mentorship program. Any related PR or docs I can check out to get started?

hamees-sayed avatar Aug 15 '22 17:08 hamees-sayed

Hey folks, came here from the LFX mentorship projects and I'd like to contribute to this. Any help on where to get started?

ahsenkamal avatar Aug 24 '22 09:08 ahsenkamal

I was going through the code base and wanted to understand more on how multi-tenancy is currently achieved in Thanos as it wasn't very much clear with the docs as well.It would be great if I may get some relevant blogs/papers as related to what currently is implemented. Thanks in advance.

rajivharlalka avatar Aug 26 '22 13:08 rajivharlalka

Hey folks, came here from the LFX mentorship projects and I'd like to contribute to this. Any help on where to get started?

@ahsenkamal @rajivharlalka I think you can start from adding external labels to hashring config here. Currently, its only supports tenant name as external label value for tenant-label-name command line flag.

once you have some kinda map to hold tenant name to external label-value mapping in hash-ring config, you need to wire them to here https://github.com/thanos-io/thanos/blob/main/pkg/receive/multitsdb.go#L443

lset := labelpb.ExtendSortedLabels(t.labels, labels.FromStrings(t.tenantLabelName, tenantID))

sharadgaur avatar Sep 15 '22 15:09 sharadgaur

@saswatamcode @fpetkovski PR #5777 only does the main parts of the proposal #5720 Should we create an issue to track doing the remaining parts, before moving the proposal to proposals-done? Some users may want to contribute.

haanhvu avatar May 25 '23 12:05 haanhvu