Skip to content

Commit

Permalink
include node attributes in overview and nodes view
Browse files Browse the repository at this point in the history
  • Loading branch information
lmenezes committed May 20, 2020
1 parent 5b1239d commit 1af8da1
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 9 deletions.
6 changes: 6 additions & 0 deletions app/models/nodes/Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package models.nodes
import models.commons.NodeRoles
import play.api.libs.json._

import scala.collection.Map

object Node {

def apply(id: String, currentMaster: Boolean, info: JsValue, stats: JsValue): JsValue = {
Expand All @@ -18,6 +20,7 @@ object Node {
"cpu" -> cpu(stats),
"uptime" -> (stats \ "jvm" \ "uptime_in_millis").as[JsValue],
"jvm" -> jvmVersion,
"attributes" -> attrs(info),
"version" -> (info \ "version").as[JsValue]
) ++ roles(info)
}
Expand All @@ -32,6 +35,9 @@ object Node {
)
}

def attrs(info: JsValue): Map[String, JsValue] =
(info \ "attributes").as[JsObject].value.filterKeys(_ != "xpack.installed")

private def cpu(stats: JsValue): JsValue = {
val load = (stats \ "os" \ "cpu" \ "load_average" \ "1m").asOpt[JsValue].getOrElse(// 5.X
(stats \ "os" \ "load_average").asOpt[JsValue].getOrElse(JsNull) // FIXME: 2.X
Expand Down
8 changes: 7 additions & 1 deletion app/models/overview/Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package models.overview
import models.commons.NodeRoles
import play.api.libs.json._

import scala.collection.Map

object Node {

def apply(id: String, info: JsValue, stats: JsValue, masterNodeId: String) = {
Expand Down Expand Up @@ -35,10 +37,14 @@ object Node {
"used_percent" -> (stats \ "jvm" \ "mem" \ "heap_used_percent").as[JsNumber],
"max" -> (stats \ "jvm" \ "mem" \ "heap_max_in_bytes").as[JsNumber]
),
"disk" -> disk(stats)
"disk" -> disk(stats),
"attributes" -> attrs(info)
)
}

def attrs(info: JsValue): Map[String, JsValue] =
(info \ "attributes").as[JsObject].value.filterKeys(_ != "xpack.installed")

def disk(stats: JsValue): JsObject = {
val totalInBytes = (stats \ "fs" \ "total" \ "total_in_bytes").asOpt[Long].getOrElse(0l)
val freeInBytes = (stats \ "fs" \ "total" \ "free_in_bytes").asOpt[Long].getOrElse(0l)
Expand Down
1 change: 1 addition & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ table.shard-map { table-layout: fixed; }
.stat-description { font-size: 12px; font-weight: 300; }

/** node cells **/
.node-attrs { overflow: hidden; text-overflow: ellipsis; }
.node-badges { width: 20px; display: inline-block; float: left; }
.node-info { margin-left: 20px; }
.node-labels { padding-top: 5px; }
Expand Down
11 changes: 9 additions & 2 deletions public/nodes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 node-attrs">
<span ng-repeat="(attr, value) in node.attributes">
<span class="label label-success">{{value}}</span>
</span>
</div>
</div>
<div class="node-labels">
<span class="label label-details" ng-show="node.jvm">JVM: {{node.jvm}}</span>
<span class="label label-details">ES: {{node.version}}</span>
<span class="label label-primary" ng-show="node.jvm">JVM: {{node.jvm}}</span>
<span class="label label-primary">ES: {{node.version}}</span>
</div>
</td>
<td>
Expand Down
15 changes: 11 additions & 4 deletions public/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 node-attrs">
<span ng-repeat="(attr, value) in node.attributes">
<span class="label label-success">{{value}}</span>
</span>
</div>
</div>
<div ng-show="expandedView" class="node-labels">
<span class="label label-primary">JVM: {{node.jvm_version}}</span>
<span class="label label-primary">ES: {{node.es_version}}</span>
</div>
<div class="row row-condensed">
<div class="col-lg-3 col-condensed">
<ng-progress
Expand Down Expand Up @@ -264,10 +275,6 @@
/>
</div>
</div>
<div ng-show="expandedView" class="node-labels">
<span class="label label-details">JVM: {{node.jvm_version}}</span>
<span class="label label-details">ES: {{node.es_version}}</span>
</div>
</td>
<td ng-repeat="index in page.elements track by $index">
<span ng-repeat="shard in index.shards[node.id] | orderBy:'shard' track by $index">
Expand Down
1 change: 1 addition & 0 deletions src/app/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ table.shard-map { table-layout: fixed; }
.stat-description { font-size: 12px; font-weight: 300; }

/** node cells **/
.node-attrs { overflow: hidden; text-overflow: ellipsis; }
.node-badges { width: 20px; display: inline-block; float: left; }
.node-info { margin-left: 20px; }
.node-labels { padding-top: 5px; }
Expand Down
12 changes: 10 additions & 2 deletions test/models/nodes/NodeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ object NodeSpec extends Specification {
| "name": "-qkZcMt",
| "uptime": 109228,
| "version": "5.1.1",
| "host": "127.0.0.1"
| "host": "127.0.0.1",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm"
| }
|}
""".stripMargin
)
Expand Down Expand Up @@ -79,7 +83,11 @@ object NodeSpec extends Specification {
| "name": "007ywNv",
| "uptime": 492790575,
| "version": "5.1.1",
| "host": null
| "host": null,
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm"
| }
|}
""".stripMargin
)
Expand Down
10 changes: 10 additions & 0 deletions test/models/nodes/NodesInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ object NodesInfo {
| "build_hash": "5395e21",
| "host": "127.0.0.1",
| "ip": "127.0.0.1",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "jvm": {
| "gc_collectors": [
| "ParNew",
Expand Down Expand Up @@ -69,6 +74,11 @@ object NodesInfo {
"""
|{
| "build_hash": "5395e21",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "jvm": {
| "mem": {
| "direct_max": "1.9gb",
Expand Down
10 changes: 10 additions & 0 deletions test/models/overview/ClusterInitializingShards.scala
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ object ClusterInitializingShards {
| "version" : "2.1.0",
| "build" : "72cd1f1",
| "http_address" : "127.0.0.1:9201",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os" : {
| "refresh_interval_in_millis" : 1000,
| "available_processors" : 8,
Expand Down Expand Up @@ -536,6 +541,11 @@ object ClusterInitializingShards {
| "version" : "2.1.0",
| "build" : "72cd1f1",
| "http_address" : "127.0.0.1:9200",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os" : {
| "refresh_interval_in_millis" : 1000,
| "name" : "Mac OS X",
Expand Down
15 changes: 15 additions & 0 deletions test/models/overview/ClusterRelocatingShards.scala
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ object ClusterRelocatingShards extends ClusterStub {
| "version" : "2.1.0",
| "build" : "72cd1f1",
| "http_address" : "127.0.0.1:9201",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os" : {
| "refresh_interval_in_millis" : 1000,
| "available_processors" : 8,
Expand Down Expand Up @@ -632,6 +637,11 @@ object ClusterRelocatingShards extends ClusterStub {
| "version" : "2.1.0",
| "build" : "72cd1f1",
| "http_address" : "127.0.0.1:9202",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os" : {
| "refresh_interval_in_millis" : 1000,
| "available_processors" : 8,
Expand Down Expand Up @@ -663,6 +673,11 @@ object ClusterRelocatingShards extends ClusterStub {
| "version" : "2.1.0",
| "build" : "72cd1f1",
| "http_address" : "127.0.0.1:9200",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os" : {
| "refresh_interval_in_millis" : 1000,
| "name" : "Mac OS X",
Expand Down
10 changes: 10 additions & 0 deletions test/models/overview/ClusterWithData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@ trait ClusterWithData extends ClusterStub {
| "version": "2.1.0",
| "build": "72cd1f1",
| "http_address": "127.0.0.1:9201",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os": {
| "refresh_interval_in_millis": 1000,
| "available_processors": 8,
Expand Down Expand Up @@ -559,6 +564,11 @@ trait ClusterWithData extends ClusterStub {
| "version": "2.1.0",
| "build": "72cd1f1",
| "http_address": "127.0.0.1:9200",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os": {
| "refresh_interval_in_millis": 1000,
| "name": "Mac OS X",
Expand Down
10 changes: 10 additions & 0 deletions test/models/overview/ClusterWithoutData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ object ClusterWithoutData extends ClusterStub {
| "version":"2.1.0",
| "build":"72cd1f1",
| "http_address":"127.0.0.1:9201",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os":{
| "refresh_interval_in_millis":1000,
| "available_processors":8,
Expand Down Expand Up @@ -388,6 +393,11 @@ object ClusterWithoutData extends ClusterStub {
| "version":"2.1.0",
| "build":"72cd1f1",
| "http_address":"127.0.0.1:9200",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os":{
| "refresh_interval_in_millis":1000,
| "name":"Mac OS X",
Expand Down
8 changes: 8 additions & 0 deletions test/models/overview/NodeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ object NodeSpec extends Specification {
| "total": 249804886016,
| "free": 41567444992,
| "used_percent": 84
| },
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm"
| }
|}
""".stripMargin
Expand Down Expand Up @@ -77,6 +81,10 @@ object NodeSpec extends Specification {
| "total": 249804886016,
| "free": 41567444992,
| "used_percent": 84
| },
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm"
| }
|}
""".stripMargin
Expand Down
10 changes: 10 additions & 0 deletions test/models/overview/NodesInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ object NodesInfo {
| "version":"2.1.0",
| "build":"72cd1f1",
| "http_address":"127.0.0.1:9201",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os":{
| "refresh_interval_in_millis":1000,
| "available_processors":8,
Expand Down Expand Up @@ -56,6 +61,11 @@ object NodesInfo {
| "name":"Solara",
| "version":"2.1.0",
| "build":"72cd1f1",
| "attributes": {
| "aws_availability_zone": "eu-west-1c",
| "node_type": "warm",
| "xpack.installed": "true"
| },
| "os":{
| "refresh_interval_in_millis":1000,
| "available_processors":8,
Expand Down

0 comments on commit 1af8da1

Please sign in to comment.