Error when reloading prospectors for filebeat

I opened https://github.com/elastic/beats/pull/4128 with a potential fix. I still need to add tests and check it in some more details.