@@ -7,8 +7,10 @@ import (
77 "context"
88 "fmt"
99 "net"
10+ "net/http"
1011 "os"
1112 "path"
13+ "strconv"
1214 "strings"
1315 "time"
1416
@@ -322,6 +324,19 @@ func runReceive(
322324 httpserver .WithGracePeriod (time .Duration (* conf .httpGracePeriod )),
323325 httpserver .WithTLSConfig (* conf .httpTLSConfig ),
324326 )
327+ srv .Handle ("/-/downscale" , http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
328+ tenants := dbs .GetTenants ()
329+ n := len (tenants )
330+ w .Header ().Set ("Tenant-Count" , strconv .Itoa (n ))
331+ for _ , tname := range tenants {
332+ w .Header ().Add ("Tenants" , tname )
333+ }
334+ if n > 0 {
335+ w .WriteHeader (http .StatusTooEarly )
336+ } else {
337+ w .WriteHeader (http .StatusOK )
338+ }
339+ }))
325340 g .Add (func () error {
326341 statusProber .Healthy ()
327342 return srv .ListenAndServe ()
@@ -465,7 +480,7 @@ func runReceive(
465480 ctx , cancel := context .WithCancel (context .Background ())
466481 g .Add (func () error {
467482 return runutil .Repeat (conf .topMetricsUpdateInterval , ctx .Done (), func () error {
468- level .Info (logger ).Log ("msg" , "getting top metrics" )
483+ level .Debug (logger ).Log ("msg" , "getting top metrics" )
469484 for _ , ts := range dbs .TenantStats (conf .numTopMetricsPerTenant , labels .MetricName ) {
470485 for _ , ms := range ts .Stats .IndexPostingStats .CardinalityMetricsStats {
471486 if ms .Count >= conf .topMetricsMinimumCardinality {
0 commit comments