From bf9cb84575e9f9f35d04c7a57d169e53b795cd5e Mon Sep 17 00:00:00 2001 From: Andrii Chubatiuk Date: Fri, 1 Mar 2024 00:23:54 +0200 Subject: [PATCH] opentelemetry: fix firehose message parsing (#5899) Co-authored-by: Andrii Chubatiuk --- .../opentelemetry/firehose/parser.go | 15 +++++++++-- .../opentelemetry/firehose/parser_test.go | 26 +++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/lib/protoparser/opentelemetry/firehose/parser.go b/lib/protoparser/opentelemetry/firehose/parser.go index 7e7fb6200..e6801e3e7 100644 --- a/lib/protoparser/opentelemetry/firehose/parser.go +++ b/lib/protoparser/opentelemetry/firehose/parser.go @@ -1,6 +1,7 @@ package firehose import ( + "encoding/binary" "encoding/json" "fmt" ) @@ -32,8 +33,18 @@ func ProcessRequestBody(b []byte) ([]byte, error) { var dst []byte for _, r := range req.Records { - dst = append(dst, r.Data...) + for len(r.Data) > 0 { + messageLength, varIntLength := binary.Uvarint(r.Data) + if varIntLength > binary.MaxVarintLen32 { + return nil, fmt.Errorf("failed to parse OpenTelemetry message: invalid variant") + } + totalLength := varIntLength + int(messageLength) + if totalLength > len(r.Data) { + return nil, fmt.Errorf("failed to parse OpenTelementry message: insufficient length of buffer") + } + dst = append(dst, r.Data[varIntLength:totalLength]...) + r.Data = r.Data[totalLength:] + } } - return dst, nil } diff --git a/lib/protoparser/opentelemetry/firehose/parser_test.go b/lib/protoparser/opentelemetry/firehose/parser_test.go index fdede8568..b5c588971 100644 --- a/lib/protoparser/opentelemetry/firehose/parser_test.go +++ b/lib/protoparser/opentelemetry/firehose/parser_test.go @@ -1,17 +1,33 @@ package firehose import ( + "bytes" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentelemetry/stream" + "strings" "testing" ) func TestProcessRequestBody(t *testing.T) { - data := []byte(`{"records": [{"data": "SGVsbG8sIA=="}, {"data": "d29ybGQh"}]}`) - result, err := ProcessRequestBody(data) + data := []byte(`{"requestId":"94885867-d282-4110-a3c5-4af3f9ce1150","timestamp":1709217414040,"records":[{"data":"oB0KnR0KuwEKFwoOY2xvdWQucHJvdmlkZXISBQoDYXdzCiIKEGNsb3VkLmFjY291bnQuaWQSDgoMNjc3NDM1ODkwNTk4ChsKDGNsb3VkLnJlZ2lvbhILCgl1cy1lYXN0LTEKXwoQYXdzLmV4cG9ydGVyLmFybhJLCklhcm46YXdzOmNsb3Vkd2F0Y2g6dXMtZWFzdC0xOjY3NzQzNTg5MDU5ODptZXRyaWMtc3RyZWFtL2N1c3RvbV9lYnNfbWV0cmljEtwbErEBCiNhbWF6b25hd3MuY29tL0FXUy9FQlMvVm9sdW1lUmVhZE9wcxoHe0NvdW50fVqAAQp+ChQKCU5hbWVzcGFjZRIHQVdTL0VCUwobCgpNZXRyaWNOYW1lEg1Wb2x1bWVSZWFkT3BzCiEKCFZvbHVtZUlkEhV2b2wtMDg2Y2ZjMTA4NTQwOGUwZGMRABjlKfhbuBcZAHAsIgZcuBchAQAAAAAAAAAyADIJCQAAAAAAAPA/ErEBCiNhbWF6b25hd3MuY29tL0FXUy9FQlMvVm9sdW1lUmVhZE9wcxoHe0NvdW50fVqAAQp+ChQKCU5hbWVzcGFjZRIHQVdTL0VCUwobCgpNZXRyaWNOYW1lEg1Wb2x1bWVSZWFkT3BzCiEKCFZvbHVtZUlkEhV2b2wtMDZkMDc4YWIxYmNjMDBlYzMRABjlKfhbuBcZAHAsIgZcuBchAQAAAAAAAAAyADIJCQAAAAAAAPA/ErEBCiNhbWF6b25hd3MuY29tL0FXUy9FQlMvVm9sdW1lUmVhZE9wcxoHe0NvdW50fVqAAQp+ChQKCU5hbWVzcGFjZRIHQVdTL0VCUwobCgpNZXRyaWNOYW1lEg1Wb2x1bWVSZWFkT3BzCiEKCFZvbHVtZUlkEhV2b2wtMGJkMTU0NjVkNjljMjNhOWERABjlKfhbuBcZAHAsIgZcuBchAQAAAAAAAAAyAD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ChsKCk1ldHJpY05hbWUSDVZvbHVtZVJlYWRPcHMKIQoIVm9sdW1lSWQSFXZvbC0wNmMzNTlhOTc1NzUxMzYzYhEAcCwiBly4FxkAyHMaFFy4FyEBAAAAAAAAADIAMgkJAAAAAAAA8D8="}]}`) + var totalTss []prompbmarshal.TimeSeries + err := stream.ParseStream(bytes.NewReader(data), false, ProcessRequestBody, func(tss []prompbmarshal.TimeSeries) error { + totalTss = append(totalTss, tss...) + for _, ts := range tss { + for _, label := range ts.Labels { + if label.Name == "__name__" { + if !strings.HasPrefix(label.Value, "amazonaws.com/AWS/EBS/VolumeReadOps") { + t.Fatalf("got %q, expected prefix amazonaws.com/AWS/EBS/VolumeReadOps", label.Value) + } + } + } + } + return nil + }) if err != nil { t.Fatalf("unexpected error: %v", err) } - resultExpected := "Hello, world!" - if string(result) != resultExpected { - t.Fatalf("unexpected result; got %q; want %q", result, resultExpected) + if len(totalTss) == 0 { + t.Fatalf("unexpected number of series: %d", len(totalTss)) } }