Skip to content

Commit

Permalink
[receiver/promtail] bring back promtailreceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
mar4uk committed Jan 31, 2023
1 parent 03de69e commit 7f2998d
Show file tree
Hide file tree
Showing 11 changed files with 986 additions and 96 deletions.
16 changes: 16 additions & 0 deletions .chloggen/add-promtail-receiver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: promtailreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds promtailreceiver to the `internal/components`

# One or more tracking issues related to the change
issues: [17082]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
68 changes: 63 additions & 5 deletions cmd/configschema/go.mod

Large diffs are not rendered by default.

398 changes: 388 additions & 10 deletions cmd/configschema/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion exporter/lokiexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 61 additions & 11 deletions go.mod

Large diffs are not rendered by default.

397 changes: 387 additions & 10 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusexecreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/promtailreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsarreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver"
Expand Down Expand Up @@ -273,7 +274,7 @@ func Components() (otelcol.Factories, error) {
postgresqlreceiver.NewFactory(),
prometheusexecreceiver.NewFactory(),
prometheusreceiver.NewFactory(),
// promtailreceiver.NewFactory(),
promtailreceiver.NewFactory(),
pulsarreceiver.NewFactory(),
purefareceiver.NewFactory(),
purefbreceiver.NewFactory(),
Expand Down
64 changes: 35 additions & 29 deletions internal/components/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ import (
"path/filepath"
"runtime"
"testing"
"time"

"github.com/grafana/loki/clients/pkg/promtail/scrapeconfig"
"github.com/grafana/loki/clients/pkg/promtail/targets/file"
"github.com/prometheus/common/model"
promconfig "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/discovery"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
Expand All @@ -44,6 +49,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbatlasreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/otlpjsonfilereceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/promtailreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snmpreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver"
Expand Down Expand Up @@ -303,35 +309,35 @@ func TestDefaultReceivers(t *testing.T) {
receiver: "prometheus_exec",
skipLifecyle: true, // Requires running a subproccess that can not be easily set across platforms
},
// {
// receiver: "promtail",
// getConfigFn: func() component.Config {
// cfg := rcvrFactories["promtail"].CreateDefaultConfig().(*promtailreceiver.PromtailConfig)
// cfg.InputConfig = *promtailreceiver.NewConfigWithID("testconfig")
// cfg.InputConfig.Input = promtailreceiver.PromtailInputConfig{
// ScrapeConfig: []scrapeconfig.Config{
// {
// JobName: "test",
// PipelineStages: []interface{}{},
// ServiceDiscoveryConfig: scrapeconfig.ServiceDiscoveryConfig{
// StaticConfigs: discovery.StaticConfig{
// {
// Labels: model.LabelSet{
// "job": "varlogs",
// },
// Targets: []model.LabelSet{},
// },
// },
// },
// },
// },
// TargetConfig: file.Config{
// SyncPeriod: 10 * time.Second,
// },
// }
// return cfg
// },
// },
{
receiver: "promtail",
getConfigFn: func() component.Config {
cfg := rcvrFactories["promtail"].CreateDefaultConfig().(*promtailreceiver.PromtailConfig)
cfg.InputConfig = *promtailreceiver.NewConfigWithID("testconfig")
cfg.InputConfig.Input = promtailreceiver.PromtailInputConfig{
ScrapeConfig: []scrapeconfig.Config{
{
JobName: "test",
PipelineStages: []interface{}{},
ServiceDiscoveryConfig: scrapeconfig.ServiceDiscoveryConfig{
StaticConfigs: discovery.StaticConfig{
{
Labels: model.LabelSet{
"job": "varlogs",
},
Targets: []model.LabelSet{},
},
},
},
},
},
TargetConfig: file.Config{
SyncPeriod: 10 * time.Second,
},
}
return cfg
},
},
{
receiver: "pulsar",
skipLifecyle: true, // TODO It requires a running pulsar instance to start successfully.
Expand Down
18 changes: 9 additions & 9 deletions receiver/promtailreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/go-kit/log v0.2.1
github.com/grafana/loki v1.6.2-0.20230116134839-2597429c893c
github.com/grafana/loki v1.6.2-0.20230127130729-855d2b74bc07
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.70.0
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.39.0
Expand All @@ -19,7 +19,7 @@ require (
)

require (
cloud.google.com/go v0.105.0 // indirect
cloud.google.com/go v0.107.0 // indirect
cloud.google.com/go/compute v1.14.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.8.0 // indirect
Expand Down Expand Up @@ -89,7 +89,7 @@ require (
github.com/gogo/googleapis v1.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/status v1.1.1 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
Expand All @@ -108,6 +108,7 @@ require (
github.com/grafana/dskit v0.0.0-20230109170026-7242706251b9 // indirect
github.com/grafana/go-gelf/v2 v2.0.1 // indirect
github.com/grafana/gomemcache v0.0.0-20230105173749-11f792309e1f // indirect
github.com/grafana/loki/pkg/push v0.0.0-20230127102416-571f88bc5765 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/grafana/tail v0.0.0-20221214082743-3a1c242a4d7b // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
Expand All @@ -124,9 +125,9 @@ require (
github.com/hashicorp/golang-lru v0.6.0 // indirect
github.com/hashicorp/memberlist v0.5.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/heroku/x v0.0.50 // indirect
github.com/heroku/x v0.0.55 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/influxdata/go-syslog/v3 v3.0.1-0.20210608084020-ac565dc76ba6 // indirect
github.com/influxdata/telegraf v1.16.3 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
Expand Down Expand Up @@ -176,11 +177,10 @@ require (
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sony/gobreaker v0.5.0 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/thanos-io/thanos v0.28.0 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/weaveworks/promrus v1.2.0 // indirect
Expand All @@ -204,7 +204,7 @@ require (
go.uber.org/multierr v1.9.0 // indirect
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.5.0 // indirect
Expand All @@ -218,7 +218,7 @@ require (
gonum.org/v1/gonum v0.12.0 // indirect
google.golang.org/api v0.108.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.52.3 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
Expand Down
Loading

0 comments on commit 7f2998d

Please sign in to comment.