Skip to content
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

Asynchronous Promtail stages #2996

Merged
merged 23 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes lint issues
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena committed Nov 26, 2020
commit 49f6d5a846cc8d4f9dc8bd9f8b1b8a6124658039
5 changes: 3 additions & 2 deletions cmd/fluent-bit/loki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"testing"
"time"

jsoniter "github.com/json-iterator/go"
"github.com/prometheus/common/model"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/client/fake"
jsoniter "github.com/json-iterator/go"
"github.com/prometheus/common/model"
)

var now = time.Now()
Expand Down
9 changes: 3 additions & 6 deletions pkg/logentry/stages/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"time"

"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

// Not all these are tested but are here to make sure the different types marshal without error
Expand Down Expand Up @@ -292,10 +293,6 @@ func ptrFromString(str string) *string {
return &str
}

func ptrFromTime(t time.Time) *time.Time {
return &t
}

// TestDropPipeline is used to verify we properly parse the yaml config and create a working pipeline
func TestDropPipeline(t *testing.T) {
registry := prometheus.NewRegistry()
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"time"

"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"time"

"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var testJSONYamlSingleStageWithoutSource = `
Expand Down
3 changes: 2 additions & 1 deletion pkg/logentry/stages/labeldrop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"testing"

"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"

"github.com/grafana/loki/pkg/promtail/api"
)

func Test_dropLabelStage_Process(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (

"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var testLabelsYaml = `
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"time"

"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var testMatchYaml = `
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (

"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var testOutputYaml = `
Expand Down
7 changes: 4 additions & 3 deletions pkg/logentry/stages/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/client/fake"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/client/fake"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/regex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import (

"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var testRegexYamlSingleStageWithoutSource = `
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/replace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"time"

"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var testReplaceYamlSingleStageWithoutSource = `
Expand Down
3 changes: 2 additions & 1 deletion pkg/logentry/stages/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"

"github.com/grafana/loki/pkg/promtail/api"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions pkg/logentry/stages/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (

"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"

"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/promtail/api"
)

var testTemplateYaml = `
Expand Down
3 changes: 2 additions & 1 deletion pkg/promtail/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package api
import (
"sync"

"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/common/model"

"github.com/grafana/loki/pkg/logproto"
)

// Entry is a log entry with labels.
Expand Down
4 changes: 1 addition & 3 deletions pkg/promtail/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ func (c *client) processEntry(e api.Entry) (api.Entry, string) {
e.Labels = c.externalLabels.Merge(e.Labels)
}
tenantID := c.getTenantID(e.Labels)
if _, ok := e.Labels[ReservedLabelTenantID]; ok {
delete(e.Labels, ReservedLabelTenantID)
}
delete(e.Labels, ReservedLabelTenantID)
return e, tenantID
}

Expand Down