Backport elasticsearch/logstash#748

Untested as yet, as I can't find the docs for that at the moment (to be continued)