Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add indices_view module #489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/controllers/IndicesController.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package controllers

import javax.inject.Inject

import controllers.auth.AuthenticationModule
import elastic.{ElasticClient, Error, Success}
import models.nodes.Nodes
import models.{CerebroResponse, Hosts}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

class IndicesController @Inject()(val authentication: AuthenticationModule,
val hosts: Hosts,
client: ElasticClient) extends BaseController {
def index = process { request =>
client.getIndicesStats(request.target).map {
case Success(status, repositories) => CerebroResponse(status, repositories)
case Error(status, error) => CerebroResponse(status, error)
}
}

}
1 change: 1 addition & 0 deletions app/elastic/ElasticClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ trait ElasticClient {

def executeRequest(method: String, path: String, data: Option[JsValue], target: ElasticServer): Future[ElasticResponse]

def getIndicesStats(target: ElasticServer): Future[ElasticResponse]
}
5 changes: 5 additions & 0 deletions app/elastic/HTTPElasticClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ class HTTPElasticClient @Inject()(client: WSClient) extends ElasticClient {
val path = "/_cat/master"
execute(s"$path?format=json", "GET", None, target)
}

override def getIndicesStats(target: ElasticServer): Future[ElasticResponse] = {
val path = "/_stats/search,get,docs,store,indexing,query_cache"
execute(s"$path", "GET", None, target)
}
}

object HTTPElasticClient {
Expand Down
3 changes: 2 additions & 1 deletion conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ POST /overview/relocate_shard controllers.ClusterOvervie

# Nodes module
POST /nodes controllers.NodesController.index

# Indices module
POST /indices controllers.IndicesController.index
# Navbar module
POST /navbar controllers.NavbarController.index

Expand Down
2 changes: 1 addition & 1 deletion public/css/lib.css

Large diffs are not rendered by default.

96 changes: 96 additions & 0 deletions public/indices_view/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<div class="row">
<div ng-include src="'stats.html'"></div>
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-12 form-group">
<input type="text" ng-model="paginator.filter.index"
class="form-control form-control-sm"
placeholder="filter index">
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 noselect">
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" ng-model="merge">merge
</label>
<label class="checkbox-inline">
<input type="checkbox" ng-model="special">special
</label>
</div>
</div>
<div class="col-md-4">
<ng-pagination page="page" paginator="paginator"></ng-pagination>
</div>
</div>

<table class="table table-bordered">
<thead>
<tr>
<th>
<ng-sort-by property="index" text="Index"></ng-sort-by>
</th>
<th>
<ng-sort-by property="totalSize" text="TotalSize"></ng-sort-by>
</th>
<th>
<ng-sort-by property="totalDocs" text="TotalDocs"></ng-sort-by>
</th>
<th>
<ng-sort-by property="primariesSize" text="PrimariesSize"></ng-sort-by>
</th>
<th>
<ng-sort-by property="primariesDocs" text="PrimariesDocs"></ng-sort-by>
</th>
<th>
<ng-sort-by property="searchCount" text="SearchCount"></ng-sort-by>
</th>
<th>
<ng-sort-by property="getCount" text="GetCount"></ng-sort-by>
</th>
<th>
<ng-sort-by property="queryCount" text="QueryCount"></ng-sort-by>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="index in page.elements track by $index" ng-show="index">
<td>
<div>
<span >{{index.index}}</span>
</div>
</td>
<td>
<div>
<span >{{formatBytes(index.totalSize)}}</span>
</div>
</td>
<td>
<div>
<span >{{renderNum(index.totalDocs)}}</span>
</div>
</td>
<td>
<div>
<span >{{formatBytes(index.primariesSize)}}</span>
</div>
</td>
<td>
<div>
<span >{{renderNum(index.primariesDocs)}}</span>
</div>
</td>
<td>
<div>
<span>{{renderNum(index.searchCount)}}</span>
</div>
</td>
<td>
<div>
<span>{{renderNum(index.getCount)}}</span>
</div>
</td>
<td>
<div>
<span>{{renderNum(index.queryCount)}}</span>
</div>
</td>
</tr>
</tbody>
</table>
Loading