Skip to content

Commit

Permalink
Cut 0.10.1 (#2035)
Browse files Browse the repository at this point in the history
* Fix invalid start/end params in series api (#2015)

* fix invalid start/end params in series api

Signed-off-by: yeya24 <[email protected]>

* add testcase for serieslabels time range

Signed-off-by: yeya24 <[email protected]>

* Revert "Fix revert metric name regression (#2005)"

This reverts commit 7d16852.

* Cut release 0.10.1

Signed-off-by: Bartlomiej Plotka <[email protected]>

Co-authored-by: Ben Ye <[email protected]>
  • Loading branch information
bwplotka and yeya24 authored Jan 24, 2020
1 parent 7d16852 commit bdcc358
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan

We use *breaking* word for marking changes that are not backward compatible (relates only to v0.y.z releases.)

## [v0.10.1](https://github.com/thanos-io/thanos/releases/tag/v0.10.1) - 2020.01.23

### Fixed

- [#2015](https://github.com/thanos-io/thanos/pull/2015) Sidecar: Querier /api/v1/series bug fixed when time range was ignored inside sidecar.
The bug was noticeable for example when using Grafana template variables.

## [v0.10.0](https://github.com/thanos-io/thanos/releases/tag/v0.10.0) - 2020.01.13

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.0
0.10.1
4 changes: 2 additions & 2 deletions examples/alerts/alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ rules:
message: Thanos Querys {{$labels.job}} have {{ $value }} of failing DNS queries.
expr: |
(
sum by (job) (rate(thanos_querier_store_apis_dns_failures_total{job=~"thanos-querier.*"}[5m]))
sum by (job) (rate(thanos_query_store_apis_dns_failures_total{job=~"thanos-querier.*"}[5m]))
/
sum by (job) (rate(thanos_querier_store_apis_dns_lookups_total{job=~"thanos-querier.*"}[5m]))
sum by (job) (rate(thanos_query_store_apis_dns_lookups_total{job=~"thanos-querier.*"}[5m]))
> 1
)
for: 15m
Expand Down
4 changes: 2 additions & 2 deletions examples/alerts/alerts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ groups:
message: Thanos Querys {{$labels.job}} have {{ $value }} of failing DNS queries.
expr: |
(
sum by (job) (rate(thanos_querier_store_apis_dns_failures_total{job=~"thanos-querier.*"}[5m]))
sum by (job) (rate(thanos_query_store_apis_dns_failures_total{job=~"thanos-querier.*"}[5m]))
/
sum by (job) (rate(thanos_querier_store_apis_dns_lookups_total{job=~"thanos-querier.*"}[5m]))
sum by (job) (rate(thanos_query_store_apis_dns_lookups_total{job=~"thanos-querier.*"}[5m]))
> 1
)
for: 15m
Expand Down
4 changes: 2 additions & 2 deletions mixin/thanos/alerts/querier.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
},
expr: |||
(
sum by (job) (rate(thanos_querier_store_apis_dns_failures_total{%(selector)s}[5m]))
sum by (job) (rate(thanos_query_store_apis_dns_failures_total{%(selector)s}[5m]))
/
sum by (job) (rate(thanos_querier_store_apis_dns_lookups_total{%(selector)s}[5m]))
sum by (job) (rate(thanos_query_store_apis_dns_lookups_total{%(selector)s}[5m]))
> 1
)
||| % thanos.querier,
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/timeduration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (tdv *TimeOrDurationValue) Set(s string) error {
return nil
}

// String returns either tume or duration.
// String returns either time or duration.
func (tdv *TimeOrDurationValue) String() string {
switch {
case tdv.Time != nil:
Expand Down
11 changes: 9 additions & 2 deletions pkg/store/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import (
"net/url"
"path"
"sort"
"strconv"
"strings"
"sync"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
Expand All @@ -23,6 +25,7 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/common/version"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/storage/remote"
"github.com/prometheus/prometheus/tsdb/chunkenc"
Expand Down Expand Up @@ -662,9 +665,9 @@ func (p *PrometheusStore) seriesLabels(ctx context.Context, matchers []storepb.L
}

q.Add("match[]", metric)
q.Add("start", formatTime(timestamp.Time(startTime)))
q.Add("end", formatTime(timestamp.Time(endTime)))
u.RawQuery = q.Encode()
q.Add("start", string(startTime))
q.Add("end", string(endTime))

req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
Expand Down Expand Up @@ -714,3 +717,7 @@ func (p *PrometheusStore) seriesLabels(ctx context.Context, matchers []storepb.L

return m.Data, nil
}

func formatTime(t time.Time) string {
return strconv.FormatFloat(float64(t.Unix())+float64(t.Nanosecond())/1e9, 'f', -1, 64)
}
38 changes: 31 additions & 7 deletions pkg/store/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) {
testutil.Ok(t, err)
_, err = a.Add(labels.FromStrings("a", "d", "job", "test"), baseT+300, 3)
testutil.Ok(t, err)
_, err = a.Add(labels.FromStrings("job", "test"), baseT+400, 4)
testutil.Ok(t, err)
testutil.Ok(t, a.Commit())

ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -208,14 +210,13 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) {
u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr()))
testutil.Ok(t, err)

limitMinT := int64(0)
proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar,
promStore, err := NewPrometheusStore(nil, nil, u, component.Sidecar,
func() labels.Labels { return labels.FromStrings("region", "eu-west") },
func() (int64, int64) { return limitMinT, -1 }) // Maxt does not matter.
func() (int64, int64) { return math.MinInt64/1000 + 62135596801, math.MaxInt64/1000 - 62135596801 })
testutil.Ok(t, err)

{
res, err := proxy.seriesLabels(ctx, []storepb.LabelMatcher{
res, err := promStore.seriesLabels(ctx, []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "a", Value: "b"},
}, baseT, baseT+300)
testutil.Ok(t, err)
Expand All @@ -224,15 +225,15 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) {
testutil.Equals(t, labels.FromMap(res[0]), labels.Labels{{Name: "a", Value: "b"}})
}
{
res, err := proxy.seriesLabels(ctx, []storepb.LabelMatcher{
res, err := promStore.seriesLabels(ctx, []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "job", Value: "foo"},
}, baseT, baseT+300)
testutil.Ok(t, err)

testutil.Equals(t, len(res), 0)
}
{
res, err := proxy.seriesLabels(ctx, []storepb.LabelMatcher{
res, err := promStore.seriesLabels(ctx, []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_NEQ, Name: "a", Value: "b"},
{Type: storepb.LabelMatcher_EQ, Name: "job", Value: "test"},
}, baseT, baseT+300)
Expand All @@ -246,7 +247,7 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) {
}
}
{
res, err := proxy.seriesLabels(ctx, []storepb.LabelMatcher{
res, err := promStore.seriesLabels(ctx, []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "job", Value: "test"},
}, baseT, baseT+300)
testutil.Ok(t, err)
Expand All @@ -258,6 +259,29 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) {
testutil.Equals(t, labels.FromMap(r).Get("job"), "test")
}
}
{
res, err := promStore.seriesLabels(ctx, []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "job", Value: "test"},
}, baseT+400, baseT+400)
testutil.Ok(t, err)

// In baseT + 400 we can just get one series.
testutil.Equals(t, len(res), 1)
testutil.Equals(t, len(res[0]), 1)
testutil.Equals(t, labels.FromMap(res[0]).Get("job"), "test")
}
// This test case is to test when start time and end time is not specified.
{
minTime, maxTime := promStore.timestamps()
res, err := promStore.seriesLabels(ctx, []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "job", Value: "test"},
}, minTime, maxTime)
testutil.Ok(t, err)
testutil.Equals(t, len(res), 3)
for _, r := range res {
testutil.Equals(t, labels.FromMap(r).Get("job"), "test")
}
}
}

func TestPrometheusStore_LabelValues_e2e(t *testing.T) {
Expand Down

0 comments on commit bdcc358

Please sign in to comment.