Custom endpoint settings

Hi team,
How to set custom endpoint to write JSON from front-end to two indicies simultaneously?
Use Kibana 6.7.0.

You'll need to create a custom plugin and add a server route with the path you want to call from the front end. This route can then handle talking to Elasticsearch on behalf of the client.

return new kibana.Plugin({
  // ...
  init(server, options) {
    server.route({
      path: '/api/my_plugin/my_endpoint',
      method: 'GET',
      handler(req, reply) {
        const response = await server.plugins.elasticsearch.callWithRequest(req, ...args);
        // ... do something with response
        reply('message to send to client');
      }
    });
  }
});

Then you can talk to your API from the front end by calling /api/my_plugin/my_endpoint

This blog post, though a few years old, provides some good examples with further detail on how to configure server routes in your plugin & query Elasticsearch using callWithRequest.

Kibana's server-side plugin code relies heavily on hapi, so those docs will also be a good point of reference in terms of how to configure your server routes.

issue resolved

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