Skip to content

Commit

Permalink
Wire tenant's external labels from hashring to multiTSDB
Browse files Browse the repository at this point in the history
Signed-off-by: haanhvu <[email protected]>
  • Loading branch information
haanhvu committed Oct 26, 2022
1 parent 5f2cb67 commit 6e5e45a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/receive/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type HashringConfig struct {
Hashring string `json:"hashring,omitempty"`
Tenants []string `json:"tenants,omitempty"`
Endpoints []string `json:"endpoints"`
ExternalLabels []string `json:"external-labels"`
ExternalLabels []string `json:"external_labels"`
}

// ConfigWatcher is able to watch a file containing a hashring configuration
Expand Down
9 changes: 6 additions & 3 deletions pkg/receive/multitsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/thanos-io/thanos/pkg/store"
"github.com/thanos-io/thanos/pkg/store/labelpb"
"github.com/thanos-io/thanos/pkg/store/storepb"
"github.com/thanos-io/thanos/cmd/thanos"
)

type TSDBStats interface {
Expand Down Expand Up @@ -138,7 +139,7 @@ type tenant struct {
storeTSDB *store.TSDBStore
exemplarsTSDB *exemplars.TSDB
ship *shipper.Shipper
externalLabels labels.Labels
externalLabels HashringConfig.ExternalLabels

mtx *sync.RWMutex
}
Expand Down Expand Up @@ -181,12 +182,13 @@ func (t *tenant) shipper() *shipper.Shipper {
return t.ship
}

func (t *tenant) set(storeTSDB *store.TSDBStore, tenantTSDB *tsdb.DB, ship *shipper.Shipper, exemplarsTSDB *exemplars.TSDB) {
func (t *tenant) set(storeTSDB *store.TSDBStore, tenantTSDB *tsdb.DB, ship *shipper.Shipper, exemplarsTSDB *exemplars.TSDB, externalLabels HashringConfig.ExternalLabels) {
t.readyS.Set(tenantTSDB)
t.mtx.Lock()
t.storeTSDB = storeTSDB
t.ship = ship
t.exemplarsTSDB = exemplarsTSDB
t.externalLabels = HashringConfig.ExternalLabels
t.mtx.Unlock()
}

Expand Down Expand Up @@ -494,8 +496,9 @@ func (t *MultiTSDB) startTSDB(logger log.Logger, tenantID string, tenant *tenant
reg = NewUnRegisterer(reg)

lset := labelpb.ExtendSortedLabels(t.labels, labels.FromStrings(t.tenantLabelName, tenantID))
tenantExternalLabels := thanos.parseFlagLabels(tenant.externalLabels)
for _, tenantInstance := range t.tenants {
lset = labelpb.ExtendSortedLabels(t.labels, tenantInstance.externalLabels)
lset = labelpb.ExtendSortedLabels(t.labels, tenantExternalLabels)
}
dataDir := t.defaultTenantDataDir(tenantID)

Expand Down

0 comments on commit 6e5e45a

Please sign in to comment.