Elasticsearch bucket script metric on grouping by filters

Hello,

I have data in elastic that represents lines from apache access log. I would like to create custom metric for apache availability. For example I have all GET requests (query: request: /.GET ./) and would like to get ratio between successfull and all requests according to response_code (response_code: [200 TO 308] / response_code: [200 TO 511]). Is it somehow possible via bucket script metric or any other option?
I already tried transformation and MetaQueries plugin, that are able to create this graph, but I also need alerting, which is not supported on both.