How to intercept search request (in a pluign) without creating separate RestAction

Is it possible to intercept the request (and save the payload in ES) in a
plugin without creating a separate RestAction ?

  1. I want to avoid having to add separate url patterns
  2. I want to return the same response ES would return without the plugin.

What would be the best possible to log search request into elasticsearch ?
I know I can create a nginx proxy that would do that but I wanted to have a
solution built in ES.

I was thinking of a service that would schedule puting the payload in ES
so the plugin wouldn't block the response?

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit

Hi @Piotr_Majewski,

Did you end up with some solution? I have a ES API extension plugin to intercept all requests sent to ES. you may try the code below. use ES 5.1.x

public class RestRequestInterceptorAction extends BaseRestHandler {

    private static final Logger logger = Loggers.getLogger(RestRequestInterceptorAction.class);
    public RestRequestInterceptorAction(Settings settings, RestController controller) {
        controller.registerFilter(new RestFilter() {
            public void process(RestRequest request, RestChannel channel, NodeClient client, RestFilterChain filterChain)
                    throws Exception {
                RestRequest newRequest = new RestRequest(request.params(), request.path()) {
                    public String uri() {
//              "add customize uri");
                        return request.uri();

                    public Method method() {
//              "method shall be the same");
                        return request.method();

                    public Iterable<Entry<String, String>> headers() {
//              "add customized header to request");
                        return request.headers();

                    public String header(String name) {
                        return request.header(name);

                    public boolean hasContent() {
//              "has Contect?:" + request.hasContent());
                        return request.hasContent();

                    public BytesReference content() {
//              "customized content is called");
                        return request.content();
                filterChain.continueProcessing(newRequest, channel, client);