Skip to content

Commit

Permalink
Sidecar: Fix process external label on promethues v2.28+ use units.By…
Browse files Browse the repository at this point in the history
…tes config type (thanos-io#4657)

* Sidecar: Fix process external label when promethues v2.28+ use units.Bytes config type (thanos-io#4656)

Signed-off-by: hanjm <hanjinming@outlook.com>

* E2E: Upgrade prometheus image version

Signed-off-by: hanjm <hanjinming@outlook.com>
  • Loading branch information
hanjm authored and someshkoli committed Nov 7, 2021
1 parent dc13a2b commit 1cae783
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pkg/promclient/promclient.go
Expand Up @@ -178,7 +178,9 @@ func (c *Client) ExternalLabels(ctx context.Context, base *url.URL) (labels.Labe
if err := json.Unmarshal(body, &d); err != nil {
return nil, errors.Wrapf(err, "unmarshal response: %v", string(body))
}
var cfg config.Config
var cfg struct {
GlobalConfig config.GlobalConfig `yaml:"global"`
}
if err := yaml.Unmarshal([]byte(d.Data.YAML), &cfg); err != nil {
return nil, errors.Wrapf(err, "parse Prometheus config: %v", d.Data.YAML)
}
Expand Down
16 changes: 10 additions & 6 deletions pkg/promclient/promclient_e2e_test.go
Expand Up @@ -15,12 +15,14 @@ import (

"github.com/oklog/ulid"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/timestamp"
"github.com/thanos-io/thanos/pkg/block/metadata"
"github.com/thanos-io/thanos/pkg/runutil"
"github.com/thanos-io/thanos/pkg/testutil"
"github.com/thanos-io/thanos/pkg/testutil/e2eutil"
"gopkg.in/yaml.v3"
)

func TestIsWALFileAccessible_e2e(t *testing.T) {
Expand All @@ -38,12 +40,14 @@ func TestIsWALFileAccessible_e2e(t *testing.T) {

func TestExternalLabels_e2e(t *testing.T) {
e2eutil.ForeachPrometheus(t, func(t testing.TB, p *e2eutil.Prometheus) {
p.SetConfig(`
global:
external_labels:
region: eu-west
az: 1
`)
// Keep consistent with the config processing in function (*Client).ExternalLabels.
cfg := config.Config{GlobalConfig: config.GlobalConfig{ExternalLabels: []labels.Label{
{Name: "region", Value: "eu-west"},
{Name: "az", Value: "1"},
}}}
cfgData, err := yaml.Marshal(cfg)
testutil.Ok(t, err)
p.SetConfig(string(cfgData))

testutil.Ok(t, p.Start())

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2ethanos/services.go
Expand Up @@ -43,7 +43,7 @@ const (

// TODO(bwplotka): Run against multiple?
func DefaultPrometheusImage() string {
return "quay.io/prometheus/prometheus:v2.26.0"
return "quay.io/prometheus/prometheus:v2.29.2"
}

func DefaultAlertmanagerImage() string {
Expand Down

0 comments on commit 1cae783

Please sign in to comment.