Anyone has the same problem where the Metricbeats keep trying to connect to Elasticsearch Url: http://localhost:9200 until around 1h 30 mins later and it finds the correct Elasticsearch Url that was identified in the fleet settings.
{"log.level":"error","@timestamp":"2023-03-06T04:55:12.781Z","log.logger":"publisher_pipeline_output","log.origin":{"file.name":"pipeline/client_worker.go","file.line":150},"message":"Failed to connect to backoff(elasticsearch(http://localhost:9200)): Get \"http://localhost:9200\": dial tcp 127.0.0.1:9200: connect: connection refused","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2023-03-06T04:55:12.781Z","log.logger":"publisher_pipeline_output","log.origin":{"file.name":"pipeline/client_worker.go","file.line":141},"message":"Attempting to reconnect to backoff(elasticsearch(http://localhost:9200)) with 126 reconnect attempt(s)","service.name":"metricbeat","ecs.version":"1.6.0"}
The entire setup is using traffic filter via AWS private link and using fleet managed elastic agent.