Skip to content

Commit 75c3c54

Browse files
pracuccipstibrany
andauthored
Ignore time range in /series request for the blocks storage (#2617)
* Ignore time range in /series request for the blocks storage Signed-off-by: Marco Pracucci <[email protected]> * Updated CHANGELOG Signed-off-by: Marco Pracucci <[email protected]> * Update CHANGELOG.md Signed-off-by: Marco Pracucci <[email protected]> Co-authored-by: Peter Štibraný <[email protected]> * Update pkg/ingester/ingester_v2.go Signed-off-by: Marco Pracucci <[email protected]> Co-authored-by: Peter Štibraný <[email protected]> Co-authored-by: Peter Štibraný <[email protected]>
1 parent 0b6b7f3 commit 75c3c54

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* [BUGFIX] QueryFrontend: fixed a situation where HTTP error is ignored and an incorrect status code is set. #2590
3939
* [BUGFIX] Ingester: Fix an ingester starting up in the JOINING state and staying there forever. #2565
4040
* [BUGFIX] QueryFrontend: fixed a panic (`integer divide by zero`) in the query-frontend. The query-frontend now requires the `-querier.default-evaluation-interval` config to be set to the same value of the querier. #2603
41+
* [BUGFIX] Experimental TSDB: when the querier receives a `/series` request with a time range older than the data stored in the ingester, it now ignores the requested time range and returns known series anyway instead of returning an empty response. This aligns the behaviour with the chunks storage. #2617
4142

4243
## 1.1.0 / 2020-05-21
4344

pkg/ingester/ingester_v2.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,16 @@ func (i *Ingester) v2MetricsForLabelMatchers(ctx context.Context, req *client.Me
527527
}
528528

529529
// Parse the request
530-
from, to, matchersSet, err := client.FromMetricsForLabelMatchersRequest(req)
530+
_, _, matchersSet, err := client.FromMetricsForLabelMatchersRequest(req)
531531
if err != nil {
532532
return nil, err
533533
}
534534

535-
// Create a new instance of the TSDB querier
536-
q, err := db.Querier(int64(from), int64(to))
535+
// Since ingester runs with a very limited TSDB retention, we can (and should) query
536+
// metrics without any time range bound, otherwise when we receive a request with a time
537+
// range older then the ingester's data we return an empty response instead of returning
538+
// the currently known series.
539+
q, err := db.Querier(0, math.MaxInt64)
537540
if err != nil {
538541
return nil, err
539542
}

pkg/ingester/ingester_v2_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,16 +883,17 @@ func Test_Ingester_v2MetricsForLabelMatchers(t *testing.T) {
883883
{Labels: client.FromLabelsToLabelAdapters(fixtures[2].lbls)},
884884
},
885885
},
886-
"should filter metrics by time range": {
887-
from: 100000,
888-
to: 100000,
886+
"should NOT filter metrics by time range to always return known metrics even when queried for older time ranges": {
887+
from: 100,
888+
to: 1000,
889889
matchers: []*client.LabelMatchers{{
890890
Matchers: []*client.LabelMatcher{
891891
{Type: client.EQUAL, Name: model.MetricNameLabel, Value: "test_1"},
892892
},
893893
}},
894894
expected: []*client.Metric{
895895
{Labels: client.FromLabelsToLabelAdapters(fixtures[0].lbls)},
896+
{Labels: client.FromLabelsToLabelAdapters(fixtures[1].lbls)},
896897
},
897898
},
898899
"should not return duplicated metrics on overlapping matchers": {

0 commit comments

Comments
 (0)