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

[Monitoring] CCR UI #23013

Merged
merged 42 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
63e5dac
Initial version of CCR monitoring UI
chrisronline Sep 13, 2018
025f248
Adding missing files
chrisronline Sep 13, 2018
09f99e6
Use icons
chrisronline Sep 13, 2018
7a66a00
Use new column header text
chrisronline Sep 13, 2018
00f9706
Update tests
chrisronline Sep 14, 2018
f0145ef
Basic of shard detail page
chrisronline Sep 16, 2018
6c25a27
Do these in parallel
chrisronline Sep 16, 2018
42f9bdd
Disable time picker on ccr page
chrisronline Sep 17, 2018
b1683f1
Remove summary for now
chrisronline Sep 17, 2018
bafc945
Remove unnecessary code here
chrisronline Sep 17, 2018
b325eb2
Fix a few things on the shard page
chrisronline Sep 17, 2018
8691dc5
Only send down what we need
chrisronline Sep 17, 2018
f0bd7e3
update snapshot
chrisronline Sep 17, 2018
0ca3b45
Handle no ccr_stats documents
chrisronline Sep 18, 2018
e9a4051
Ensure we fetch the latest
chrisronline Sep 18, 2018
fac343b
Updates
chrisronline Sep 19, 2018
1451a08
Format the time
chrisronline Sep 19, 2018
ffd5bf4
Add api integration tests
chrisronline Sep 19, 2018
6b75c0d
Adding pagination and sorting
chrisronline Sep 20, 2018
e1181a5
Updated query logic
chrisronline Sep 20, 2018
41aa135
Merge remote-tracking branch 'elastic/master' into monitoring/ccr
chrisronline Sep 21, 2018
cadae6b
Change this back
chrisronline Sep 21, 2018
38e4a67
Merge remote-tracking branch 'elastic/master' into monitoring/ccr
chrisronline Sep 24, 2018
6bfb58f
Add specific information about the follower and leader lag ops
chrisronline Sep 24, 2018
195c58a
Update tests
chrisronline Sep 24, 2018
a179832
UI updates
chrisronline Sep 24, 2018
183accd
Address PR issues
chrisronline Sep 25, 2018
bc4e068
Fix tests
chrisronline Sep 25, 2018
2c75c68
Merge in master
chrisronline Sep 25, 2018
ca9cce4
Update shapshots
chrisronline Sep 25, 2018
e16515e
Add timestamp
chrisronline Sep 26, 2018
8cd1cbe
Update tests
chrisronline Sep 26, 2018
c46b2fc
Add a few snapshot tests
chrisronline Sep 27, 2018
36b8384
Use timezone formatter
chrisronline Sep 27, 2018
d22f966
Fix tests
chrisronline Sep 27, 2018
d4cf306
Merge remote-tracking branch 'elastic/master' into monitoring/ccr
chrisronline Oct 1, 2018
0248638
Merge remote-tracking branch 'elastic/master' into monitoring/ccr
chrisronline Oct 2, 2018
d7b156c
Merge remote-tracking branch 'elastic/master' into monitoring/ccr
chrisronline Oct 3, 2018
0fdc024
Fix aligment of shard table
chrisronline Oct 3, 2018
94f06d9
PR feedback
chrisronline Oct 3, 2018
8f86714
Update snapshots
chrisronline Oct 3, 2018
a4184fb
Update snapshot
chrisronline Oct 3, 2018
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
140 changes: 140 additions & 0 deletions x-pack/plugins/monitoring/public/components/elasticsearch/ccr/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
* 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, { Component } from 'react';
import {
EuiBasicTable,
EuiLink,
EuiPage,
EuiPageBody,
EuiPageContent,
EuiPageContentBody,
EuiIcon,
} from '@elastic/eui';

export class Ccr extends Component {
constructor(props) {
super(props);
this.state = {
itemIdToExpandedRowMap: {},
};
}

toggleShard(index) {
const { data: { shardStatsByFollowerIndex } } = this.props;

const itemIdToExpandedRowMap = {
...this.state.itemIdToExpandedRowMap
};

if (itemIdToExpandedRowMap[index]) {
delete itemIdToExpandedRowMap[index];
} else {
itemIdToExpandedRowMap[index] = (
<EuiBasicTable
items={Object.values(shardStatsByFollowerIndex[index])}
columns={[
{
field: 'shardId',
name: 'Shard',
render: shardId => {
return (
<EuiLink href={`#/elasticsearch/ccr/${index}/shard/${shardId}`}>
{shardId}
</EuiLink>
);
}
},
{
field: 'follows',
name: 'Follows'
},
{
field: 'opsSynced',
name: 'Ops synced'
},
{
field: 'syncLagTime',
name: 'Last fetch time'
},
{
field: 'syncLagOps',
name: 'Sync Lag (ops)',
},
{
field: 'error',
name: 'Error',
}
]}
/>
);
}
this.setState({ itemIdToExpandedRowMap });
}

renderTable() {
const { data: { all } } = this.props;
const items = all;

return (
<EuiBasicTable
columns={[
{
field: 'index',
name: 'Index',
render: (index) => {
const expanded = !!this.state.itemIdToExpandedRowMap[index];
return (
<EuiLink onClick={() => this.toggleShard(index)}>
{index}
&nbsp;
{ expanded ? <EuiIcon type="arrowUp" /> : <EuiIcon type="arrowDown" /> }
</EuiLink>
);
}
},
{
field: 'follows',
name: 'Follows'
},
{
field: 'opsSynced',
name: 'Ops synced'
},
{
field: 'syncLagTime',
name: 'Last fetch time'
},
{
field: 'syncLagOps',
name: 'Sync Lag (ops)'
},
{
field: 'error',
name: 'Error'
}
]}
items={items}
itemId="id"
itemIdToExpandedRowMap={this.state.itemIdToExpandedRowMap}
/>
);
}

render() {
return (
<EuiPage>
<EuiPageBody>
<EuiPageContent>
<EuiPageContentBody>
{this.renderTable()}
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
</EuiPage>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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, { Fragment, PureComponent } from 'react';
import {
EuiPage,
EuiPageBody,
EuiPanel,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
} from '@elastic/eui';
import { MonitoringTimeseriesContainer } from '../../chart';
import { Status } from './status';

export class CcrShard extends PureComponent {
renderCharts() {
const { metrics } = this.props;
const seriesToShow = [
[metrics.sync_lag_time],
[metrics.sync_lag_ops]
];

const charts = seriesToShow.map((data, index) => (
<EuiFlexItem style={{ minWidth: '45%' }} key={index}>
<EuiPanel>
<MonitoringTimeseriesContainer
series={data}
/>
</EuiPanel>
</EuiFlexItem>
));

return (
<Fragment>
{charts}
</Fragment>
);
}

render() {
const { stat } = this.props;

return (
<EuiPage style={{ backgroundColor: 'white' }}>
<EuiPageBody>
<Status stats={stat}/>
<EuiSpacer size="s"/>
<EuiFlexGroup wrap>
{this.renderCharts()}
</EuiFlexGroup>
</EuiPageBody>
</EuiPage>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 Status({ stats }) {
const {
follower_index: followerIndex,
shard_id: shardId,
leader_index: leaderIndex,
operations_received: operationsReceived
} = stats;

const metrics = [
{
label: 'Follower Index',
value: followerIndex,
dataTestSubj: 'followerIndex'
},
{
label: 'Shard Id',
value: shardId,
dataTestSubj: 'shardId'
},
{
label: 'Leader Index',
value: leaderIndex,
dataTestSubj: 'leaderIndex'
},
{
label: 'Total Ops Synced',
value: formatMetric(operationsReceived, 'int_commas'),
dataTestSubj: 'operationsReceived'
},
];

return (
<SummaryStatus
metrics={metrics}
data-test-subj="ccrDetailStatus"
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<a ng-if="!monitoringMain.instance" kbn-href="#/elasticsearch/nodes" class="kuiLocalTab" ng-class="{'kuiLocalTab-isSelected': monitoringMain.isActiveTab('nodes')}">Nodes</a>
<a ng-if="!monitoringMain.instance" kbn-href="#/elasticsearch/indices" class="kuiLocalTab" ng-class="{'kuiLocalTab-isSelected': monitoringMain.isActiveTab('indices')}">Indices</a>
<a ng-if="!monitoringMain.instance && monitoringMain.isMlSupported()" kbn-href="#/elasticsearch/ml_jobs" class="kuiLocalTab" ng-class="{'kuiLocalTab-isSelected': monitoringMain.isActiveTab('ml')}">Jobs</a>
<a ng-if="!monitoringMain.instance" kbn-href="#/elasticsearch/ccr" class="kuiLocalTab" ng-class="{'kuiLocalTab-isSelected': monitoringMain.isActiveTab('ccr')}">CCR</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the future it would be nice if CCR would only be shown if the ES version that is monitored supports CCR or we have data related to it. We could also then add an info icon on why it is not enabled and tell users about CCR.

<a
ng-if="monitoringMain.instance && (monitoringMain.name === 'nodes' || monitoringMain.name === 'indices')"
kbn-href="#/elasticsearch/{{ monitoringMain.name }}/{{ monitoringMain.resolver }}"
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/monitoring/public/views/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import './elasticsearch/index/advanced';
import './elasticsearch/nodes';
import './elasticsearch/node';
import './elasticsearch/node/advanced';
import './elasticsearch/ccr';
import './elasticsearch/ccr/shard';
import './elasticsearch/ml_jobs';
import './kibana/overview';
import './kibana/instances';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
import { timefilter } from 'ui/timefilter';

export function getPageData($injector) {
const $http = $injector.get('$http');
const globalState = $injector.get('globalState');
const timeBounds = timefilter.getBounds();
const url = `../api/monitoring/v1/clusters/${globalState.cluster_uuid}/elasticsearch/ccr`;

return $http.post(url, {
ccs: globalState.ccs,
timeRange: {
min: timeBounds.min.toISOString(),
max: timeBounds.max.toISOString()
}
})
.then(response => response.data)
.catch((err) => {
const Private = $injector.get('Private');
const ajaxErrorHandlers = Private(ajaxErrorHandlersProvider);
return ajaxErrorHandlers(err);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<monitoring-main
product="elasticsearch"
name="ccr"
data-test-subj="elasticsearchCcrListingPage"
>
<div id="elasticsearchCcrReact"></div>
</monitoring-main>
44 changes: 44 additions & 0 deletions x-pack/plugins/monitoring/public/views/elasticsearch/ccr/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 uiRoutes from 'ui/routes';
import { getPageData } from './get_page_data';
import template from './index.html';
import { timefilter } from 'ui/timefilter';
import { Ccr } from '../../../components/elasticsearch/ccr';
import { MonitoringViewBaseController } from '../../base_controller';

uiRoutes.when('/elasticsearch/ccr', {
template,
resolve: {
pageData: getPageData,
},
controllerAs: 'elasticsearchCcr',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the convention for abbreviations? In Golang we would use CCR also for the var name.

controller: class ElasticsearchCcrController extends MonitoringViewBaseController {
constructor($injector, $scope) {
super({
title: 'Elasticsearch - Ccr',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be CCR instead of Ccr?

reactNodeId: 'elasticsearchCcrReact',
getPageData,
$scope,
$injector
});

timefilter.disableTimeRangeSelector();

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

this.renderReact = ({ data }) => {
super.renderReact(
<Ccr data={data} />
);
};
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
import { timefilter } from 'ui/timefilter';

export function getPageData($injector) {
const $http = $injector.get('$http');
const $route = $injector.get('$route');
const globalState = $injector.get('globalState');
const timeBounds = timefilter.getBounds();
const url = `../api/monitoring/v1/clusters/${globalState.cluster_uuid}/elasticsearch/ccr/${$route.current.params.index}/shard/${$route.current.params.shardId}`; // eslint-disable-line max-len

return $http.post(url, {
ccs: globalState.ccs,
timeRange: {
min: timeBounds.min.toISOString(),
max: timeBounds.max.toISOString()
}
})
.then(response => response.data)
.catch((err) => {
const Private = $injector.get('Private');
const ajaxErrorHandlers = Private(ajaxErrorHandlersProvider);
return ajaxErrorHandlers(err);
});

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<monitoring-main
product="elasticsearch"
name="ccr_shard"
data-test-subj="elasticsearchCcrShardPage"
>
<div id="elasticsearchCcrShardReact"></div>
</monitoring-main>
Loading