Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchen-db committed Oct 12, 2024
1 parent 15d725d commit 1ba81c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 1 addition & 7 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"context"
"net/http"
"os"
"path"
"strings"
Expand Down Expand Up @@ -312,6 +311,7 @@ func runReceive(
httpserver.WithGracePeriod(time.Duration(*conf.httpGracePeriod)),
httpserver.WithTLSConfig(*conf.httpTLSConfig),
)
httpserver.RegisterDownscale(srv, dbs.GetTenants())
g.Add(func() error {
statusProber.Healthy()
return srv.ListenAndServe()
Expand All @@ -323,12 +323,6 @@ func runReceive(
})
}

level.Debug(logger).Log("msg", "setting up downscale HTTP server")
{
http.HandleFunc("/downscale", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) })
http.ListenAndServe(":8080", nil)
}

level.Debug(logger).Log("msg", "setting up gRPC server")
{
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), conf.grpcConfig.tlsSrvCert, conf.grpcConfig.tlsSrvKey, conf.grpcConfig.tlsSrvClientCA)
Expand Down
4 changes: 4 additions & 0 deletions pkg/receive/multitsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func (t *MultiTSDB) SkipMatchExternalLabels() {
t.skipMatchExternalLabels = true
}

func (t *MultiTSDB) GetTenants() map[string]*tenant {
return t.tenants
}

type localClient struct {
store *store.TSDBStore
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/server/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package http

import (
"context"
"fmt"
"net/http"
"net/http/pprof"

Expand Down Expand Up @@ -68,6 +69,13 @@ func New(logger log.Logger, reg *prometheus.Registry, comp component.Component,
}
}

func RegisterDownscale[K comparable, V any](s *Server, m map[K]V) {
s.mux.Handle("/-/downscale", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, len(m))
}))
}

// ListenAndServe listens on the TCP network address and handles requests on incoming connections.
func (s *Server) ListenAndServe() error {
level.Info(s.logger).Log("msg", "listening for requests and metrics", "address", s.opts.listen)
Expand Down

0 comments on commit 1ba81c7

Please sign in to comment.