diff --git a/.chloggen/webhookevent-enable.yaml b/.chloggen/webhookevent-enable.yaml new file mode 100755 index 000000000000..c70a9cc94959 --- /dev/null +++ b/.chloggen/webhookevent-enable.yaml @@ -0,0 +1,20 @@ +# Use this changelog template to create an entry for release notes. +# If your change doesn't affect end users, such as a test fix or a tooling change, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'enhancement' + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: webhookeventreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Mark the component as Alpha and add to `component.go` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [18101] + +# (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: diff --git a/cmd/configschema/go.mod b/cmd/configschema/go.mod index 7127847d5cde..5f0b53445d57 100644 --- a/cmd/configschema/go.mod +++ b/cmd/configschema/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/fatih/structtag v1.2.0 github.com/google/uuid v1.3.0 - github.com/open-telemetry/opentelemetry-collector-contrib v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver v0.79.0 github.com/stretchr/testify v1.8.4 go.opentelemetry.io/collector v0.79.0 @@ -450,6 +450,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/julienschmidt/httprouter v1.3.0 // indirect github.com/karrick/godirwalk v1.17.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.16.5 // indirect @@ -513,6 +514,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/pkg/winperfcounters v0.79.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver v0.79.0 // indirect github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver v0.79.0 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect @@ -1044,6 +1046,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcent replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver => ../../receiver/wavefrontreceiver +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver => ../../receiver/webhookeventreceiver + replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver => ../../receiver/windowseventlogreceiver replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver => ../../receiver/windowsperfcountersreceiver diff --git a/cmd/configschema/go.sum b/cmd/configschema/go.sum index 60447fa42874..283c3cffa4a8 100644 --- a/cmd/configschema/go.sum +++ b/cmd/configschema/go.sum @@ -2134,6 +2134,7 @@ github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea/go.mod h1:W54LbzXuIE0b github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/julz/importas v0.0.0-20210226073942-60b4fa260dd0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= diff --git a/cmd/otelcontribcol/builder-config.yaml b/cmd/otelcontribcol/builder-config.yaml index d9d1c6fa11a2..2d1d0b4b4b72 100644 --- a/cmd/otelcontribcol/builder-config.yaml +++ b/cmd/otelcontribcol/builder-config.yaml @@ -187,6 +187,7 @@ receivers: - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.79.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snmpreceiver v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.79.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver v0.79.0 @@ -401,6 +402,7 @@ replaces: - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver => ../../receiver/cloudflarereceiver - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusexecreceiver => ../../receiver/prometheusexecreceiver - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver => ../../receiver/windowseventlogreceiver + - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver => ../../receiver/webhookeventreceiver - github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/ecsobserver => ../../extension/observer/ecsobserver # see https://github.com/mattn/go-ieproxy/issues/45 - github.com/mattn/go-ieproxy => github.com/mattn/go-ieproxy v0.0.1 diff --git a/cmd/otelcontribcol/components.go b/cmd/otelcontribcol/components.go index 6f7b680be683..44c6e6343f71 100644 --- a/cmd/otelcontribcol/components.go +++ b/cmd/otelcontribcol/components.go @@ -188,6 +188,7 @@ import ( udplogreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver" vcenterreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver" wavefrontreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver" + webhookeventreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver" windowseventlogreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver" windowsperfcountersreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver" zipkinreceiver "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver" @@ -308,6 +309,7 @@ func components() (otelcol.Factories, error) { udplogreceiver.NewFactory(), vcenterreceiver.NewFactory(), wavefrontreceiver.NewFactory(), + webhookeventreceiver.NewFactory(), snmpreceiver.NewFactory(), windowsperfcountersreceiver.NewFactory(), windowseventlogreceiver.NewFactory(), diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index a47985f4c09b..4b2bed6e151c 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -176,6 +176,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.79.0 + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.79.0 @@ -453,6 +454,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/julienschmidt/httprouter v1.3.0 // indirect github.com/karrick/godirwalk v1.17.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.16.5 // indirect @@ -1078,6 +1080,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prome replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver => ../../receiver/windowseventlogreceiver +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver => ../../receiver/webhookeventreceiver + replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/ecsobserver => ../../extension/observer/ecsobserver replace github.com/mattn/go-ieproxy => github.com/mattn/go-ieproxy v0.0.1 diff --git a/cmd/otelcontribcol/go.sum b/cmd/otelcontribcol/go.sum index eea95595f979..280740c2c974 100644 --- a/cmd/otelcontribcol/go.sum +++ b/cmd/otelcontribcol/go.sum @@ -2131,6 +2131,7 @@ github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea/go.mod h1:W54LbzXuIE0b github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/julz/importas v0.0.0-20210226073942-60b4fa260dd0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= diff --git a/cmd/otelcontribcol/receivers_test.go b/cmd/otelcontribcol/receivers_test.go index dc3a659a1cac..ed82130eb722 100644 --- a/cmd/otelcontribcol/receivers_test.go +++ b/cmd/otelcontribcol/receivers_test.go @@ -38,6 +38,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/syslogreceiver" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver" ) func TestDefaultReceivers(t *testing.T) { @@ -400,6 +401,14 @@ func TestDefaultReceivers(t *testing.T) { receiver: "wavefront", skipLifecyle: true, // Depends on carbon receiver to be running correctly }, + { + receiver: "webhookevent", + getConfigFn: func() component.Config { + cfg := rcvrFactories["webhookevent"].CreateDefaultConfig().(*webhookeventreceiver.Config) + cfg.Endpoint = "127.0.0.1:8088" + return cfg + }, + }, { receiver: "windowseventlog", skipLifecyle: true, // Requires a running windows process diff --git a/go.mod b/go.mod index 1b7ace3d7590..83f1a548f9f2 100644 --- a/go.mod +++ b/go.mod @@ -162,6 +162,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.79.0 + github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.79.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.79.0 @@ -434,6 +435,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/julienschmidt/httprouter v1.3.0 // indirect github.com/karrick/godirwalk v1.17.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.16.5 // indirect @@ -1051,6 +1053,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavef replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver => ./receiver/windowseventlogreceiver +replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver => ./receiver/webhookeventreceiver + replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver => ./receiver/windowsperfcountersreceiver replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver => ./receiver/zipkinreceiver diff --git a/go.sum b/go.sum index 0e97683a24e8..8d0c33691737 100644 --- a/go.sum +++ b/go.sum @@ -2137,6 +2137,7 @@ github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea/go.mod h1:W54LbzXuIE0b github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/julz/importas v0.0.0-20210226073942-60b4fa260dd0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= diff --git a/internal/components/components.go b/internal/components/components.go index d40e973e03b4..197498a30ac4 100644 --- a/internal/components/components.go +++ b/internal/components/components.go @@ -178,6 +178,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/webhookeventreceiver" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver" @@ -291,6 +292,7 @@ func Components() (otelcol.Factories, error) { sshcheckreceiver.NewFactory(), statsdreceiver.NewFactory(), wavefrontreceiver.NewFactory(), + webhookeventreceiver.NewFactory(), windowseventlogreceiver.NewFactory(), windowsperfcountersreceiver.NewFactory(), zookeeperreceiver.NewFactory(), diff --git a/receiver/webhookeventreceiver/README.md b/receiver/webhookeventreceiver/README.md index 459072afedf2..31150a65a9c6 100644 --- a/receiver/webhookeventreceiver/README.md +++ b/receiver/webhookeventreceiver/README.md @@ -3,11 +3,37 @@ | Status | | | ------------- |-----------| -| Stability | [development]: logs | +| Stability | [alpha]: logs | | Distributions | [] | -[development]: https://github.com/open-telemetry/opentelemetry-collector#development +[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha -The Webhook Event receiver is meantWebhook Event to act as a generally available push based receiver for any webhook style data source. +The Webhook Event Receiver is a push based event collector component meant to act as a generally available receiver for any webhook style data source. It is designed to work alongside other pipeline components +like the [transform processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor) to allow the ingestion of generic events as logs into the opentelemetry +collector. + +## Configuration + +The following settings are required: + +* `endpoint` (no default): The endpoint where you may point your webhook to emit events to + +The following settings are optional: + +* `path` (default: '/events'): Path where the receiver instance will accept events +* `health_path` (default: '/health_check'): Path available for checking receiver status +* `read_timeout` (default: '500ms'): Maximum wait time while attempting to read a received event +* `write_timeout` (default: '500ms'): Maximum wait time while attempting to write a response + +Example: +```yaml +receivers: + webhookevent: + endpoint: localhost:8088 + read_timeout: "500ms" + path: "eventsource/receiver" + health_path: "eventreceiver/healthcheck" +``` +The full list of settings exposed for this receiver are documented [here](./config.go) with a detailed sample configuration [here](./testdata/config.yaml) diff --git a/receiver/webhookeventreceiver/internal/metadata/generated_status.go b/receiver/webhookeventreceiver/internal/metadata/generated_status.go index 27a3adfaf2d9..e0bb6684022d 100644 --- a/receiver/webhookeventreceiver/internal/metadata/generated_status.go +++ b/receiver/webhookeventreceiver/internal/metadata/generated_status.go @@ -8,5 +8,5 @@ import ( const ( Type = "webhookevent" - LogsStability = component.StabilityLevelDevelopment + LogsStability = component.StabilityLevelAlpha ) diff --git a/receiver/webhookeventreceiver/metadata.yaml b/receiver/webhookeventreceiver/metadata.yaml index 1611b0d9dca7..d3212393673c 100644 --- a/receiver/webhookeventreceiver/metadata.yaml +++ b/receiver/webhookeventreceiver/metadata.yaml @@ -3,6 +3,6 @@ type: webhookevent status: class: receiver stability: - development: [logs] - distributions: + alpha: [logs] + distributions: diff --git a/receiver/webhookeventreceiver/receiver.go b/receiver/webhookeventreceiver/receiver.go index 2cb5140dab1a..be73d30002c7 100644 --- a/receiver/webhookeventreceiver/receiver.go +++ b/receiver/webhookeventreceiver/receiver.go @@ -133,6 +133,11 @@ func (er *eventReceiver) Start(_ context.Context, host component.Host) error { // Shutdown function manages receiver shutdown tasks. part of the receiver.Logs interface. func (er *eventReceiver) Shutdown(_ context.Context) error { + // server must exist to be closed. + if er.server == nil { + return nil + } + err := er.server.Close() er.shutdownWG.Wait() return err