Skip to content

Commit

Permalink
fix: Keep the service_name label after discovery in push.ParseLokiReq…
Browse files Browse the repository at this point in the history
…uest before calculating retention and passing to the usage tracker (#14960)

Signed-off-by: Jordan Rushing <rushing.jordan@gmail.com>
  • Loading branch information
JordanRushing authored Nov 15, 2024
1 parent e55fb14 commit 71d4d6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
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

0 comments on commit 71d4d6a

Please sign in to comment.