Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -24,6 +24,7 @@ import { BeatsOverviewPage } from './pages/beats/overview';
import { BeatsInstancesPage } from './pages/beats/instances';
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 { MonitoringTimeContainer } from './hooks/use_monitoring_time';
import { BreadcrumbContainer } from './hooks/use_breadcrumbs';
Expand Down Expand Up @@ -81,6 +82,13 @@ const MonitoringApp: React.FC<{
/>

{/* ElasticSearch Views */}
<RouteInit
path="/elasticsearch/indices"
component={ElasticsearchIndicesPage}
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,99 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { find } from 'lodash';
import { ElasticsearchTemplate } from './elasticsearch_template';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { GlobalStateContext } from '../../global_state_context';
import { ElasticsearchIndices } from '../../../components/elasticsearch';
import { ComponentProps } from '../../route_init';
import { SetupModeRenderer } from '../../setup_mode/setup_mode_renderer';
import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context';
import { useTable } from '../../hooks/use_table';
import { useLocalStorage } from '../../hooks/use_local_storage';

interface SetupModeProps {
setupMode: any;
flyoutComponent: any;
bottomBarComponent: any;
}

export const ElasticsearchIndicesPage: React.FC<ComponentProps> = ({ clusters }) => {
const globalState = useContext(GlobalStateContext);
const { services } = useKibana<{ data: any }>();
const { getPaginationTableProps } = useTable('elasticsearch.indices');
const clusterUuid = globalState.cluster_uuid;
const cluster = find(clusters, {
cluster_uuid: clusterUuid,
});
const [data, setData] = useState({} as any);
const [showSystemIndices, setShowSystemIndices] = useLocalStorage<boolean>(
'showSystemIndices',
false
);

const title = i18n.translate('xpack.monitoring.elasticsearch.indices.routeTitle', {
defaultMessage: 'Elasticsearch - Indices',
});

const pageTitle = i18n.translate('xpack.monitoring.elasticsearch.indices.pageTitle', {
defaultMessage: 'Elasticsearch indices',
});

const toggleShowSystemIndices = useCallback(
() => setShowSystemIndices(!showSystemIndices),
[showSystemIndices, setShowSystemIndices]
);

const getPageData = useCallback(async () => {
const bounds = services.data?.query.timefilter.timefilter.getBounds();
const url = `../api/monitoring/v1/clusters/${clusterUuid}/elasticsearch/indices`;
const response = await services.http?.fetch(url, {
method: 'POST',
query: {
show_system_indices: showSystemIndices,
},
body: JSON.stringify({
timeRange: {
min: bounds.min.toISOString(),
max: bounds.max.toISOString(),
},
}),
});
setData(response);
}, [showSystemIndices, clusterUuid, services.data?.query.timefilter.timefilter, services.http]);

return (
<ElasticsearchTemplate
title={title}
pageTitle={pageTitle}
getPageData={getPageData}
data-test-subj="elasticsearchOverviewPage"
cluster={cluster}
>
<div data-test-subj="elasticsearchNodesListingPage">
<SetupModeRenderer
render={({ flyoutComponent, bottomBarComponent }: SetupModeProps) => (
<SetupModeContext.Provider value={{ setupModeSupported: true }}>
{flyoutComponent}
<ElasticsearchIndices
clusterStatus={data.clusterStatus}
indices={data.indices}
alerts={{}}
showSystemIndices={showSystemIndices}
toggleShowSystemIndices={toggleShowSystemIndices}
{...getPaginationTableProps()}
/>
{bottomBarComponent}
</SetupModeContext.Provider>
)}
/>
</div>
</ElasticsearchTemplate>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

export const ElasticsearchOverview: FunctionComponent<Props>;
export const ElasticsearchNodes: FunctionComponent<Props>;
export const ElasticsearchIndices: FunctionComponent<Props>;
export const NodeReact: FunctionComponent<Props>;