mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmselect: properly handle errors in GetLabelsOnTimeRange and GetLabelValuesOnTimeRange
This commit is contained in:
parent
f2bff64933
commit
72011bcc45
@ -579,9 +579,12 @@ func LabelValuesHandler(startTime time.Time, at *auth.Token, labelName string, w
|
|||||||
var labelValues []string
|
var labelValues []string
|
||||||
var isPartial bool
|
var isPartial bool
|
||||||
if len(r.Form["match[]"]) == 0 {
|
if len(r.Form["match[]"]) == 0 {
|
||||||
var err error
|
|
||||||
if len(r.Form["start"]) == 0 && len(r.Form["end"]) == 0 {
|
if len(r.Form["start"]) == 0 && len(r.Form["end"]) == 0 {
|
||||||
|
var err error
|
||||||
labelValues, isPartial, err = netstorage.GetLabelValues(at, labelName, deadline)
|
labelValues, isPartial, err = netstorage.GetLabelValues(at, labelName, deadline)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf(`cannot obtain label values for %q: %w`, labelName, err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ct := startTime.UnixNano() / 1e6
|
ct := startTime.UnixNano() / 1e6
|
||||||
end, err := searchutils.GetTime(r, "end", ct)
|
end, err := searchutils.GetTime(r, "end", ct)
|
||||||
@ -597,9 +600,9 @@ func LabelValuesHandler(startTime time.Time, at *auth.Token, labelName string, w
|
|||||||
MaxTimestamp: end,
|
MaxTimestamp: end,
|
||||||
}
|
}
|
||||||
labelValues, isPartial, err = netstorage.GetLabelValuesOnTimeRange(at, labelName, tr, deadline)
|
labelValues, isPartial, err = netstorage.GetLabelValuesOnTimeRange(at, labelName, tr, deadline)
|
||||||
}
|
if err != nil {
|
||||||
if err != nil {
|
return fmt.Errorf(`cannot obtain label values on time range for %q: %w`, labelName, err)
|
||||||
return fmt.Errorf(`cannot obtain label values for %q: %w`, labelName, err)
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Extended functionality that allows filtering by label filters and time range
|
// 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 labels []string
|
||||||
var isPartial bool
|
var isPartial bool
|
||||||
if len(r.Form["match[]"]) == 0 {
|
if len(r.Form["match[]"]) == 0 {
|
||||||
var err error
|
|
||||||
if len(r.Form["start"]) == 0 && len(r.Form["end"]) == 0 {
|
if len(r.Form["start"]) == 0 && len(r.Form["end"]) == 0 {
|
||||||
|
var err error
|
||||||
labels, isPartial, err = netstorage.GetLabels(at, deadline)
|
labels, isPartial, err = netstorage.GetLabels(at, deadline)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot obtain labels: %w", err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ct := startTime.UnixNano() / 1e6
|
ct := startTime.UnixNano() / 1e6
|
||||||
end, err := searchutils.GetTime(r, "end", ct)
|
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,
|
MaxTimestamp: end,
|
||||||
}
|
}
|
||||||
labels, isPartial, err = netstorage.GetLabelsOnTimeRange(at, tr, deadline)
|
labels, isPartial, err = netstorage.GetLabelsOnTimeRange(at, tr, deadline)
|
||||||
}
|
if err != nil {
|
||||||
if err != nil {
|
return fmt.Errorf("cannot obtain labels on time range: %w", err)
|
||||||
return fmt.Errorf("cannot obtain labels: %w", err)
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Extended functionality that allows filtering by label filters and time range
|
// Extended functionality that allows filtering by label filters and time range
|
||||||
|
@ -182,7 +182,7 @@ func skipSamplesOutsideRetention(b *Block, retentionDeadline int64, rowsDeleted
|
|||||||
for nextIdx < len(timestamps) && timestamps[nextIdx] < retentionDeadline {
|
for nextIdx < len(timestamps) && timestamps[nextIdx] < retentionDeadline {
|
||||||
nextIdx++
|
nextIdx++
|
||||||
}
|
}
|
||||||
atomic.AddUint64(rowsDeleted, uint64(nextIdx - b.nextIdx))
|
atomic.AddUint64(rowsDeleted, uint64(nextIdx-b.nextIdx))
|
||||||
b.nextIdx = nextIdx
|
b.nextIdx = nextIdx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user