Filebeat selftest failt: missing field 'output.elasticsearch.hosts'

Check the indentation of your yaml, if it is like you shared here it is wrong, hosts, protocol, username and password should not be on the same level (column) as the output.elasticsearch.

Compare it with the filebeat.reference.yml.

Should be something like this:

output.elasticsearch:
  hosts: ["yourhost:9200"]