Making API POST request in Kibana plugin

Hello everyone,
I'm trying to create a simple Kibana plugin which should send _update_by_query request to elasticsearch, with values to updated provided by GUI in said plugin, but I can't quite grasp how making API calls works from a plugin.

At first I've tried doing it with fetch(node/_update_by_query, method: "POST)", but I realized it's the wrong way to do it entirely.

From what I've learned, I believe I should use the data plugin in order to prepare a query and send it, but I cannot comprehend, how it should be done and the documentation provided with it doesn't make anything clearer for me. Could you please provide me with some tutorial/examples on how such request should be done?

I realize this is a pretty basic question, but this plugin is my first contact with the entire ELK stack I feel a bit lost...
Thank you in advance. :slight_smile:

data plugin is for _search API access.

Kibana client does not have direct access to elasticsearch. You will need to create a rest endpoint in server folder of your plugin. This end point will internally call elasticsearch API and forward a response. Then you can call this endpoint with fetch in the client. Here is an example.

server route /internal/file_upload/import

calling route in client kibana/x-pack/plugins/file_upload/public/importer/importer.ts at main · elastic/kibana · GitHub

1 Like

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