diff --git a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent.go b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent.go index 9ad68b1537cb6..c874c00b21fba 100644 --- a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent.go +++ b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent.go @@ -100,7 +100,7 @@ func (a *Agent) Start(context.Context) error { a.log.Debug("Starting logs-agent...") // setup the server config - endpoints, err := buildEndpoints(a.config) + endpoints, err := buildEndpoints(a.config, a.log) if err != nil { message := fmt.Sprintf("Invalid endpoints: %v", err) @@ -219,10 +219,13 @@ func (a *Agent) SetupPipeline( } // buildEndpoints builds endpoints for the logs agent -func buildEndpoints(coreConfig pkgconfigmodel.Reader) (*config.Endpoints, error) { +func buildEndpoints(coreConfig pkgconfigmodel.Reader, log logComponent.Component) (*config.Endpoints, error) { httpConnectivity := config.HTTPConnectivityFailure if endpoints, err := config.BuildHTTPEndpoints(coreConfig, intakeTrackType, config.AgentJSONIntakeProtocol, config.DefaultIntakeOrigin); err == nil { httpConnectivity = http.CheckConnectivity(endpoints.Main, coreConfig) + if !httpConnectivity { + log.Warn("Error while validating API key") + } } return config.BuildEndpoints(coreConfig, httpConnectivity, intakeTrackType, config.AgentJSONIntakeProtocol, config.DefaultIntakeOrigin) } diff --git a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent_test.go b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent_test.go index 3698f61e3d6ef..50cf5d335f10b 100644 --- a/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent_test.go +++ b/comp/otelcol/logsagentpipeline/logsagentpipelineimpl/agent_test.go @@ -175,11 +175,12 @@ func TestAgentTestSuite(t *testing.T) { } func TestBuildEndpoints(t *testing.T) { - config := fxutil.Test[configComponent.Component](t, fx.Options( + deps := fxutil.Test[testDeps](t, fx.Options( configComponent.MockModule(), + logimpl.MockModule(), )) - endpoints, err := buildEndpoints(config) + endpoints, err := buildEndpoints(deps.Config, deps.Log) assert.Nil(t, err) assert.Equal(t, "agent-intake.logs.datadoghq.com", endpoints.Main.Host) }