Commit e4567e72 authored by Leonardo Menezes's avatar Leonardo Menezes
Browse files

overview: added index stats action

closes #82
parent 4b9809bd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -45,4 +45,10 @@ class CommonsController @Inject()(val authentication: AuthenticationModule,
    }
  }

  def getIndexStats = process { request =>
    client.indexStats(request.get("index"), request.target).map { response =>
      CerebroResponse(response.status, response.body)
    }
  }

}
+2 −1
Original line number Diff line number Diff line
package elastic

import com.google.inject.ImplementedBy
import controllers.auth.AuthenticationModuleImpl
import models.ElasticServer
import play.api.libs.json._

@@ -20,6 +19,8 @@ trait ElasticClient {

  def nodeStats(node: String, target: ElasticServer): Future[ElasticResponse]

  def indexStats(index: String, target: ElasticServer): Future[ElasticResponse]

  def clusterSettings(target: ElasticServer): Future[ElasticResponse]

  def aliases(target: ElasticServer): Future[ElasticResponse]
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ class HTTPElasticClient @Inject()(client: WSClient) extends ElasticClient {
    execute(s"${target.host}$path", "GET", None, target.authentication)
  }

  def indexStats(index: String, target: ElasticServer): Future[ElasticResponse] = {
    val path = s"/$index/_stats?human=true"
    execute(s"${target.host}$path", "GET", None, target.authentication)
  }

  def nodeStats(node: String, target: ElasticServer) = {
    val path = s"/_nodes/$node/stats?human"
    execute(s"${target.host}$path", "GET", None, target.authentication)
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ POST /commons/nodes controllers.CommonsControl
POST        /commons/get_index_settings               controllers.CommonsController.getIndexSettings
POST        /commons/get_index_mapping                controllers.CommonsController.getIndexMappings
POST        /commons/get_node_stats                   controllers.CommonsController.getNodeStats
POST        /commons/get_index_stats                  controllers.CommonsController.getIndexStats

# Create index module
POST        /create_index/get_index_metadata          controllers.CreateIndexController.getIndexMetadata
+9 −0
Original line number Diff line number Diff line
@@ -1011,6 +1011,10 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http',
      OverviewDataService.nodeStats(node, displayInfo, error);
    };

    $scope.indexStats = function(index) {
      OverviewDataService.indexStats(index, displayInfo, error);
    };

    $scope.getIndexSettings = function(index) {
      OverviewDataService.getIndexSettings(index, displayInfo, error);
    };
@@ -1136,6 +1140,11 @@ angular.module('cerebro').factory('OverviewDataService', ['DataService',
      DataService.send('commons/get_node_stats', {node: node}, success, error);
    };

    this.indexStats = function(index, success, error) {
      var data = {index: index};
      DataService.send('commons/get_index_stats', data, success, error);
    };

    this.getIndexMapping = function(index, success, error) {
      var data = {index: index};
      DataService.send('commons/get_index_mapping', data, success, error);
Loading