Skip to content

Commit

Permalink
[Monitoring] Fixing issue with EUI table filtering in monitoring UI (#…
Browse files Browse the repository at this point in the history
…27504)

* Ensure the schema is set

* Flatten certain table data lists to ensure the default field filtering works

* Fix issue with tests

* Fix issue with sort key name

* Readd localization that was removed
  • Loading branch information
chrisronline authored Jan 9, 2019
1 parent 22877eb commit 1e9bd95
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 50 deletions.
14 changes: 10 additions & 4 deletions x-pack/plugins/monitoring/public/components/alerts/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const linkToCategories = {
const getColumns = (kbnUrl, scope) => ([
{
name: 'Status',
field: 'metadata.severity',
field: 'status',
sortable: true,
render: severity => {
const severityIcon = mapSeverity(severity);
Expand Down Expand Up @@ -82,7 +82,7 @@ const getColumns = (kbnUrl, scope) => ([
},
{
name: 'Category',
field: 'metadata.link',
field: 'category',
sortable: true,
render: link => linkToCategories[link] ? linkToCategories[link] : 'General'
},
Expand All @@ -101,16 +101,22 @@ const getColumns = (kbnUrl, scope) => ([
]);

const AlertsUI = ({ alerts, angular, sorting, pagination, onTableChange, intl }) => {
const alertsFlattened = alerts.map(alert => ({
...alert,
status: alert.metadata.severity,
category: alert.metadata.link,
}));

return (
<EuiMonitoringTable
className="alertsTable"
rows={alerts}
rows={alertsFlattened}
columns={getColumns(angular.kbnUrl, angular.scope)}
sorting={{
...sorting,
sort: {
...sorting.sort,
field: 'metadata.severity',
field: 'status',
direction: EUI_SORT_DESCENDING,
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ import { EuiPage, EuiLink, EuiPageBody, EuiPageContent, EuiSpacer } from '@elast
import { formatPercentageUsage, formatNumber } from '../../../lib/format_number';
import { ClusterStatus } from '..//cluster_status';
import { EuiMonitoringTable } from '../../table';
import { injectI18n } from '@kbn/i18n/react';
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

class ListingUI extends PureComponent {
getColumns() {
const { kbnUrl, scope } = this.props.angular;

return [
{
name: 'Name',
field: 'logstash.name',
name: i18n.translate('xpack.monitoring.logstash.nodes.nameTitle', {
defaultMessage: 'Name'
}),
field: 'name',
sortable: true,
render: (name, node) => (
<div>
Expand All @@ -40,42 +43,67 @@ class ListingUI extends PureComponent {
)
},
{
name: 'CPU Usage',
field: 'process.cpu.percent',
name: i18n.translate('xpack.monitoring.logstash.nodes.cpuUsageTitle', {
defaultMessage: 'CPU Usage'
}),
field: 'cpu_usage',
sortable: true,
render: value => formatPercentageUsage(value, 100)
},
{
name: 'Load Average',
field: 'os.cpu.load_average.1m',
name: i18n.translate('xpack.monitoring.logstash.nodes.loadAverageTitle', {
defaultMessage: 'Load Average'
}),
field: 'load_average',
sortable: true,
render: value => formatNumber(value, '0.00')
},
{
name: 'JVM Heap Used',
field: 'jvm.mem.heap_used_percent',
name: i18n.translate('xpack.monitoring.logstash.nodes.jvmHeapUsedTitle', {
defaultMessage: '{javaVirtualMachine} Heap Used',
values: { javaVirtualMachine: 'JVM' }
}),
field: 'jvm_heap_used',
sortable: true,
render: value => formatPercentageUsage(value, 100)
},
{
name: 'Events Ingested',
field: 'events.out',
name: i18n.translate('xpack.monitoring.logstash.nodes.eventsIngestedTitle', {
defaultMessage: 'Events Ingested'
}),
field: 'events_out',
sortable: true,
render: value => formatNumber(value, '0.[0]a')
},
{
name: 'Config Reloads',
name: i18n.translate('xpack.monitoring.logstash.nodes.configReloadsTitle', {
defaultMessage: 'Config Reloads'
}),
sortable: true,
render: node => (
<div>
<div>{ node.reloads.successes } successes</div>
<div>{ node.reloads.failures } failures</div>
<div>
<FormattedMessage
id="xpack.monitoring.logstash.nodes.configReloadsSuccessCountLabel"
defaultMessage="{reloadsSuccesses} successes"
values={{ reloadsSuccesses: node.reloads.successes }}
/>
</div>
<div>
<FormattedMessage
id="xpack.monitoring.logstash.nodes.configReloadsFailuresCountLabel"
defaultMessage="{reloadsFailures} failures"
values={{ reloadsFailures: node.reloads.failures }}
/>
</div>
</div>
)
},
{
name: 'Version',
field: 'logstash.version',
name: i18n.translate('xpack.monitoring.logstash.nodes.versionTitle', {
defaultMessage: 'Version'
}),
field: 'version',
sortable: true,
render: value => formatNumber(value)
}
Expand All @@ -84,6 +112,15 @@ class ListingUI extends PureComponent {
render() {
const { data, stats, sorting, pagination, onTableChange, intl } = this.props;
const columns = this.getColumns();
const flattenedData = data.map(item => ({
...item,
name: item.logstash.name,
cpu_usage: item.process.cpu.percent,
load_average: item.os.cpu.load_average['1m'],
jvm_heap_used: item.jvm.mem.heap_used_percent,
events_ingested: item.events.out,
version: item.logstash.version,
}));

return (
<EuiPage>
Expand All @@ -93,13 +130,13 @@ class ListingUI extends PureComponent {
<EuiSpacer size="m"/>
<EuiMonitoringTable
className="logstashNodesTable"
rows={data}
rows={flattenedData}
columns={columns}
sorting={{
...sorting,
sort: {
...sorting.sort,
field: 'logstash.name'
field: 'name'
}
}}
pagination={pagination}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export class EuiMonitoringTable extends React.PureComponent {
search.box['data-test-subj'] = 'monitoringTableToolBar';
}

if (search.box && !search.box.schema) {
search.box.schema = true;
}

const columns = _columns.map(column => {
if (!column['data-test-subj']) {
column['data-test-subj'] = 'monitoringTableHasData';
Expand Down
44 changes: 16 additions & 28 deletions x-pack/plugins/monitoring/public/views/kibana/instances/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

import React from 'react';
import { render } from 'react-dom';
import { find, capitalize } from 'lodash';
import { capitalize } from 'lodash';
import uiRoutes from'ui/routes';
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
import { MonitoringViewBaseEuiTableController } from '../../';
Expand All @@ -25,7 +24,7 @@ const getColumns = (kbnUrl, scope) => ([
name: i18n.translate('xpack.monitoring.kibana.listing.nameColumnTitle', {
defaultMessage: 'Name'
}),
field: 'kibana.name',
field: 'name',
render: (name, kibana) => (
<EuiLink
onClick={() => {
Expand All @@ -43,7 +42,7 @@ const getColumns = (kbnUrl, scope) => ([
name: i18n.translate('xpack.monitoring.kibana.listing.statusColumnTitle', {
defaultMessage: 'Status'
}),
field: 'kibana.status',
field: 'status',
render: (status, kibana) => (
<div
title={`Instance status: ${status}`}
Expand Down Expand Up @@ -127,25 +126,25 @@ uiRoutes.when('/kibana/instances', {
title: 'Kibana Instances',
storageKey: 'kibana.instances',
getPageData,
reactNodeId: 'monitoringKibanaInstancesApp',
$scope,
$injector
});

const $route = $injector.get('$route');
this.data = $route.current.locals.pageData;
const globalState = $injector.get('globalState');
$scope.cluster = find($route.current.locals.clusters, { cluster_uuid: globalState.cluster_uuid });
$scope.pageData = $route.current.locals.pageData;

const kbnUrl = $injector.get('kbnUrl');

const renderReact = () => {
const app = document.getElementById('monitoringKibanaInstancesApp');
if (!app) {
$scope.$watch(() => this.data, data => {
if (!data || !data.kibanas) {
return;
}

const page = (
const dataFlattened = data.kibanas.map(item => ({
...item,
name: item.kibana.name,
status: item.kibana.status,
}));

this.renderReact(
<I18nProvider>
<EuiPage>
<EuiPageBody>
Expand All @@ -154,15 +153,9 @@ uiRoutes.when('/kibana/instances', {
<EuiSpacer size="m"/>
<EuiMonitoringTable
className="kibanaInstancesTable"
rows={this.data.kibanas}
rows={dataFlattened}
columns={getColumns(kbnUrl, $scope)}
sorting={{
...this.sorting,
sort: {
...this.sorting.sort,
field: 'kibana.name'
}
}}
sorting={this.sorting}
pagination={this.pagination}
search={{
box: {
Expand All @@ -180,12 +173,7 @@ uiRoutes.when('/kibana/instances', {
</EuiPage>
</I18nProvider>
);

render(page, app);
};

$scope.$watch('data', () => renderReact());
renderReact();
});
}
}
});

0 comments on commit 1e9bd95

Please sign in to comment.