[6.4] [Monitoring/React] Logstash cluster status bars in react (#19433) (#25663)

* Cherry-pick 6760a64c3d

* Fix tests

* No newlines
This commit is contained in:
Chris Roberson 2018-11-16 16:25:37 -05:00 committed by GitHub
parent e6f513e3ce
commit 39fcc6cdaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 159 additions and 64 deletions

View file

@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { SummaryStatus } from '../../summary_status';
import { formatMetric } from '../../../lib/format_number';
export function ClusterStatus({ stats }) {
const {
node_count: nodeCount,
avg_memory_used: avgMemoryUsed,
avg_memory: avgMemory,
events_in_total: eventsInTotal,
events_out_total: eventsOutTotal
} = stats;
const metrics = [
{
label: 'Nodes',
value: nodeCount,
dataTestSubj: 'node_count'
},
{
label: 'Memory',
value: formatMetric(avgMemoryUsed, 'byte') + ' / ' + formatMetric(avgMemory, 'byte'),
dataTestSubj: 'memory_used'
},
{
label: 'Events Received',
value: formatMetric(eventsInTotal, '0.[0]a'),
dataTestSubj: 'events_in_total'
},
{
label: 'Events Emitted',
value: formatMetric(eventsOutTotal, '0.[0]a'),
dataTestSubj: 'events_out_total'
}
];
return (
<SummaryStatus
metrics={metrics}
data-test-subj="logstashClusterStatus"
/>
);
}

View file

@ -0,0 +1,84 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { SummaryStatus } from '../../summary_status';
import { formatMetric } from '../../../lib/format_number';
export function DetailStatus({ stats }) {
const {
http_address: httpAddress,
events,
reloads,
pipeline,
queue_type: queueType,
version,
uptime
} = stats;
const firstMetrics = [
{
value: httpAddress,
dataTestSubj: 'httpAddress'
},
{
label: 'Events Received',
value: formatMetric(events.in, '0.[0]a'),
dataTestSubj: 'eventsIn'
},
{
label: 'Events Emitted',
value: formatMetric(events.out, '0.[0]a'),
dataTestSubj: 'eventsOut'
},
{
label: 'Config Reloads',
value: reloads.successes,
dataTestSubj: 'numReloads'
},
{
label: 'Pipeline Workers',
value: pipeline.workers,
dataTestSubj: 'pipelineWorkers'
},
{
label: 'Batch Size',
value: pipeline.batch_size,
dataTestSubj: 'pipelineBatchSize'
}
];
const lastMetrics = [
{
label: 'Version',
value: version,
dataTestSubj: 'version'
},
{
label: 'Uptime',
value: formatMetric(uptime, 'time_since'),
dataTestSubj: 'uptime'
}
];
// make queueType conditional
const metrics = [...firstMetrics];
if (queueType) {
metrics.push({
label: 'Queue Type',
value: queueType,
dataTestSubj: 'queueType'
});
}
metrics.push(...lastMetrics);
return (
<SummaryStatus
metrics={metrics}
data-test-subj="logstashDetailStatus"
/>
);
}

View file

@ -1,19 +0,0 @@
<div class="monitoring-summary-status" role="status">
<div
class="monitoring-summary-status__content"
data-test-subj="logstashSummaryStatus"
>
<div>Nodes:
<strong data-test-subj="node_count">{{ status.node_count }}</strong>
</div>
<div>Memory:
<strong data-test-subj="memory_used">{{ status.avg_memory_used|formatNumber:'byte' }} / {{ status.avg_memory|formatNumber:'byte' }}</strong>
</div>
<div>Events Received:
<strong data-test-subj="events_in_total">{{ status.events_in_total|formatNumber:'0.[0]a' }}</strong>
</div>
<div>Events Emitted:
<strong data-test-subj="events_out_total">{{ status.events_out_total|formatNumber:'0.[0]a' }}</strong>
</div>
</div>
</div>

View file

@ -4,16 +4,22 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { render } from 'react-dom';
import { uiModules } from 'ui/modules';
import template from './index.html';
import { ClusterStatus } from 'plugins/monitoring/components/logstash/cluster_status';
const uiModule = uiModules.get('monitoring/directives', []);
uiModule.directive('monitoringClusterStatusLogstash', () => {
return {
restrict: 'E',
template,
scope: {
status: '='
},
link(scope, $el) {
scope.$watch('status', status => {
render(<ClusterStatus stats={status} />, $el[0]);
});
}
};
});

View file

@ -1,31 +0,0 @@
<div class="monitoring-summary-status" role="status">
<div class="monitoring-summary-status__content">
<div>
<strong data-test-subj="httpAddress">{{ logstash.http_address }}</strong>
</div>
<div>Events Received:
<strong data-test-subj="eventsIn">{{ logstash.events.in|formatNumber:'0.[0]a' }}</strong>
</div>
<div>Events Emitted:
<strong data-test-subj="eventsOut">{{ logstash.events.out|formatNumber:'0.[0]a' }}</strong>
</div>
<div>Config Reloads:
<strong data-test-subj="numReloads">{{ logstash.reloads.successes }}</strong>
</div>
<div>Pipeline Workers:
<strong data-test-subj="pipelineWorkers">{{ logstash.pipeline.workers }}</strong>
</div>
<div>Batch Size:
<strong data-test-subj="pipelineBatchSize">{{ logstash.pipeline.batch_size }}</strong>
</div>
<div ng-show="logstash.queue_type">Queue Type:
<strong data-test-subj="queueType">{{ logstash.queue_type }}</strong>
</div>
<div>Logstash:
<strong data-test-subj="version">{{ logstash.version }}</strong>
</div>
<div>Uptime:
<strong data-test-subj="uptime">{{ logstash.uptime|formatNumber:'time_since' }}</strong>
</div>
</div>
</div>

View file

@ -4,16 +4,22 @@
* you may not use this file except in compliance with the Elastic License.
*/
import template from './index.html';
import React from 'react';
import { render } from 'react-dom';
import { uiModules } from 'ui/modules';
import { DetailStatus } from 'plugins/monitoring/components/logstash/detail_status';
const uiModule = uiModules.get('monitoring/directives', []);
uiModule.directive('monitoringLogstashNodeSummary', () => {
return {
restrict: 'E',
template: template,
scope: {
logstash: '='
},
link(scope, $el) {
scope.$watch('logstash', logstash => {
render(<DetailStatus stats={logstash} />, $el[0]);
});
}
};
});

View file

@ -30,16 +30,16 @@ export default function ({ getService, getPageObjects }) {
await tearDown();
});
it('Logstash Cluster Summary Status shows correct info', async () => {
it('should have Logstash Cluster Summary Status showing correct info', async () => {
expect(await lsClusterSummaryStatus.getContent()).to.eql({
nodeCount: '2',
memoryUsed: '528.4 MB / 1.9 GB',
eventsInTotal: '117.9k',
eventsOutTotal: '111.9k'
nodeCount: 'Nodes: 2',
memoryUsed: 'Memory: 528.4 MB / 1.9 GB',
eventsInTotal: 'Events Received: 117.9k',
eventsOutTotal: 'Events Emitted: 111.9k'
});
});
it('Pipelines table shows correct rows with default sorting', async () => {
it('should have Pipelines table showing correct rows with default sorting', async () => {
const rows = await pipelinesList.getRows();
expect(rows.length).to.be(4);
@ -60,7 +60,7 @@ export default function ({ getService, getPageObjects }) {
});
});
it('Pipelines Table shows correct rows after sorting by Events Emitted Rate Asc', async () => {
it('should have Pipelines Table showing correct rows after sorting by Events Emitted Rate Asc', async () => {
await pipelinesList.clickEventsEmittedRateCol();
const rows = await pipelinesList.getRows();
@ -83,14 +83,14 @@ export default function ({ getService, getPageObjects }) {
});
});
it('filters for specific pipelines', async () => {
it('should filter for specific pipelines', async () => {
await pipelinesList.setFilter('la');
const rows = await pipelinesList.getRows();
expect(rows.length).to.be(2);
await pipelinesList.clearFilter();
});
it('filters for non-existent pipeline', async () => {
it('should filter for non-existent pipeline', async () => {
await pipelinesList.setFilter('foobar');
await pipelinesList.assertNoData();
await pipelinesList.clearFilter();

View file

@ -7,7 +7,7 @@
export function MonitoringLogstashSummaryStatusProvider({ getService }) {
const testSubjects = getService('testSubjects');
const SUBJ_SUMMARY = 'logstashSummaryStatus';
const SUBJ_SUMMARY = 'logstashClusterStatus';
const SUBJ_SUMMARY_NODE_COUNT = `${SUBJ_SUMMARY} node_count`;
const SUBJ_SUMMARY_MEMORY_USED = `${SUBJ_SUMMARY} memory_used`;
const SUBJ_SUMMARY_EVENTS_IN_TOTAL = `${SUBJ_SUMMARY} events_in_total`;