How to access custom elastic search plugin url in kibana custom plugin

A new Elasticsearch plugin with endpoint e.g. /_pql is installed. I'm developing a new kibana plugin, How to send a request to this url through kibana

I have tried:

init: function (server) {
server.route({
method: ['POST', 'GET'],
path: '/api/_pql',
handler: async (request, reply) => {

      console.log(request);

     
     const { callWithRequest } = server.plugins.elasticsearch.getCluster('admin');
     

      return callWithRequest(request, '/_pql', {"quey:":"example'"})
      .then(function (resp) {
       reply(response);
      });
    }
  });
},

and I'm getting

server error [09:14:58.081] [warning][process] Error: called with an invalid endpoint: /_pql
at callAPI

You will need to extend elasticsearch-js to be aware of the new endpoint. The "clusters" represented by "getCluster" can not be extended, so you will need to create a new cluster with your elasticsearch-js extension. You can see how we did this with monitoring here: https://github.com/elastic/kibana/blob/master/x-pack/plugins/monitoring/server/es_client/instantiate_client.js

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.