Skip to content

Commit 662332a

Browse files
committed
return tenants in http header
1 parent 5bee491 commit 662332a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

cmd/thanos/receive.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"context"
88
"fmt"
99
"net"
10-
"net/http"
10+
"net/http"
1111
"os"
1212
"path"
1313
"strconv"
@@ -325,8 +325,12 @@ func runReceive(
325325
httpserver.WithTLSConfig(*conf.httpTLSConfig),
326326
)
327327
srv.Handle("/-/downscale", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
328-
n := dbs.GetTenantsLen()
328+
tenants := dbs.GetTenants()
329+
n := len(tenants)
329330
w.Header().Set("Tenant-Count", strconv.Itoa(n))
331+
for _, tname := range tenants {
332+
w.Header().Add("Tenants", tname)
333+
}
330334
if n > 0 {
331335
w.WriteHeader(http.StatusTooEarly)
332336
} else {

pkg/receive/multitsdb.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,14 @@ func NewMultiTSDB(
122122
return mt
123123
}
124124

125-
func (t *MultiTSDB) GetTenantsLen() int {
125+
func (t *MultiTSDB) GetTenants() []string {
126126
t.mtx.RLock()
127+
tenants := make([]string, 0, len(t.tenants))
128+
for tname := range t.tenants {
129+
tenants = append(tenants, tname)
130+
}
127131
defer t.mtx.RUnlock()
128-
return len(t.tenants)
132+
return tenants
129133
}
130134

131135
type localClient struct {

0 commit comments

Comments
 (0)