diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 472bc38063..663ae67429 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -579,9 +579,12 @@ func LabelValuesHandler(startTime time.Time, at *auth.Token, labelName string, w var labelValues []string var isPartial bool if len(r.Form["match[]"]) == 0 { - var err error if len(r.Form["start"]) == 0 && len(r.Form["end"]) == 0 { + var err error labelValues, isPartial, err = netstorage.GetLabelValues(at, labelName, deadline) + if err != nil { + return fmt.Errorf(`cannot obtain label values for %q: %w`, labelName, err) + } } else { ct := startTime.UnixNano() / 1e6 end, err := searchutils.GetTime(r, "end", ct) @@ -597,9 +600,9 @@ func LabelValuesHandler(startTime time.Time, at *auth.Token, labelName string, w MaxTimestamp: end, } labelValues, isPartial, err = netstorage.GetLabelValuesOnTimeRange(at, labelName, tr, deadline) - } - if err != nil { - return fmt.Errorf(`cannot obtain label values for %q: %w`, labelName, err) + if err != nil { + return fmt.Errorf(`cannot obtain label values on time range for %q: %w`, labelName, err) + } } } else { // Extended functionality that allows filtering by label filters and time range @@ -789,9 +792,12 @@ func LabelsHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r var labels []string var isPartial bool if len(r.Form["match[]"]) == 0 { - var err error if len(r.Form["start"]) == 0 && len(r.Form["end"]) == 0 { + var err error labels, isPartial, err = netstorage.GetLabels(at, deadline) + if err != nil { + return fmt.Errorf("cannot obtain labels: %w", err) + } } else { ct := startTime.UnixNano() / 1e6 end, err := searchutils.GetTime(r, "end", ct) @@ -807,9 +813,9 @@ func LabelsHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r MaxTimestamp: end, } labels, isPartial, err = netstorage.GetLabelsOnTimeRange(at, tr, deadline) - } - if err != nil { - return fmt.Errorf("cannot obtain labels: %w", err) + if err != nil { + return fmt.Errorf("cannot obtain labels on time range: %w", err) + } } } else { // Extended functionality that allows filtering by label filters and time range diff --git a/lib/storage/merge.go b/lib/storage/merge.go index 433b2fc4e6..073361064e 100644 --- a/lib/storage/merge.go +++ b/lib/storage/merge.go @@ -182,7 +182,7 @@ func skipSamplesOutsideRetention(b *Block, retentionDeadline int64, rowsDeleted for nextIdx < len(timestamps) && timestamps[nextIdx] < retentionDeadline { nextIdx++ } - atomic.AddUint64(rowsDeleted, uint64(nextIdx - b.nextIdx)) + atomic.AddUint64(rowsDeleted, uint64(nextIdx-b.nextIdx)) b.nextIdx = nextIdx }