Skip to content

Commit

Permalink
Return empty result for no stats
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
  • Loading branch information
fpetkovski committed Jul 12, 2022
1 parent b7d3792 commit 6d6af65
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/api/status/v1.go
Expand Up @@ -17,7 +17,6 @@
package status

import (
"fmt"
"net/http"

"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -95,8 +94,9 @@ func (sapi *StatusAPI) httpServeStats(r *http.Request) (interface{}, []error, *a
return nil, nil, sterr
}

if stats == nil {
return nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: fmt.Errorf("unknown tenant")}
result := make([]TSDBStatus, 0, len(stats))
if len(stats) == 0 {
return result, nil, nil
}

metrics, err := sapi.registry.Gather()
Expand All @@ -119,7 +119,6 @@ func (sapi *StatusAPI) httpServeStats(r *http.Request) (interface{}, []error, *a
}
}

result := make([]TSDBStatus, 0, len(stats))
for _, s := range stats {
var chunkCount int64
if c, ok := tenantChunks[s.Tenant]; ok {
Expand Down

0 comments on commit 6d6af65

Please sign in to comment.