Accessing to different index from the contoroller in kibana

(Yu Watanabe) #1


I am now writing code for custom plugin in kibana.

What I want to do is, access to different index from the current scope.

I have a controller for visualization app accessing to index1 now as below .

  module.controller('PluginController', function ($scope, Private) {
      $scope.$watch('esResponse', function (resp) {
        if (resp) {
         var bucketId = $scope.vis.aggs.bySchemaName['bucket'][0].id;

         var buckets  = resp.aggregations[bucketId].buckets;

         $scope.bucket = {
           return {
             label: bucket.key

But I want to access to index test2 too in my custom logic.
Is this possible in visualization app?

(Tim Sullivan) #2

It's not very clear what your goals are. Seems that you access index1 because that's the selected index pattern for your visualization, but is the index2 name supposed to be hardcoded in your controller for a follow-up query? Is the goal going to be to join data from the initial response with data from index2?

(Yu Watanabe) #3

Hi @tsullivan

Sorry that I didnt make things clear.

What I want to do is to access index1 and index2 regardless of selected index in vidualization.

I assume this is possible using javascript client of elasticsearch.

Am I correct?

(Tim Sullivan) #4

Am I correct?

Yes, you should be able to get the Elasticsearch client by creating a module that has the es dependency, which is the Elasticsearch client. An example from Kibana:

Then you can call methods off the client, for example es.get(). You can refer to the documentation for the available methods and the options they take. Index name is usually a field you can supply in the params.

Sorry for the delayed response - my email notifications were not coming in.

(system) #5