From 1af8da1142f5b6cc98d4ef9bf057c0341fbc6540 Mon Sep 17 00:00:00 2001 From: Leonardo Menezes Date: Wed, 20 May 2020 09:23:53 +0200 Subject: [PATCH] include node attributes in overview and nodes view --- app/models/nodes/Node.scala | 6 ++++++ app/models/overview/Node.scala | 8 +++++++- public/css/app.css | 1 + public/nodes/index.html | 11 +++++++++-- public/overview.html | 15 +++++++++++---- src/app/css/app.css | 1 + test/models/nodes/NodeSpec.scala | 12 ++++++++++-- test/models/nodes/NodesInfo.scala | 10 ++++++++++ .../overview/ClusterInitializingShards.scala | 10 ++++++++++ .../models/overview/ClusterRelocatingShards.scala | 15 +++++++++++++++ test/models/overview/ClusterWithData.scala | 10 ++++++++++ test/models/overview/ClusterWithoutData.scala | 10 ++++++++++ test/models/overview/NodeSpec.scala | 8 ++++++++ test/models/overview/NodesInfo.scala | 10 ++++++++++ 14 files changed, 118 insertions(+), 9 deletions(-) diff --git a/app/models/nodes/Node.scala b/app/models/nodes/Node.scala index 396d271c..9b6d21b7 100644 --- a/app/models/nodes/Node.scala +++ b/app/models/nodes/Node.scala @@ -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 = { @@ -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) } @@ -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 diff --git a/app/models/overview/Node.scala b/app/models/overview/Node.scala index dd95c103..de6c2876 100644 --- a/app/models/overview/Node.scala +++ b/app/models/overview/Node.scala @@ -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) = { @@ -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) diff --git a/public/css/app.css b/public/css/app.css index 493daefc..228e43df 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -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; } diff --git a/public/nodes/index.html b/public/nodes/index.html index 74c5ccf2..ac2cdd5e 100644 --- a/public/nodes/index.html +++ b/public/nodes/index.html @@ -81,9 +81,16 @@ +
+
+ + {{value}} + +
+
- JVM: {{node.jvm}} - ES: {{node.version}} + JVM: {{node.jvm}} + ES: {{node.version}}
diff --git a/public/overview.html b/public/overview.html index ee036ceb..23025481 100644 --- a/public/overview.html +++ b/public/overview.html @@ -230,6 +230,17 @@ +
+
+ + {{value}} + +
+
+
+ JVM: {{node.jvm_version}} + ES: {{node.es_version}} +
-
- JVM: {{node.jvm_version}} - ES: {{node.es_version}} -
diff --git a/src/app/css/app.css b/src/app/css/app.css index 493daefc..228e43df 100755 --- a/src/app/css/app.css +++ b/src/app/css/app.css @@ -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; } diff --git a/test/models/nodes/NodeSpec.scala b/test/models/nodes/NodeSpec.scala index 4476d594..ff16d183 100644 --- a/test/models/nodes/NodeSpec.scala +++ b/test/models/nodes/NodeSpec.scala @@ -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 ) @@ -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 ) diff --git a/test/models/nodes/NodesInfo.scala b/test/models/nodes/NodesInfo.scala index f2e9e864..ea266324 100644 --- a/test/models/nodes/NodesInfo.scala +++ b/test/models/nodes/NodesInfo.scala @@ -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", @@ -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", diff --git a/test/models/overview/ClusterInitializingShards.scala b/test/models/overview/ClusterInitializingShards.scala index 363c2f93..6e817b79 100644 --- a/test/models/overview/ClusterInitializingShards.scala +++ b/test/models/overview/ClusterInitializingShards.scala @@ -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, @@ -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", diff --git a/test/models/overview/ClusterRelocatingShards.scala b/test/models/overview/ClusterRelocatingShards.scala index bcd8a512..8a0725b4 100644 --- a/test/models/overview/ClusterRelocatingShards.scala +++ b/test/models/overview/ClusterRelocatingShards.scala @@ -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, @@ -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, @@ -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", diff --git a/test/models/overview/ClusterWithData.scala b/test/models/overview/ClusterWithData.scala index 3a7a14d0..50880ce8 100644 --- a/test/models/overview/ClusterWithData.scala +++ b/test/models/overview/ClusterWithData.scala @@ -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, @@ -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", diff --git a/test/models/overview/ClusterWithoutData.scala b/test/models/overview/ClusterWithoutData.scala index c0c44f4b..f4756168 100644 --- a/test/models/overview/ClusterWithoutData.scala +++ b/test/models/overview/ClusterWithoutData.scala @@ -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, @@ -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", diff --git a/test/models/overview/NodeSpec.scala b/test/models/overview/NodeSpec.scala index cb5d9fbe..0b269b0f 100644 --- a/test/models/overview/NodeSpec.scala +++ b/test/models/overview/NodeSpec.scala @@ -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 @@ -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 diff --git a/test/models/overview/NodesInfo.scala b/test/models/overview/NodesInfo.scala index dc1530b5..6b807738 100644 --- a/test/models/overview/NodesInfo.scala +++ b/test/models/overview/NodesInfo.scala @@ -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, @@ -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,