diff --git a/README.md b/README.md index 255e7de..0ed431a 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ timeout: 10s timeout_shutdown: 10s # Max number of parallel incoming HTTP requests to handle concurrency: 10 +# Whether to forward metrics metadata from Prometheus to Cortex +# Since metadata requests have no timeseries in them - we cannot divide them into tenants +# So the metadata requests will be sent to the default tenant only, if one is not defined - they will be dropped +metadata: false tenant: # Which label to look for the tenant information diff --git a/VERSION b/VERSION index bc80560..dc1e644 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.0 +1.6.0 diff --git a/config.go b/config.go index 565579e..37b2b58 100644 --- a/config.go +++ b/config.go @@ -19,6 +19,7 @@ type config struct { Timeout time.Duration TimeoutShutdown time.Duration `yaml:"timeout_shutdown"` Concurrency int + Metadata bool Tenant struct { Label string diff --git a/config.yml b/config.yml index f7f755a..895ecf0 100644 --- a/config.yml +++ b/config.yml @@ -6,6 +6,7 @@ log_level: debug timeout: 10s timeout_shutdown: 0s concurrency: 10 +metadata: false tenant: label: tenant diff --git a/processor.go b/processor.go index 1e0c431..4a754c1 100644 --- a/processor.go +++ b/processor.go @@ -113,9 +113,24 @@ func (p *processor) handle(ctx *fh.RequestCtx) { return } + clientIP := ctx.RemoteAddr() + reqID, _ := uuid.NewRandom() + if len(wrReqIn.Timeseries) == 0 { // If there's metadata - just accept the request and drop it if len(wrReqIn.Metadata) > 0 { + if p.cfg.Metadata && p.cfg.Tenant.Default != "" { + code, body, err := p.send(clientIP, reqID, p.cfg.Tenant.Default, wrReqIn) + if err != nil { + ctx.Error(err.Error(), fh.StatusInternalServerError) + p.Errorf("src=%s req_id=%s: unable to proxy metadata: %s", clientIP, reqID, err) + return + } + + ctx.SetStatusCode(code) + ctx.SetBody(body) + } + return } @@ -123,9 +138,6 @@ func (p *processor) handle(ctx *fh.RequestCtx) { return } - clientIP := ctx.RemoteAddr() - reqID, _ := uuid.NewRandom() - m, err := p.createWriteRequests(wrReqIn) if err != nil { ctx.Error(err.Error(), fh.StatusBadRequest)