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 all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
Copy link
Contributor

Choose a reason for hiding this comment

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

For my understanding: How are these files exactly used / run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some docs about that.

Basically, it renders a React component into a string then stores that string in a file. The next time the test is run, it renders the same React component and compares it to the file and if there is any change, it fails the test. You can however easily update this file if the change was intentional (the CI tool does it for you)

So this means any kind of visual change requires the dev to update the snapshots and thus be aware they are changing something with how the component is rendered.


exports[`Ccr that it renders normally 1`] = `
<EuiPage
restrictWidth={false}
>
<EuiPageBody
restrictWidth={false}
>
<EuiPageContent
panelPaddingSize="l"
>
<EuiPageContentBody>
<EuiInMemoryTable
className="monitoringElasticsearchCcrListingTable"
columns={
Array [
Object {
"field": "index",
"name": "Index",
"render": [Function],
"sortable": true,
},
Object {
"field": "follows",
"name": "Follows",
"sortable": true,
},
Object {
"field": "opsSynced",
"name": "Ops synced",
"sortable": true,
},
Object {
"field": "syncLagTime",
"name": "Last fetch time",
"render": [Function],
"sortable": true,
},
Object {
"field": "syncLagOps",
"name": "Sync Lag (ops)",
"sortable": true,
},
Object {
"field": "error",
"name": "Error",
"render": [Function],
"sortable": true,
},
]
}
itemId="id"
itemIdToExpandedRowMap={Object {}}
items={
Array [
Object {
"follows": "leader",
"id": "follower",
"index": "follower",
"opsSynced": 400,
"shards": Array [
Object {
"opsSynced": 200,
"shardId": 0,
"syncLagOps": 2,
"syncLagOpsFollower": 1,
"syncLagOpsLeader": 1,
"syncLagTime": 45000,
},
Object {
"opsSynced": 200,
"shardId": 1,
"syncLagOps": 1,
"syncLagOpsFollower": 0,
"syncLagOpsLeader": 1,
"syncLagTime": 60000,
},
],
"syncLagOps": 5,
"syncLagTime": 60000,
},
Object {
"error": "not_working_properly",
"follows": "leader2",
"id": "follower2",
"index": "follower2",
"opsSynced": 50,
"shards": Array [
Object {
"opsSynced": 20,
"shardId": 1,
"syncLagOps": 0,
"syncLagOpsFollower": 0,
"syncLagOpsLeader": 0,
"syncLagTime": 11000,
},
Object {
"error": "not_working_properly",
"opsSynced": 30,
"shardId": 2,
"syncLagOps": 5,
"syncLagOpsFollower": 5,
"syncLagOpsLeader": 0,
"syncLagTime": 1000,
},
],
"syncLagOps": 1,
"syncLagTime": 12000,
},
]
}
pagination={false}
responsive={true}
sorting={
Object {
"sort": Object {
"direction": "asc",
"field": "index",
},
}
}
/>
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
</EuiPage>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* [1] - We want the collapsed table (that shows the shard data) to be inline
* with the columns from the main table so we need to remove the padding
*/
.monitoringElasticsearchCcrListingTable .euiTableRow-isExpandedRow > .euiTableRowCell > .euiTableCellContent {
padding: 0; /* [1] */
}
211 changes: 211 additions & 0 deletions x-pack/plugins/monitoring/public/components/elasticsearch/ccr/ccr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
/*
* 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, Component } from 'react';
import {
EuiInMemoryTable,
EuiLink,
EuiPage,
EuiPageBody,
EuiPageContent,
EuiPageContentBody,
EuiIcon,
EuiIconTip,
EuiTextColor
} from '@elastic/eui';

import './ccr.css';

function toSeconds(ms) {
return Math.floor(ms / 1000) + 's';
}

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

toggleShards(index, shards) {
const itemIdToExpandedRowMap = {
...this.state.itemIdToExpandedRowMap
};

if (itemIdToExpandedRowMap[index]) {
delete itemIdToExpandedRowMap[index];
} else {
let pagination = {
initialPageSize: 5,
pageSizeOptions: [5, 10, 20]
};

if (shards.length <= pagination.initialPageSize) {
pagination = false;
}

itemIdToExpandedRowMap[index] = (
<EuiInMemoryTable
items={shards}
columns={[
{
field: 'shardId',
name: 'Shard',
render: shardId => {
return (
<EuiLink href={`#/elasticsearch/ccr/${index}/shard/${shardId}`}>
{shardId}
</EuiLink>
);
}
},
{
render: () => null
},
{
field: 'opsSynced',
name: 'Ops synced'
},
{
field: 'syncLagTime',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we later also clean up the field naming to be consistent with the Name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea probably a good idea

name: 'Last fetch time',
render: syncLagTime => <span>{toSeconds(syncLagTime)}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we will always be interested in seconds? It could also be larger or smaller I would assume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll address in a follow up

},
{
field: 'syncLagOps',
name: 'Sync Lag (ops)',
render: (syncLagOps, data) => (
<span>
{syncLagOps}
&nbsp;&nbsp;
<EuiIconTip
size="m"
type="iInCircle"
content={(
<Fragment>
<span>Leader lag: {data.syncLagOpsLeader}</span>
<br/>
<span>Follower lag: {data.syncLagOpsFollower}</span>
</Fragment>
)}
position="right"
/>
</span>
)
},
{
field: 'error',
name: 'Error',
render: error => (
<EuiTextColor color="danger">
{error}
</EuiTextColor>
)
}
]}
sorting={true}
pagination={pagination}
/>
);
}
this.setState({ itemIdToExpandedRowMap });
}

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

let pagination = {
initialPageSize: 5,
pageSizeOptions: [5, 10, 20]
};

if (items.length <= pagination.initialPageSize) {
pagination = false;
}

const sorting = {
sort: {
field: 'index',
direction: 'asc',
},
};

return (
<EuiInMemoryTable
className="monitoringElasticsearchCcrListingTable"
columns={[
{
field: 'index',
name: 'Index',
sortable: true,
render: (index, { shards }) => {
const expanded = !!this.state.itemIdToExpandedRowMap[index];
return (
<EuiLink onClick={() => this.toggleShards(index, shards)}>
{index}
&nbsp;
{ expanded ? <EuiIcon type="arrowUp" /> : <EuiIcon type="arrowDown" /> }
</EuiLink>
);
}
},
{
field: 'follows',
sortable: true,
name: 'Follows'
},
{
field: 'opsSynced',
sortable: true,
name: 'Ops synced'
},
{
field: 'syncLagTime',
sortable: true,
name: 'Last fetch time',
render: syncLagTime => <span>{toSeconds(syncLagTime)}</span>
},
{
field: 'syncLagOps',
sortable: true,
name: 'Sync Lag (ops)',
},
{
field: 'error',
sortable: true,
name: 'Error',
render: error => (
<EuiTextColor color="danger">
{error}
</EuiTextColor>
)
}
]}
items={items}
pagination={pagination}
sorting={sorting}
itemId="id"
itemIdToExpandedRowMap={this.state.itemIdToExpandedRowMap}
/>
);
}

render() {
return (
<EuiPage>
<EuiPageBody>
<EuiPageContent>
<EuiPageContentBody>
{this.renderTable()}
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
</EuiPage>
);
}
}
Loading