diff --git a/libbeat/idxmgmt/idxmgmt.go b/libbeat/idxmgmt/idxmgmt.go index efc9de34755..9b65d64529d 100644 --- a/libbeat/idxmgmt/idxmgmt.go +++ b/libbeat/idxmgmt/idxmgmt.go @@ -124,11 +124,16 @@ func MakeDefaultSupport(ilmSupport lifecycle.SupportFactory) SupportFactory { if outCfg.Output.IsSet() && outCfg.Output.Name() == "elasticsearch" { esClient, err := eslegclient.NewConnectedClient(outCfg.Output.Config(), info.Beat) if err != nil { - return nil, fmt.Errorf("error creating ES client while setting up index support: %w", err) - } - if esClient.IsServerless() { - defaultLifecycle = lifecycle.DefaultDSLConfig(info) + // this is for the benefit of tests as well as various retry mechanisms; + // if we can't connect to ES, print a warning and fallback to ILM, tests won't care and non-test environments can + // retry the connection + logp.L().Warnf("could not connect to ES to determine ES type during index setup. Will default to ILM.") + } else { + if esClient.IsServerless() { + defaultLifecycle = lifecycle.DefaultDSLConfig(info) + } } + } // now that we have the "correct" default, unpack the rest of the config diff --git a/libbeat/tests/integration/template_test.go b/libbeat/tests/integration/template_test.go index d853e9503ac..1812456c9d1 100644 --- a/libbeat/tests/integration/template_test.go +++ b/libbeat/tests/integration/template_test.go @@ -87,17 +87,15 @@ setup.template: // Test that beat stops in case elasticsearch index is modified and name not func TestIndexModifiedNoName(t *testing.T) { - cfgRaw := ` + cfg := ` mockbeat: output: elasticsearch: - hosts: %s index: test setup.template: pattern: test ` - esUrl := GetESURL(t, "http") - cfg := fmt.Sprintf(cfgRaw, esUrl.String()) + mockbeat := NewBeat(t, "mockbeat", "../../libbeat.test") mockbeat.WriteConfigFile(cfg) mockbeat.Start()