Skip to content

Commit c65e781

Browse files
[Monitoring] Fix issue with ES node detail status (#72298) (#72349)
* Fix issue with ES node detail status * Add test Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent f519176 commit c65e781

File tree

7 files changed

+92
-6
lines changed

7 files changed

+92
-6
lines changed

x-pack/plugins/monitoring/public/alerts/status.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ interface Props {
2020
export const AlertsStatus: React.FC<Props> = (props: Props) => {
2121
const { alerts, showBadge = false, showOnlyCount = false } = props;
2222

23+
if (!alerts) {
24+
return null;
25+
}
26+
2327
let atLeastOneDanger = false;
2428
const count = Object.values(alerts).reduce((cnt, alertStatus) => {
2529
if (alertStatus.states.length) {

x-pack/plugins/monitoring/public/components/elasticsearch/node/advanced.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { NodeDetailStatus } from '../node_detail_status';
1818
import { MonitoringTimeseriesContainer } from '../../chart';
1919

20-
export const AdvancedNode = ({ nodeSummary, metrics, ...props }) => {
20+
export const AdvancedNode = ({ nodeSummary, metrics, alerts, ...props }) => {
2121
const metricsToShow = [
2222
metrics.node_gc,
2323
metrics.node_gc_time,
@@ -40,7 +40,7 @@ export const AdvancedNode = ({ nodeSummary, metrics, ...props }) => {
4040
<EuiPage>
4141
<EuiPageBody>
4242
<EuiPanel>
43-
<NodeDetailStatus stats={nodeSummary} />
43+
<NodeDetailStatus stats={nodeSummary} alerts={alerts} />
4444
</EuiPanel>
4545
<EuiSpacer size="m" />
4646
<EuiPageContent>

x-pack/plugins/monitoring/public/components/elasticsearch/node_detail_status/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import { SummaryStatus } from '../../summary_status';
99
import { NodeStatusIcon } from '../node';
1010
import { formatMetric } from '../../../lib/format_number';
1111
import { i18n } from '@kbn/i18n';
12+
import { AlertsStatus } from '../../../alerts/status';
1213

13-
export function NodeDetailStatus({ stats, alerts }) {
14+
export function NodeDetailStatus({ stats, alerts = {} }) {
1415
const {
1516
transport_address: transportAddress,
1617
usedHeap,
@@ -29,8 +30,10 @@ export function NodeDetailStatus({ stats, alerts }) {
2930

3031
const metrics = [
3132
{
32-
label: 'Alerts',
33-
value: <span>{Object.values(alerts).length}</span>,
33+
label: i18n.translate('xpack.monitoring.elasticsearch.nodeDetailStatus.alerts', {
34+
defaultMessage: 'Alerts',
35+
}),
36+
value: <AlertsStatus alerts={alerts} showOnlyCount={true} />,
3437
},
3538
{
3639
label: i18n.translate('xpack.monitoring.elasticsearch.nodeDetailStatus.transportAddress', {

x-pack/plugins/monitoring/public/directives/main/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
</a>
9191
<a
9292
ng-if="monitoringMain.instance && (monitoringMain.name === 'nodes' || monitoringMain.name === 'indices')"
93+
data-test-subj="esNodeDetailAdvancedLink"
9394
kbn-href="#/elasticsearch/{{ monitoringMain.name }}/{{ monitoringMain.resolver }}/advanced"
9495
class="euiTab"
9596
ng-class="{'euiTab-isSelected': monitoringMain.page === 'advanced'}"

x-pack/plugins/monitoring/public/views/elasticsearch/node/advanced/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import template from './index.html';
1616
import { Legacy } from '../../../../legacy_shims';
1717
import { AdvancedNode } from '../../../../components/elasticsearch/node/advanced';
1818
import { MonitoringViewBaseController } from '../../../base_controller';
19-
import { CODE_PATH_ELASTICSEARCH } from '../../../../../common/constants';
19+
import { CODE_PATH_ELASTICSEARCH, ALERT_CPU_USAGE } from '../../../../../common/constants';
2020

2121
function getPageData($injector) {
2222
const $http = $injector.get('$http');
@@ -53,12 +53,26 @@ uiRoutes.when('/elasticsearch/nodes/:node/advanced', {
5353
},
5454
controller: class extends MonitoringViewBaseController {
5555
constructor($injector, $scope) {
56+
const $route = $injector.get('$route');
57+
const nodeName = $route.current.params.node;
58+
5659
super({
5760
defaultData: {},
5861
getPageData,
5962
reactNodeId: 'monitoringElasticsearchAdvancedNodeApp',
6063
$scope,
6164
$injector,
65+
alerts: {
66+
shouldFetch: true,
67+
options: {
68+
alertTypeIds: [ALERT_CPU_USAGE],
69+
filters: [
70+
{
71+
nodeUuid: nodeName,
72+
},
73+
],
74+
},
75+
},
6276
});
6377

6478
$scope.$watch(
@@ -80,6 +94,7 @@ uiRoutes.when('/elasticsearch/nodes/:node/advanced', {
8094
this.renderReact(
8195
<AdvancedNode
8296
nodeSummary={data.nodeSummary}
97+
alerts={this.alerts}
8398
metrics={data.metrics}
8499
onBrush={this.onBrush}
85100
zoomInfo={this.zoomInfo}

x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,64 @@ export default function ({ getService, getPageObjects }) {
103103
});
104104
});
105105
});
106+
107+
describe('Advanced', () => {
108+
describe('Active Nodes', () => {
109+
const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects);
110+
111+
before(async () => {
112+
await setup('monitoring/singlecluster-three-nodes-shard-relocation', {
113+
from: 'Oct 5, 2017 @ 20:31:48.354',
114+
to: 'Oct 5, 2017 @ 20:35:12.176',
115+
});
116+
117+
// go to nodes listing
118+
await overview.clickEsNodes();
119+
expect(await nodesList.isOnListing()).to.be(true);
120+
});
121+
122+
after(async () => {
123+
await tearDown();
124+
});
125+
126+
afterEach(async () => {
127+
await PageObjects.monitoring.clickBreadcrumb('~breadcrumbEsNodes'); // return back for next test
128+
});
129+
130+
it('should show node summary of master node with 20 indices and 38 shards', async () => {
131+
await nodesList.clickRowByResolver('jUT5KdxfRbORSCWkb5zjmA');
132+
await nodeDetail.clickAdvanced();
133+
134+
expect(await nodeDetail.getSummary()).to.eql({
135+
transportAddress: 'Transport Address\n127.0.0.1:9300',
136+
jvmHeap: 'JVM Heap\n29%',
137+
freeDiskSpace: 'Free Disk Space\n173.9 GB (37.42%)',
138+
documentCount: 'Documents\n24.8k',
139+
dataSize: 'Data\n50.4 MB',
140+
indicesCount: 'Indices\n20',
141+
shardsCount: 'Shards\n38',
142+
nodeType: 'Type\nMaster Node',
143+
status: 'Status: Online',
144+
});
145+
});
146+
147+
it('should show node summary of data node with 4 indices and 4 shards', async () => {
148+
await nodesList.clickRowByResolver('bwQWH-7IQY-mFPpfoaoFXQ');
149+
await nodeDetail.clickAdvanced();
150+
151+
expect(await nodeDetail.getSummary()).to.eql({
152+
transportAddress: 'Transport Address\n127.0.0.1:9302',
153+
jvmHeap: 'JVM Heap\n17%',
154+
freeDiskSpace: 'Free Disk Space\n173.9 GB (37.42%)',
155+
documentCount: 'Documents\n240',
156+
dataSize: 'Data\n1.4 MB',
157+
indicesCount: 'Indices\n4',
158+
shardsCount: 'Shards\n4',
159+
nodeType: 'Type\nNode',
160+
status: 'Status: Online',
161+
});
162+
});
163+
});
164+
});
106165
});
107166
}

x-pack/test/functional/services/monitoring/elasticsearch_node_detail.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export function MonitoringElasticsearchNodeDetailProvider({ getService }) {
1919
const SUBJ_SUMMARY_STATUS = `${SUBJ_SUMMARY} > statusIcon`;
2020

2121
return new (class ElasticsearchNodeDetail {
22+
async clickAdvanced() {
23+
return testSubjects.click('esNodeDetailAdvancedLink');
24+
}
25+
2226
async getSummary() {
2327
return {
2428
transportAddress: await testSubjects.getVisibleText(SUBJ_SUMMARY_TRANSPORT_ADDRESS),

0 commit comments

Comments
 (0)