Skip to content

Commit

Permalink
Avoid putting all the GCP labels into loki labels (#3284)
Browse files Browse the repository at this point in the history
  • Loading branch information
kavirajk authored Feb 3, 2021
1 parent 3bd725e commit d667dd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
9 changes: 1 addition & 8 deletions pkg/promtail/targets/gcplog/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@ func format(m *pubsub.Message, other model.LabelSet, useIncomingTimestamp bool)
}

labels := model.LabelSet{
"logName": model.LabelValue(ge.LogName),
"resourceType": model.LabelValue(ge.Resource.Type),
}
for k, v := range ge.Resource.Labels {
if !model.LabelName(k).IsValid() || !model.LabelValue(k).IsValid() {
continue
}
labels[model.LabelName(k)] = model.LabelValue(v)
"resource_type": model.LabelValue(ge.Resource.Type),
}

// add labels from config as well.
Expand Down
12 changes: 4 additions & 8 deletions pkg/promtail/targets/gcplog/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ func TestFormat(t *testing.T) {
useIncomingTimestamp: true,
expected: api.Entry{
Labels: model.LabelSet{
"jobname": "pubsub-test",
"logName": "https://project/gcs",
"resourceType": "gcs",
"instanceId": "344555",
"jobname": "pubsub-test",
"resource_type": "gcs",
},
Entry: logproto.Entry{
Timestamp: mustTime(t, "2020-12-22T15:01:23.045123456Z"),
Expand All @@ -53,10 +51,8 @@ func TestFormat(t *testing.T) {
},
expected: api.Entry{
Labels: model.LabelSet{
"jobname": "pubsub-test",
"logName": "https://project/gcs",
"resourceType": "gcs",
"instanceId": "344555",
"jobname": "pubsub-test",
"resource_type": "gcs",
},
Entry: logproto.Entry{
Timestamp: time.Now(),
Expand Down

0 comments on commit d667dd2

Please sign in to comment.