Skip to content

fix: Keep the service_name label after discovery in push.ParseLokiRequest before calculating retention and passing to the usage tracker #14960

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

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pkg/loghttp/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,6 @@ func ParseLokiRequest(userID string, r *http.Request, tenantsRetention TenantsRe
lb := labels.NewBuilder(lbs)
lbs = lb.Set(LabelServiceName, serviceName).Labels()
s.Labels = lbs.String()

// Remove the added label after it's added to the stream so it's not consumed by subsequent steps
lbs = lb.Del(LabelServiceName).Labels()
}

if logPushRequestStreams {
Expand Down
4 changes: 2 additions & 2 deletions pkg/loghttp/push/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestParseRequest(t *testing.T) {
enableServiceDiscovery: true,
expectedBytes: len("fizzbuzz"),
expectedLines: 1,
expectedBytesUsageTracker: map[string]float64{`{foo="bar2", job="stuff"}`: float64(len("fizzbuss"))},
expectedBytesUsageTracker: map[string]float64{`{foo="bar2", job="stuff", service_name="stuff"}`: float64(len("fizzbuss"))},
expectedLabels: labels.FromStrings("foo", "bar2", "job", "stuff", LabelServiceName, "stuff"),
},
{
Expand All @@ -232,7 +232,7 @@ func TestParseRequest(t *testing.T) {
enableServiceDiscovery: true,
expectedBytes: len("fizzbuzz"),
expectedLines: 1,
expectedBytesUsageTracker: map[string]float64{`{foo="bar2"}`: float64(len("fizzbuss"))},
expectedBytesUsageTracker: map[string]float64{`{foo="bar2", service_name="unknown_service"}`: float64(len("fizzbuss"))},
expectedLabels: labels.FromStrings("foo", "bar2", LabelServiceName, ServiceUnknown),
},
{
Expand Down
Loading