From 15c43b73efd475cb04b2c542200afaeb90377e08 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Sat, 3 Aug 2019 12:03:57 +0000 Subject: [PATCH] Add disk space percentage to node listing (#42145) * Add disk space percentage to node listing * Test modification for totalSpace * Fix test mockup * Add totalSpace to fixture * Test fixup * Remove trailing space per review suggestion * More fixture updates * More fixture update * More fixture updates * Update mock * More fixture changes --- .../components/elasticsearch/node_detail_status/index.js | 7 +++++-- .../lib/elasticsearch/nodes/__tests__/get_node_summary.js | 5 ++++- .../server/lib/elasticsearch/nodes/get_node_summary.js | 1 + .../elasticsearch/fixtures/node_detail_advanced.json | 1 + .../apps/monitoring/elasticsearch/node_detail.js | 6 +++--- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js index b9043529c9853..83bdb29406e25 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js +++ b/x-pack/legacy/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js @@ -15,6 +15,7 @@ export function NodeDetailStatus({ stats }) { transport_address: transportAddress, usedHeap, freeSpace, + totalSpace, documents, dataSize, indexCount, @@ -24,6 +25,8 @@ export function NodeDetailStatus({ stats }) { isOnline, } = stats; + const percentSpaceUsed = (freeSpace / totalSpace) * 100; + const metrics = [ { label: i18n.translate('xpack.monitoring.elasticsearch.nodeDetailStatus.transportAddress', { @@ -45,9 +48,9 @@ export function NodeDetailStatus({ stats }) { }, { label: i18n.translate('xpack.monitoring.elasticsearch.nodeDetailStatus.freeDiskSpaceLabel', { - defaultMessage: 'Free Disk Space' + defaultMessage: 'Free Disk Space', }), - value: formatMetric(freeSpace, '0.0 b'), + value: formatMetric(freeSpace, '0.0 b') + ' (' + formatMetric(percentSpaceUsed, '0,0.[00]', '%', { prependSpace: false }) + ')', 'data-test-subj': 'freeDiskSpace' }, { diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/get_node_summary.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/get_node_summary.js index 40904aac2cde0..1df42256482be 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/get_node_summary.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/get_node_summary.js @@ -59,6 +59,7 @@ describe('Elasticsearch Node Summary get_node_summary handleResponse', () => { documents: undefined, dataSize: undefined, freeSpace: undefined, + totalSpace: undefined, usedHeap: undefined, nodeTypeLabel: 'Node', nodeTypeClass: 'fa-server', @@ -108,7 +109,8 @@ describe('Elasticsearch Node Summary get_node_summary handleResponse', () => { }, fs: { total: { - available_in_bytes: 8700 + available_in_bytes: 8700, + total_in_bytes: 10000 } }, jvm: { @@ -135,6 +137,7 @@ describe('Elasticsearch Node Summary get_node_summary handleResponse', () => { documents: 11000, dataSize: 35000, freeSpace: 8700, + totalSpace: 10000, usedHeap: 33, nodeTypeLabel: 'Master Node', nodeTypeClass: 'fa-star', diff --git a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js index a470dbc1f4ad3..c33fea9563f38 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/elasticsearch/nodes/get_node_summary.js @@ -44,6 +44,7 @@ export function handleResponse(clusterState, shardStats, nodeUuid) { documents: get(sourceStats, 'indices.docs.count'), dataSize: get(sourceStats, 'indices.store.size_in_bytes'), freeSpace: get(sourceStats, 'fs.total.available_in_bytes'), + totalSpace: get(sourceStats, 'fs.total.total_in_bytes'), usedHeap: get(sourceStats, 'jvm.mem.heap_used_percent'), status: i18n.translate('xpack.monitoring.es.nodes.onlineStatusLabel', { defaultMessage: 'Online' }), diff --git a/x-pack/test/api_integration/apis/monitoring/elasticsearch/fixtures/node_detail_advanced.json b/x-pack/test/api_integration/apis/monitoring/elasticsearch/fixtures/node_detail_advanced.json index a0e3cae496db3..f84d0c73bed07 100644 --- a/x-pack/test/api_integration/apis/monitoring/elasticsearch/fixtures/node_detail_advanced.json +++ b/x-pack/test/api_integration/apis/monitoring/elasticsearch/fixtures/node_detail_advanced.json @@ -16,6 +16,7 @@ "documents": 24830, "dataSize": 52847579, "freeSpace": 186755088384, + "totalSpace": 499065712640, "usedHeap": 29, "status": "Online", "isOnline": true diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js index 46fdd8d3921a3..eeaf214ded517 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js @@ -42,7 +42,7 @@ export default function ({ getService, getPageObjects }) { expect(await nodeDetail.getSummary()).to.eql({ transportAddress: 'Transport Address\n127.0.0.1:9300', jvmHeap: 'JVM Heap\n29%', - freeDiskSpace: 'Free Disk Space\n173.9 GB', + freeDiskSpace: 'Free Disk Space\n173.9 GB (37.42%)', documentCount: 'Documents\n24.8k', dataSize: 'Data\n50.4 MB', indicesCount: 'Indices\n20', @@ -58,7 +58,7 @@ export default function ({ getService, getPageObjects }) { expect(await nodeDetail.getSummary()).to.eql({ transportAddress: 'Transport Address\n127.0.0.1:9302', jvmHeap: 'JVM Heap\n17%', - freeDiskSpace: 'Free Disk Space\n173.9 GB', + freeDiskSpace: 'Free Disk Space\n173.9 GB (37.42%)', documentCount: 'Documents\n240', dataSize: 'Data\n1.4 MB', indicesCount: 'Indices\n4', @@ -93,7 +93,7 @@ export default function ({ getService, getPageObjects }) { expect(await nodeDetail.getSummary()).to.eql({ transportAddress: 'Transport Address\n127.0.0.1:9302', jvmHeap: 'JVM Heap\nN/A', - freeDiskSpace: 'Free Disk Space\nN/A', + freeDiskSpace: 'Free Disk Space\nN/A (N/A)', documentCount: 'Documents\nN/A', dataSize: 'Data\nN/A', indicesCount: 'Indices\nN/A',