diff --git a/.chloggen/mx-psi_internal-localhostgate.yaml b/.chloggen/mx-psi_internal-localhostgate.yaml index 08f6e66d0c22..79bfaaaa5e20 100755 --- a/.chloggen/mx-psi_internal-localhostgate.yaml +++ b/.chloggen/mx-psi_internal-localhostgate.yaml @@ -17,7 +17,7 @@ issues: [30702] # Use pipe (|) for multiline entries. subtext: | This change affects the following components: - - TBF + - receiver/loki # If your change doesn't affect end users or the exported elements of any package, # you should instead start your pull request title with [chore] or use the "Skip Changelog" label. diff --git a/receiver/lokireceiver/README.md b/receiver/lokireceiver/README.md index b2617ce5e80b..2c437c0755d6 100644 --- a/receiver/lokireceiver/README.md +++ b/receiver/lokireceiver/README.md @@ -22,7 +22,7 @@ This receiver runs HTTP and GRPC servers to ingest log entries in Loki format. The settings are: -- `endpoint` (required, default = 0.0.0.0:3500 for HTTP protocol, 0.0.0.0:3600 gRPC protocol): host:port to which the receiver is going to receive data. +- `endpoint` (required, default = 0.0.0.0:3500 for HTTP protocol, 0.0.0.0:3600 gRPC protocol): host:port to which the receiver is going to receive data. The `component.UseLocalHostAsDefaultHost` feature gate changes these to localhost:3500 and localhost:3600. These will become the default in a future release. - `use_incoming_timestamp` (optional, default = false) if set `true` the timestamp from Loki log entry is used Example: diff --git a/receiver/lokireceiver/factory.go b/receiver/lokireceiver/factory.go index 1f8b09baa15d..3204784b598b 100644 --- a/receiver/lokireceiver/factory.go +++ b/receiver/lokireceiver/factory.go @@ -15,10 +15,13 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/receiver" + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver/internal/metadata" ) const ( + defaultGRPCPort = 3600 + defaultHTTPPort = 3500 defaultGRPCBindEndpoint = "0.0.0.0:3600" defaultHTTPBindEndpoint = "0.0.0.0:3500" ) @@ -36,12 +39,12 @@ func createDefaultConfig() component.Config { Protocols: Protocols{ GRPC: &configgrpc.GRPCServerSettings{ NetAddr: confignet.NetAddr{ - Endpoint: defaultGRPCBindEndpoint, + Endpoint: localhostgate.EndpointForPort(defaultGRPCPort), Transport: "tcp", }, }, HTTP: &confighttp.HTTPServerSettings{ - Endpoint: defaultHTTPBindEndpoint, + Endpoint: localhostgate.EndpointForPort(defaultHTTPPort), }, }, }