diff --git a/app/vminsert/csvimport/request_handler.go b/app/vminsert/csvimport/request_handler.go index 472bec359..05216f35e 100644 --- a/app/vminsert/csvimport/request_handler.go +++ b/app/vminsert/csvimport/request_handler.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/netstorage" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/relabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/auth" parser "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/csvimport" "github.com/VictoriaMetrics/VictoriaMetrics/lib/tenantmetrics" @@ -30,6 +31,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { defer netstorage.PutInsertCtx(ctx) ctx.Reset() // This line is required for initializing ctx internals. + hasRelabeling := relabel.HasRelabeling() for i := range rows { r := &rows[i] ctx.Labels = ctx.Labels[:0] @@ -38,7 +40,9 @@ func insertRows(at *auth.Token, rows []parser.Row) error { tag := &r.Tags[j] ctx.AddLabel(tag.Key, tag.Value) } - ctx.ApplyRelabeling() + if hasRelabeling { + ctx.ApplyRelabeling() + } if len(ctx.Labels) == 0 { // Skip metric without labels. continue diff --git a/app/vminsert/graphite/request_handler.go b/app/vminsert/graphite/request_handler.go index 8760c2342..3aef526cf 100644 --- a/app/vminsert/graphite/request_handler.go +++ b/app/vminsert/graphite/request_handler.go @@ -4,6 +4,7 @@ import ( "io" "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/netstorage" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/relabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/auth" parser "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/graphite" "github.com/VictoriaMetrics/VictoriaMetrics/lib/tenantmetrics" @@ -34,6 +35,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { ctx.Reset() // This line is required for initializing ctx internals. atCopy := *at + hasRelabeling := relabel.HasRelabeling() for i := range rows { r := &rows[i] ctx.Labels = ctx.Labels[:0] @@ -52,7 +54,9 @@ func insertRows(at *auth.Token, rows []parser.Row) error { } ctx.AddLabel(tag.Key, tag.Value) } - ctx.ApplyRelabeling() + if hasRelabeling { + ctx.ApplyRelabeling() + } if len(ctx.Labels) == 0 { // Skip metric without labels. continue diff --git a/app/vminsert/opentsdb/request_handler.go b/app/vminsert/opentsdb/request_handler.go index 42ae8a538..74eda55bc 100644 --- a/app/vminsert/opentsdb/request_handler.go +++ b/app/vminsert/opentsdb/request_handler.go @@ -4,6 +4,7 @@ import ( "io" "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/netstorage" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/relabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/auth" parser "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentsdb" "github.com/VictoriaMetrics/VictoriaMetrics/lib/tenantmetrics" @@ -34,6 +35,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { ctx.Reset() // This line is required for initializing ctx internals. atCopy := *at + hasRelabeling := relabel.HasRelabeling() for i := range rows { r := &rows[i] ctx.Labels = ctx.Labels[:0] @@ -52,7 +54,9 @@ func insertRows(at *auth.Token, rows []parser.Row) error { } ctx.AddLabel(tag.Key, tag.Value) } - ctx.ApplyRelabeling() + if hasRelabeling { + ctx.ApplyRelabeling() + } if len(ctx.Labels) == 0 { // Skip metric without labels. continue diff --git a/app/vminsert/opentsdbhttp/request_handler.go b/app/vminsert/opentsdbhttp/request_handler.go index 580a89e8f..44812120e 100644 --- a/app/vminsert/opentsdbhttp/request_handler.go +++ b/app/vminsert/opentsdbhttp/request_handler.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/netstorage" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/relabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/auth" "github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver" parser "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentsdbhttp" @@ -51,6 +52,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { defer netstorage.PutInsertCtx(ctx) ctx.Reset() // This line is required for initializing ctx internals. + hasRelabeling := relabel.HasRelabeling() for i := range rows { r := &rows[i] ctx.Labels = ctx.Labels[:0] @@ -59,7 +61,9 @@ func insertRows(at *auth.Token, rows []parser.Row) error { tag := &r.Tags[j] ctx.AddLabel(tag.Key, tag.Value) } - ctx.ApplyRelabeling() + if hasRelabeling { + ctx.ApplyRelabeling() + } if len(ctx.Labels) == 0 { // Skip metric without labels. continue diff --git a/app/vminsert/prometheusimport/request_handler.go b/app/vminsert/prometheusimport/request_handler.go index 95421ba5a..ec62dda7c 100644 --- a/app/vminsert/prometheusimport/request_handler.go +++ b/app/vminsert/prometheusimport/request_handler.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/netstorage" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/relabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/auth" parser "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/prometheus" "github.com/VictoriaMetrics/VictoriaMetrics/lib/tenantmetrics" @@ -31,6 +32,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { defer netstorage.PutInsertCtx(ctx) ctx.Reset() // This line is required for initializing ctx internals. + hasRelabeling := relabel.HasRelabeling() for i := range rows { r := &rows[i] ctx.Labels = ctx.Labels[:0] @@ -39,7 +41,9 @@ func insertRows(at *auth.Token, rows []parser.Row) error { tag := &r.Tags[j] ctx.AddLabel(tag.Key, tag.Value) } - ctx.ApplyRelabeling() + if hasRelabeling { + ctx.ApplyRelabeling() + } if len(ctx.Labels) == 0 { // Skip metric without labels. continue diff --git a/app/vminsert/promremotewrite/request_handler.go b/app/vminsert/promremotewrite/request_handler.go index 435af23ed..318585993 100644 --- a/app/vminsert/promremotewrite/request_handler.go +++ b/app/vminsert/promremotewrite/request_handler.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/netstorage" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/relabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/auth" "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompb" parser "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/promremotewrite" @@ -33,6 +34,7 @@ func insertRows(at *auth.Token, timeseries []prompb.TimeSeries) error { ctx.Reset() // This line is required for initializing ctx internals. rowsTotal := 0 + hasRelabeling := relabel.HasRelabeling() for i := range timeseries { ts := ×eries[i] ctx.Labels = ctx.Labels[:0] @@ -40,7 +42,9 @@ func insertRows(at *auth.Token, timeseries []prompb.TimeSeries) error { for _, srcLabel := range srcLabels { ctx.AddLabelBytes(srcLabel.Name, srcLabel.Value) } - ctx.ApplyRelabeling() + if hasRelabeling { + ctx.ApplyRelabeling() + } if len(ctx.Labels) == 0 { // Skip metric without labels. continue diff --git a/app/vminsert/vmimport/request_handler.go b/app/vminsert/vmimport/request_handler.go index 1489dfe48..d956d5ba8 100644 --- a/app/vminsert/vmimport/request_handler.go +++ b/app/vminsert/vmimport/request_handler.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/netstorage" + "github.com/VictoriaMetrics/VictoriaMetrics/app/vminsert/relabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/auth" parser "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/vmimport" "github.com/VictoriaMetrics/VictoriaMetrics/lib/storage" @@ -34,6 +35,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { ctx.Reset() // This line is required for initializing ctx internals. rowsTotal := 0 + hasRelabeling := relabel.HasRelabeling() for i := range rows { r := &rows[i] ctx.Labels = ctx.Labels[:0] @@ -41,7 +43,9 @@ func insertRows(at *auth.Token, rows []parser.Row) error { tag := &r.Tags[j] ctx.AddLabelBytes(tag.Key, tag.Value) } - ctx.ApplyRelabeling() + if hasRelabeling { + ctx.ApplyRelabeling() + } if len(ctx.Labels) == 0 { // Skip metric without labels. continue