Own plugin: route for _cat/indices?


#1

Hi all,

Kibana Version: 5.0.0

For an own plugin I'd like to receive the list of all indices, i.e. the ouput of
GET /_cat/indices?index=myindices-*&h=index

But I could not figure out how to set up the route in the es_route.js file.
At the moment it looks like:
server.route({ path: '/api/elasticsearch_myplugin/_cat/indices', method: 'GET', handler(req, reply) { call(req, 'cat', { h: [], pri: '???' }).then(function (response) { reply(response); }); } });

From within the controller I make the call:
$http.post('../api/elasticsearch_myplugin/_cat/indices', this.queryMatchAll()).then((response) => { console.log(response.data.hits.hits); });

I get this error message:
POST http://localhost:5601/iaw/api/elasticsearch_myplugin/_cat/indices 404 (Not Found)

Does anybody have an idea how to configure the route properly?


(Felix Stürmer) #2

Hi @MarcelHallmann,

From the code snippets it looks like you're creating the server side route handler for the GET method, but performing a POST request on the client side. That could explain the 404 response.


#3

Yes, you right, this was a copy/paste failure.
I changed the call to
$http.get('../api/elasticsearch_sicdayselector/_cat/indices', this.queryMatchAll()).then((response) => { console.log(response); });

but now I'm getting:
GET http://localhost:5601/iaw/api/elasticsearch_myplugin/_cat/indices 500 (Internal Server Error)


(Felix Stürmer) #4

That looks like an exception is being thrown inside your handler. What does the Kibana server log show?


#5

Hah, I just figured it out!!

The es_route entry must look like:

server.route({ path: '/api/elasticsearch_sicdayselector/_cat/indices', method: 'GET', handler(req, reply) { call(req, 'cat.indices', { index: 'myindices-*', h: 'index' }).then(function (response) { reply(response); }); } });

Thanks for the help!


(system) #6

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