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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions clients/cmd/docker-driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ func relabelConfig(config string, lbs model.LabelSet) (model.LabelSet, error) {
if err := yaml.UnmarshalStrict([]byte(config), &relabelConfig); err != nil {
return nil, err
}
// Validate relabel configs to set the validation scheme properly
for _, rc := range relabelConfig {
if err := rc.Validate(model.UTF8Validation); err != nil {
return nil, err
}
}
relabed, _ := relabel.Process(labels.FromMap(util.ModelLabelSetToMap(lbs)), relabelConfig...)
return model.LabelSet(util.LabelsToMetric(relabed)), nil
}
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/promtail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func getPromMetrics(t *testing.T, httpListenAddr net.Addr) ([]byte, string) {
func parsePromMetrics(t *testing.T, bytes []byte, contentType string, metricName string, label string) map[string]float64 {
rb := map[string]float64{}

pr, err := textparse.New(bytes, contentType, "", false, false, false, nil)
pr, err := textparse.New(bytes, contentType, nil, textparse.ParserOptions{})
require.NoError(t, err)
for {
et, err := pr.Next()
Expand Down
16 changes: 15 additions & 1 deletion clients/pkg/promtail/targets/azureeventhubs/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,21 @@ func (e *messageParser) getLabels(logRecord *azureMonitorResourceLog, relabelCon
var processed labels.Labels
// apply relabeling
if len(relabelConfig) > 0 {
processed, _ = relabel.Process(lbs, relabelConfig...)
// Validate relabel configs to set the validation scheme properly
valid := true
for _, rc := range relabelConfig {
if err := rc.Validate(model.UTF8Validation); err != nil {
// If validation fails, skip relabeling and use original labels
valid = false
break
}
}
// Only process if all configs were validated successfully
if valid {
processed, _ = relabel.Process(lbs, relabelConfig...)
} else {
processed = lbs
}
} else {
processed = lbs
}
Expand Down
16 changes: 15 additions & 1 deletion clients/pkg/promtail/targets/gcplog/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,21 @@ func parseGCPLogsEntry(data []byte, other model.LabelSet, otherInternal labels.L

// apply relabeling
if len(relabelConfig) > 0 {
processed, _ = relabel.Process(lbs.Labels(), relabelConfig...)
// Validate relabel configs to set the validation scheme properly
valid := true
for _, rc := range relabelConfig {
if err := rc.Validate(model.UTF8Validation); err != nil {
// If validation fails, skip relabeling and use original labels
valid = false
break
}
}
// Only process if all configs were validated successfully
if valid {
processed, _ = relabel.Process(lbs.Labels(), relabelConfig...)
} else {
processed = lbs.Labels()
}
} else {
processed = lbs.Labels()
}
Expand Down
21 changes: 20 additions & 1 deletion clients/pkg/promtail/targets/gelf/gelftarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,26 @@ func (t *Target) handleMessage(msg *gelf.Message) {
lb.Set("__gelf_message_version", msg.Version)
lb.Set("__gelf_message_facility", msg.Facility)

processed, _ := relabel.Process(lb.Labels(), t.relabelConfig...)
var processed labels.Labels
if len(t.relabelConfig) > 0 {
// Validate relabel configs to set the validation scheme properly
valid := true
for _, rc := range t.relabelConfig {
if err := rc.Validate(model.UTF8Validation); err != nil {
// If validation fails, skip relabeling and use original labels
valid = false
break
}
}
// Only process if all configs were validated successfully
if valid {
processed, _ = relabel.Process(lb.Labels(), t.relabelConfig...)
} else {
processed = lb.Labels()
}
} else {
processed = lb.Labels()
}

filtered := make(model.LabelSet)
processed.Range(func(lbl labels.Label) {
Expand Down
21 changes: 20 additions & 1 deletion clients/pkg/promtail/targets/heroku/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,26 @@ func (h *Target) drain(w http.ResponseWriter, r *http.Request) {
lb.Set(lokiClient.ReservedLabelTenantID, tenantIDHeaderValue)
}

processed, _ := relabel.Process(lb.Labels(), h.relabelConfigs...)
var processed labels.Labels
if len(h.relabelConfigs) > 0 {
// Validate relabel configs to set the validation scheme properly
valid := true
for _, rc := range h.relabelConfigs {
if err := rc.Validate(model.UTF8Validation); err != nil {
// If validation fails, skip relabeling and use original labels
valid = false
break
}
}
// Only process if all configs were validated successfully
if valid {
processed, _ = relabel.Process(lb.Labels(), h.relabelConfigs...)
} else {
processed = lb.Labels()
}
} else {
processed = lb.Labels()
}

// Start with the set of labels fixed in the configuration
filtered := h.Labels().Clone()
Expand Down
21 changes: 20 additions & 1 deletion clients/pkg/promtail/targets/kafka/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,26 @@ func format(lbs labels.Labels, cfg []*relabel.Config) model.LabelSet {
if lbs.IsEmpty() {
return nil
}
processed, _ := relabel.Process(lbs, cfg...)
var processed labels.Labels
if len(cfg) > 0 {
// Validate relabel configs to set the validation scheme properly
valid := true
for _, rc := range cfg {
if err := rc.Validate(model.UTF8Validation); err != nil {
// If validation fails, skip relabeling and use original labels
valid = false
break
}
}
// Only process if all configs were validated successfully
if valid {
processed, _ = relabel.Process(lbs, cfg...)
} else {
processed = lbs
}
} else {
processed = lbs
}
labelOut := model.LabelSet(util.LabelsToMetric(processed))
for k := range labelOut {
if strings.HasPrefix(string(k), "__") {
Expand Down
42 changes: 40 additions & 2 deletions clients/pkg/promtail/targets/syslog/syslogtarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,26 @@ func (t *SyslogTarget) handleMessageRFC5424(connLabels labels.Labels, msg syslog
}
}

processed, _ := relabel.Process(lb.Labels(), t.relabelConfig...)
var processed labels.Labels
if len(t.relabelConfig) > 0 {
// Validate relabel configs to set the validation scheme properly
valid := true
for _, rc := range t.relabelConfig {
if err := rc.Validate(model.UTF8Validation); err != nil {
// If validation fails, skip relabeling and use original labels
valid = false
break
}
}
// Only process if all configs were validated successfully
if valid {
processed, _ = relabel.Process(lb.Labels(), t.relabelConfig...)
} else {
processed = lb.Labels()
}
} else {
processed = lb.Labels()
}

filtered := make(model.LabelSet)
processed.Range(func(lbl labels.Label) {
Expand Down Expand Up @@ -206,7 +225,26 @@ func (t *SyslogTarget) handleMessageRFC3164(connLabels labels.Labels, msg syslog
lb.Set("__syslog_message_msg_id", *v)
}

processed, _ := relabel.Process(lb.Labels(), t.relabelConfig...)
var processed labels.Labels
if len(t.relabelConfig) > 0 {
// Validate relabel configs to set the validation scheme properly
valid := true
for _, rc := range t.relabelConfig {
if err := rc.Validate(model.UTF8Validation); err != nil {
// If validation fails, skip relabeling and use original labels
valid = false
break
}
}
// Only process if all configs were validated successfully
if valid {
processed, _ = relabel.Process(lb.Labels(), t.relabelConfig...)
} else {
processed = lb.Labels()
}
} else {
processed = lb.Labels()
}

filtered := make(model.LabelSet)
processed.Range(func(lbl labels.Label) {
Expand Down
22 changes: 11 additions & 11 deletions cmd/dataobj-inspect/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/grafana/loki/cmd/index

go 1.25.0
go 1.25.3

replace github.com/grafana/loki/v3 => ../..

Expand All @@ -9,7 +9,7 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.18.0
github.com/grafana/loki/v3 v3.5.8
github.com/prometheus/prometheus v0.305.1-0.20250806170547-208187eaa19b
github.com/prometheus/prometheus v0.307.3
)

require (
Expand All @@ -30,34 +30,34 @@ require (
github.com/golang/snappy v1.0.0 // indirect
github.com/google/flatbuffers v25.2.10+incompatible // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect
github.com/kamstrup/intmap v0.5.1 // indirect
github.com/klauspost/compress v1.18.1 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.23.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.1-0.20250703115700-7f8b2a0d32d3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/thanos-io/objstore v0.0.0-20250115091151-a54d0f04b42a // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/exp v0.0.0-20250711185948-6ae5c78190dc // indirect
golang.org/x/mod v0.28.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/exp v0.0.0-20250808145144-a408d31f581a // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053 // indirect
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect
golang.org/x/text v0.30.0 // indirect
golang.org/x/tools v0.37.0 // indirect
golang.org/x/tools v0.38.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading
Loading