Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG TARGETARCH=amd64
ARG TARGETVARIANT=v1

# renovate: datasource=github-releases depName=grpc-ecosystem/grpc-health-probe
ARG GRPC_HEALTH_PROBE_VERSION=v0.4.47
ARG GRPC_HEALTH_PROBE_VERSION=v0.4.57
# Downloading grpc_health_probe from github releases with retry as we have seen it fail a lot on ci.
RUN for i in $(seq 1 50); do \
wget -qO/bin/grpc_health_probe "https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-${TARGETOS}-${TARGETARCH}" && \
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ func (c *ScrapeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if rlcfg == nil {
return errors.New("empty or null target relabeling rule in scrape config")
}
if err := rlcfg.Validate(model.UTF8Validation); err != nil {
return err
}
}

// Validate the scrape and timeout internal configuration. When /debug/pprof/profile scraping
Expand Down
30 changes: 30 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/relabel"
"github.com/stretchr/testify/require"
"github.com/thanos-io/objstore/client"
)
Expand All @@ -35,6 +37,34 @@ func TestLoad(t *testing.T) {
}
}

// TestLoadRelabelConfigNameValidationScheme is a regression test for a panic
// ("Invalid name validation scheme requested: unset") that occurred because
// parsed relabel configs never had their NameValidationScheme populated,
// leaving it at the zero value (model.UnsetValidation).
func TestLoadRelabelConfigNameValidationScheme(t *testing.T) {
t.Parallel()

cfg, err := Load(`scrape_configs:
- job_name: 'test'
static_configs:
- targets: ['localhost:8080']
relabel_configs:
- source_labels: ['__meta_foo']
regex: '(.+)'
target_label: '__meta_${1}'
replacement: 'bar'
action: replace`)
require.NoError(t, err)
require.Len(t, cfg.ScrapeConfigs, 1)
require.Len(t, cfg.ScrapeConfigs[0].RelabelConfigs, 1)
require.Equal(t, model.UTF8Validation, cfg.ScrapeConfigs[0].RelabelConfigs[0].NameValidationScheme)

lb := labels.NewBuilder(labels.FromStrings("__meta_foo", "extra"))
require.NotPanics(t, func() {
relabel.ProcessBuilder(lb, cfg.ScrapeConfigs[0].RelabelConfigs...)
})
}

func TestLoadComplex(t *testing.T) {
t.Parallel()

Expand Down
Loading