Skip to content
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: 2 additions & 1 deletion clients/pkg/promtail/targets/lokipush/pushtarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func (t *PushTarget) handleLoki(w http.ResponseWriter, r *http.Request) {
e := api.Entry{
Labels: filtered.Clone(),
Entry: logproto.Entry{
Line: entry.Line,
Line: entry.Line,
StructuredMetadata: entry.StructuredMetadata,
},
}
if t.config.KeepTimestamp {
Expand Down
13 changes: 13 additions & 0 deletions clients/pkg/promtail/targets/lokipush/pushtarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/prometheus/prometheus/model/relabel"
"github.com/stretchr/testify/require"

"github.com/grafana/loki/pkg/push"

"github.com/grafana/loki/v3/clients/pkg/promtail/api"
"github.com/grafana/loki/v3/clients/pkg/promtail/client"
"github.com/grafana/loki/v3/clients/pkg/promtail/client/fake"
Expand Down Expand Up @@ -101,6 +103,10 @@ func TestLokiPushTarget(t *testing.T) {
Entry: logproto.Entry{
Timestamp: time.Unix(int64(i), 0),
Line: "line" + strconv.Itoa(i),
StructuredMetadata: push.LabelsAdapter{
{Name: "i", Value: strconv.Itoa(i)},
{Name: "anotherMetaData", Value: "val"},
},
},
}
}
Expand All @@ -123,6 +129,13 @@ func TestLokiPushTarget(t *testing.T) {
// Spot check the first value in the result to make sure relabel rules were applied properly
require.Equal(t, expectedLabels, eh.Received()[0].Labels)

expectedStructuredMetadata := push.LabelsAdapter{
{Name: "i", Value: strconv.Itoa(0)},
{Name: "anotherMetaData", Value: "val"},
}
// Spot check the first value in the result to make sure structured metadata was received properly
require.Equal(t, expectedStructuredMetadata, eh.Received()[0].StructuredMetadata)

// With keep timestamp enabled, verify timestamp
require.Equal(t, time.Unix(99, 0).Unix(), eh.Received()[99].Timestamp.Unix())

Expand Down