Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stack Monitoring] Node Advanced View #113628

Merged
merged 4 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions x-pack/plugins/monitoring/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { CODE_PATH_ELASTICSEARCH, CODE_PATH_BEATS } from '../../common/constants
import { ElasticsearchNodesPage } from './pages/elasticsearch/nodes_page';
import { ElasticsearchIndicesPage } from './pages/elasticsearch/indices_page';
import { ElasticsearchNodePage } from './pages/elasticsearch/node_page';
import { ElasticsearchNodeAdvancedPage } from './pages/elasticsearch/node_advanced_page';
import { MonitoringTimeContainer } from './hooks/use_monitoring_time';
import { BreadcrumbContainer } from './hooks/use_breadcrumbs';

Expand Down Expand Up @@ -90,6 +91,13 @@ const MonitoringApp: React.FC<{
fetchAllClusters={false}
/>

<RouteInit
path="/elasticsearch/nodes/:node/advanced"
component={ElasticsearchNodeAdvancedPage}
codePaths={[CODE_PATH_ELASTICSEARCH]}
fetchAllClusters={false}
/>

<RouteInit
path="/elasticsearch/nodes/:node"
component={ElasticsearchNodePage}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 from 'react';
import { i18n } from '@kbn/i18n';
import { PageTemplate } from '../page_template';
import { TabMenuItem, PageTemplateProps } from '../page_template';

interface ItemTemplateProps extends PageTemplateProps {
id: string;
pageType: string;
}
export const ItemTemplate: React.FC<ItemTemplateProps> = (props) => {
const { pageType, id, ...rest } = props;
const tabs: TabMenuItem[] = [
{
id: 'overview',
label: i18n.translate('xpack.monitoring.esItemNavigation.overviewLinkText', {
defaultMessage: 'Overview',
}),
route: `/elasticsearch/${pageType}/${id}`,
},
{
id: 'advanced',
label: i18n.translate('xpack.monitoring.esItemNavigation.advancedLinkText', {
defaultMessage: 'Advanced',
}),
route: `/elasticsearch/${pageType}/${id}/advanced`,
},
];

return <PageTemplate {...rest} tabs={tabs} product="elasticsearch" />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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, { useContext, useState, useCallback } from 'react';
import { useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { ItemTemplate } from './item_template';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { GlobalStateContext } from '../../global_state_context';
// @ts-ignore
import { AdvancedNode } from '../../../components/elasticsearch/node/advanced';
import { ComponentProps } from '../../route_init';
import { useCharts } from '../../hooks/use_charts';

export const ElasticsearchNodeAdvancedPage: React.FC<ComponentProps> = ({ clusters }) => {
const globalState = useContext(GlobalStateContext);
const { zoomInfo, onBrush } = useCharts();

const { node }: { node: string } = useParams();
const { services } = useKibana<{ data: any }>();

const clusterUuid = globalState.cluster_uuid;
const ccs = globalState.ccs;
const [data, setData] = useState({} as any);

const title = i18n.translate('xpack.monitoring.elasticsearch.node.advanced.title', {
defaultMessage: 'Elasticsearch - Nodes - {nodeName} - Advanced',
values: {
nodeName: data?.nodeSummary?.name,
},
});

const pageTitle = i18n.translate('xpack.monitoring.elasticsearch.node.advanced.pageTitle', {
defaultMessage: 'Elasticsearch node: {nodeName}',
values: {
nodeName: data?.nodeSummary?.name,
},
});

const getPageData = useCallback(async () => {
const bounds = services.data?.query.timefilter.timefilter.getBounds();
const url = `../api/monitoring/v1/clusters/${clusterUuid}/elasticsearch/nodes/${node}`;

const response = await services.http?.fetch(url, {
method: 'POST',
body: JSON.stringify({
ccs,
timeRange: {
min: bounds.min.toISOString(),
max: bounds.max.toISOString(),
},
is_advanced: true,
}),
});

setData(response);
}, [ccs, clusterUuid, services.data?.query.timefilter.timefilter, services.http, node]);

return (
<ItemTemplate
title={title}
pageTitle={pageTitle}
getPageData={getPageData}
id={node}
pageType="nodes"
>
<AdvancedNode
nodeSummary={data.nodeSummary}
alerts={{}}
metrics={data.metrics}
onBrush={onBrush}
zoomInfo={zoomInfo}
/>
</ItemTemplate>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import React, { useContext, useState, useCallback } from 'react';
import { useParams } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import { find } from 'lodash';
import { ElasticsearchTemplate } from './elasticsearch_template';
import { ItemTemplate } from './item_template';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { GlobalStateContext } from '../../global_state_context';
import { NodeReact } from '../../../components/elasticsearch';
Expand Down Expand Up @@ -38,13 +37,10 @@ export const ElasticsearchNodePage: React.FC<ComponentProps> = ({ clusters }) =>

const clusterUuid = globalState.cluster_uuid;
const ccs = globalState.ccs;
const cluster = find(clusters, {
cluster_uuid: clusterUuid,
});
const [data, setData] = useState({} as any);
const [nodesByIndicesData, setNodesByIndicesData] = useState([]);

const title = i18n.translate('xpack.monitoring.elasticsearch.node.overview.routeTitle', {
const title = i18n.translate('xpack.monitoring.elasticsearch.node.overview.title', {
defaultMessage: 'Elasticsearch - Nodes - {nodeName} - Overview',
values: {
nodeName: data?.nodeSummary?.name,
Expand Down Expand Up @@ -92,33 +88,32 @@ export const ElasticsearchNodePage: React.FC<ComponentProps> = ({ clusters }) =>
}, [showSystemIndices, setShowSystemIndices]);

return (
<ElasticsearchTemplate
<ItemTemplate
title={title}
pageTitle={pageTitle}
getPageData={getPageData}
cluster={cluster}
id={node}
pageType="nodes"
>
<div data-test-subj="elasticsearchNodeListingPage">
<SetupModeRenderer
render={({ setupMode, flyoutComponent, bottomBarComponent }: SetupModeProps) => (
<SetupModeContext.Provider value={{ setupModeSupported: true }}>
{flyoutComponent}
<NodeReact
alerts={{}}
nodeId={node}
clusterUuid={clusterUuid}
onBrush={onBrush}
zoomInfo={zoomInfo}
toggleShowSystemIndices={toggleShowSystemIndices}
showSystemIndices={showSystemIndices}
nodesByIndices={nodesByIndicesData}
{...data}
/>
{bottomBarComponent}
</SetupModeContext.Provider>
)}
/>
</div>
</ElasticsearchTemplate>
<SetupModeRenderer
render={({ setupMode, flyoutComponent, bottomBarComponent }: SetupModeProps) => (
<SetupModeContext.Provider value={{ setupModeSupported: true }}>
{flyoutComponent}
<NodeReact
alerts={{}}
nodeId={node}
clusterUuid={clusterUuid}
onBrush={onBrush}
zoomInfo={zoomInfo}
toggleShowSystemIndices={toggleShowSystemIndices}
showSystemIndices={showSystemIndices}
nodesByIndices={nodesByIndicesData}
{...data}
/>
{bottomBarComponent}
</SetupModeContext.Provider>
)}
/>
</ItemTemplate>
);
};