Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

influx: rename extra label to match existing series #10545

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions integration/influx_ingestion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestInfluxIngestion(t *testing.T) {
series, expectedVector, expectedMatrix := generateFloatSeries("series_f1", now, prompb.Label{Name: "foo", Value: "bar"})
// Fix up the expectation as Influx values seem to be rounded to millionths
for _, s := range expectedVector {
s.Metric[model.LabelName("__mimir_source__")] = model.LabelValue("influx")
s.Metric[model.LabelName("__proxy_source__")] = model.LabelValue("influx")
s.Value = model.SampleValue(math.Round(float64(s.Value)*1000000) / 1000000.0)
}
// Fix up the expectation as Influx values seem to be rounded to millionths
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestInfluxIngestion(t *testing.T) {

labelNames, err := c.LabelNames(v1.MinTime, v1.MaxTime, nil)
require.NoError(t, err)
require.Equal(t, []string{"__mimir_source__", "__name__", "foo"}, labelNames)
require.Equal(t, []string{"__name", "__proxy_source__", "foo"}, labelNames)

rangeResult, err := c.QueryRange("series_f1", now.Add(-15*time.Minute), now, 15*time.Second)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/influx.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func TimeseriesToInfluxRequest(timeseries []prompb.TimeSeries) string {
name = l.Value
continue
}
if l.Name != "__mimir_source__" {
if l.Name != "__proxy_source__" {
others = append(others, l.Name+"="+l.Value)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/influx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestInfluxHandleSeriesPush(t *testing.T) {
{
TimeSeries: &mimirpb.TimeSeries{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{
Expand Down
4 changes: 3 additions & 1 deletion pkg/distributor/influxpush/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"github.com/grafana/mimir/pkg/util"
)

const internalLabel = "__mimir_source__"
// This has to match existing code in influx2cortex otherwise all customer series would
// change when they move to the influx in Mimir endpoint.
const internalLabel = "__proxy_source__"

// ParseInfluxLineReader parses a Influx Line Protocol request from an io.Reader.
func ParseInfluxLineReader(_ context.Context, r *http.Request, maxSize int) ([]mimirpb.PreallocTimeseries, int, error) {
Expand Down
26 changes: 13 additions & 13 deletions pkg/distributor/influxpush/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 1.5, TimestampMs: 1465839830100}},
Expand All @@ -46,8 +46,8 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 2, TimestampMs: 1465839830100}},
Expand All @@ -61,8 +61,8 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 3.14159, TimestampMs: 1465839830100}},
Expand All @@ -76,24 +76,24 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 2, TimestampMs: 1465839830100}},
},
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f2"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 3, TimestampMs: 1465839830100}},
},
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f3"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 3.14159, TimestampMs: 1465839830100}},
Expand All @@ -107,8 +107,8 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 2, TimestampMs: 1465839830100}},
Expand All @@ -123,8 +123,8 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
{Name: "t2", Value: "v2"},
{Name: "t3", Value: "v3"},
Expand All @@ -140,24 +140,24 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 3, TimestampMs: 1465839830100}},
},
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f2"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 365, TimestampMs: 1465839830100}},
},
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "measurement_f3"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "t1", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 0, TimestampMs: 1465839830100}},
Expand All @@ -171,8 +171,8 @@ func TestParseInfluxLineReader(t *testing.T) {
expectedResult: []mimirpb.TimeSeries{
{
Labels: []mimirpb.LabelAdapter{
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "_measurement_f_1"},
{Name: "__proxy_source__", Value: "influx"},
{Name: "_t1_", Value: "v1"},
},
Samples: []mimirpb.Sample{{Value: 0, TimestampMs: 1465839830100}},
Expand All @@ -187,8 +187,8 @@ func TestParseInfluxLineReader(t *testing.T) {
{
Labels: []mimirpb.LabelAdapter{
{Name: "_1t1", Value: "v1"},
{Name: "__mimir_source__", Value: "influx"},
{Name: "__name__", Value: "_0measurement_f1"},
{Name: "__proxy_source__", Value: "influx"},
},
Samples: []mimirpb.Sample{{Value: 0, TimestampMs: 1465839830100}},
},
Expand Down
Loading