diff --git a/x-pack/plugins/monitoring/public/application/pages/elasticsearch/overview.tsx b/x-pack/plugins/monitoring/public/application/pages/elasticsearch/overview.tsx index c58aaa5dffb04e..d1500d5d9587bf 100644 --- a/x-pack/plugins/monitoring/public/application/pages/elasticsearch/overview.tsx +++ b/x-pack/plugins/monitoring/public/application/pages/elasticsearch/overview.tsx @@ -10,7 +10,8 @@ import { find } from 'lodash'; import { ElasticsearchTemplate } from './elasticsearch_template'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { GlobalStateContext } from '../../contexts/global_state_context'; -import { ElasticsearchOverview } from '../../../components/elasticsearch'; +// @ts-ignore +import { ElasticsearchOverviewReact } from '../../../components/elasticsearch'; import { ComponentProps } from '../../route_init'; import { useCharts } from '../../hooks/use_charts'; import { BreadcrumbContainer } from '../../hooks/use_breadcrumbs'; @@ -78,7 +79,7 @@ export const ElasticsearchOverviewPage: React.FC = ({ clusters } const shardActivityData = shardActivity && filterShardActivityData(shardActivity); // no filter on data = null return ( - + + + + + + + + {metricsToShow.map((metric, index) => ( + + + + + ))} + + + + + + + + + + + + + ); +} diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/index.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/index.js index bcdbbe715f86e7..8c0b8b4c9c82de 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/index.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/index.js @@ -6,3 +6,4 @@ */ export { ShardActivity } from './shard_activity'; +export { ShardActivityReact } from './shard_activity_react'; diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/parse_props.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/parse_props.js index 76f22583af0c8d..1f0ed47adf3876 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/parse_props.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/parse_props.js @@ -37,18 +37,26 @@ export const parseProps = (props) => { target, translog, type, + timezone, } = props; const { files, size } = index; - const injector = Legacy.shims.getAngularInjector(); - const timezone = injector.get('config').get('dateFormat:tz'); + + let thisTimezone; + // react version passes timezone while Angular uses injector + if (!timezone) { + const injector = Legacy.shims.getAngularInjector(); + thisTimezone = injector.get('config').get('dateFormat:tz'); + } else { + thisTimezone = timezone; + } return { name: indexName || index.name, shard: `${id} / ${isPrimary ? 'Primary' : 'Replica'}`, relocationType: type === 'PRIMARY_RELOCATION' ? 'Primary Relocation' : normalizeString(type), stage: normalizeString(stage), - startTime: formatDateTimeLocal(startTimeInMillis, timezone), + startTime: formatDateTimeLocal(startTimeInMillis, thisTimezone), totalTime: formatMetric(Math.floor(totalTimeInMillis / 1000), '00:00:00'), isCopiedFromPrimary: !isPrimary || type === 'PRIMARY_RELOCATION', sourceName: source.name === undefined ? 'n/a' : source.name, diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/shard_activity_react.js b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/shard_activity_react.js new file mode 100644 index 00000000000000..cc219ff0fff321 --- /dev/null +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/shard_activity/shard_activity_react.js @@ -0,0 +1,156 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { Fragment } from 'react'; +import { EuiText, EuiTitle, EuiLink, EuiSpacer, EuiSwitch } from '@elastic/eui'; +import { EuiMonitoringTable } from '../../table'; +import { RecoveryIndex } from './recovery_index'; +import { TotalTime } from './total_time'; +import { SourceDestination } from './source_destination'; +import { FilesProgress, BytesProgress, TranslogProgress } from './progress'; +import { parseProps } from './parse_props'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; + +const columns = [ + { + name: i18n.translate('xpack.monitoring.kibana.shardActivity.indexTitle', { + defaultMessage: 'Index', + }), + field: 'name', + render: (_name, shard) => , + }, + { + name: i18n.translate('xpack.monitoring.kibana.shardActivity.stageTitle', { + defaultMessage: 'Stage', + }), + field: 'stage', + }, + { + name: i18n.translate('xpack.monitoring.kibana.shardActivity.totalTimeTitle', { + defaultMessage: 'Total Time', + }), + field: null, + render: (shard) => , + }, + { + name: i18n.translate('xpack.monitoring.kibana.shardActivity.sourceDestinationTitle', { + defaultMessage: 'Source / Destination', + }), + field: null, + render: (shard) => , + }, + { + name: i18n.translate('xpack.monitoring.kibana.shardActivity.filesTitle', { + defaultMessage: 'Files', + }), + field: null, + render: (shard) => , + }, + { + name: i18n.translate('xpack.monitoring.kibana.shardActivity.bytesTitle', { + defaultMessage: 'Bytes', + }), + field: null, + render: (shard) => , + }, + { + name: i18n.translate('xpack.monitoring.kibana.shardActivity.translogTitle', { + defaultMessage: 'Translog', + }), + field: null, + render: (shard) => , + }, +]; + +export const ShardActivityReact = (props) => { + const { + data: rawData, + sorting, + pagination, + onTableChange, + toggleShardActivityHistory, + showShardActivityHistory, + } = props; + const { services } = useKibana(); + const timezone = services.uiSettings?.get('dateFormat:tz'); + const getNoDataMessage = () => { + if (showShardActivityHistory) { + return i18n.translate('xpack.monitoring.elasticsearch.shardActivity.noDataMessage', { + defaultMessage: + 'There are no historical shard activity records for the selected time range.', + }); + } + return ( + + +
+ + + + ), + }} + /> +
+ ); + }; + + const rows = rawData.map((data) => parseProps({ ...data, timezone })); + + return ( + + + +

+ +

+
+
+ + + } + onChange={toggleShardActivityHistory} + checked={showShardActivityHistory} + /> + + +
+ ); +};