# Own plugin: route for \_cat/indices?

**URL:** <https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006>\
**Category:** Kibana\
**Created:** [December 14, 2016, 10:52am UTC](https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006 "2016-12-14T10:52:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcelHallmann](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MarcelHallmann](https://discuss.elastic.co/u/MarcelHallmann)\
**Post date:** [December 14, 2016, 10:52am UTC](https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006/1 "2016-12-14T10:52:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2016, 11:21am UTC](https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006/2 "2016-12-14T11:21:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MarcelHallmann](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MarcelHallmann](https://discuss.elastic.co/u/MarcelHallmann)\
**Post date:** [December 14, 2016, 11:49am UTC](https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006/3 "2016-12-14T11:49:43Z")

</div>

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)`

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2016, 11:53am UTC](https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006/4 "2016-12-14T11:53:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MarcelHallmann](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@MarcelHallmann](https://discuss.elastic.co/u/MarcelHallmann)\
**Post date:** [December 14, 2016, 11:55am UTC](https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006/5 "2016-12-14T11:55:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 11, 2017, 11:55am UTC](https://discuss.elastic.co/t/own-plugin-route-for--cat-indices/69006/6 "2017-01-11T11:55:45Z")

</div>

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