-
Notifications
You must be signed in to change notification settings - Fork 13
Top n queries overview page #7
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
Merged
ansjcy
merged 22 commits into
opensearch-project:main
from
LilyCaroline17:topNQueries-Overview-Page
Sep 4, 2024
Merged
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2b7f553
Add 2 tabs to home screen
LilyCaroline17 bf9372f
two tabs for query insights and configuration
LilyCaroline17 a2eff12
Breadcrumbs + restructuring
LilyCaroline17 ab271c4
Top n queries table + search
LilyCaroline17 ec6ae90
search in general
LilyCaroline17 20020ec
Search includes indices and time selection fully works
LilyCaroline17 0f1fcd9
Fix tabs display
LilyCaroline17 790081f
Remove unnecessary parts
LilyCaroline17 5e9ad96
More cleanups
LilyCaroline17 2476c4d
Linted
LilyCaroline17 c7b92e6
Unused import
LilyCaroline17 c6a7574
Update plugin version to be compatible with openSearchDashboards
LilyCaroline17 90efa67
Resolving comments
LilyCaroline17 2ef59cc
Switch to typescript
LilyCaroline17 2e6c0c8
Finish typescript updates
LilyCaroline17 aa49f07
Comments addressed with constants
LilyCaroline17 182609a
Restructuring changes
LilyCaroline17 9ccdb5b
linting issues and ensure working on no data
LilyCaroline17 6c8cd1f
Added all relevant changes to overview page
LilyCaroline17 0497aab
Merge branch 'main' into topNQueries-Overview-Page
LilyCaroline17 455a945
Remove unnecessary parts
LilyCaroline17 9881add
Fix unit test
LilyCaroline17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ yarn-error.log | |
.DS_Store | ||
/cypress/screenshots/ | ||
/cypress/videos/ | ||
target | ||
target | ||
.eslintcache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { QueryInsightsDashboardsApp } from './components/app'; | ||
import { HashRouter as Router, Route } from 'react-router-dom'; | ||
|
||
export const renderApp = ( | ||
coreStart, | ||
{ navigation }, | ||
{ appBasePath, element } | ||
) => { | ||
coreStart.chrome.setBreadcrumbs([{text: 'Query insights'}]); | ||
ReactDOM.render( | ||
<Router> | ||
<QueryInsightsDashboardsApp | ||
basename={appBasePath} | ||
notifications={coreStart.notifications} | ||
http={coreStart.http} | ||
navigation={navigation} | ||
/> | ||
</Router> | ||
, element | ||
); | ||
|
||
return () => ReactDOM.unmountComponentAtNode(element); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
LilyCaroline17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { Route } from 'react-router-dom'; | ||
import TopNQueries from '../pages/TopNQueries/TopNQueries' | ||
|
||
export const QueryInsightsDashboardsApp = ({props}) => { | ||
return ( | ||
<Route | ||
render={(props) => ( | ||
<TopNQueries | ||
{...props} | ||
/> | ||
)} | ||
/> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
LilyCaroline17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import dateMath from '@elastic/datemath'; | ||
import { EuiSuperDatePicker, EuiInMemoryTable } from '@elastic/eui'; | ||
|
||
const QueryInsights = () => { | ||
const convertTime = (unixTime) => { | ||
const date = new Date(unixTime); | ||
const loc = date.toDateString().split(' '); | ||
return loc[1] + ' ' + loc[2] + ', ' + loc[3] + ' @ ' + date.toLocaleTimeString('en-US'); | ||
}; | ||
|
||
const cols = [ | ||
{ | ||
field: 'timestamp', | ||
name: 'Time stamp', | ||
render: (timestamp) => convertTime(timestamp), | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
{ | ||
field: 'latency', | ||
name: 'Latency', | ||
render: (latency) => `${latency} ms`, | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
{ | ||
field: 'cpu', | ||
name: 'CPU usage', | ||
render: (cpu) => `${cpu} ns`, | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
{ | ||
field: 'memory', | ||
name: 'Memory', | ||
render: (memory) => `${memory} B`, | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
{ | ||
field: 'indices', | ||
name: 'Indices', | ||
render: (indices) => indices.toString(), | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
{ | ||
field: 'search_type', | ||
name: 'Search type', | ||
render: (searchType) => searchType.replaceAll('_', ' '), | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
{ | ||
field: 'node_id', | ||
name: 'Coordinator node ID', | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
{ | ||
field: 'total_shards', | ||
name: 'Total shards', | ||
sortable: true, | ||
truncateText: true, | ||
}, | ||
]; | ||
|
||
const sorting = { | ||
sort: { | ||
field: 'timestamp', | ||
direction: 'desc', | ||
}, | ||
}; | ||
|
||
const retrievedQueries = []; | ||
const [queries, setQueries] = useState(retrievedQueries); | ||
|
||
const defaultStart = 'now-24h'; | ||
const [recentlyUsedRanges, setRecentlyUsedRanges] = useState([ | ||
{ start: defaultStart, end: 'now' }, | ||
]); | ||
const [loading] = useState(false); | ||
LilyCaroline17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const [currStart, setStart] = useState(defaultStart); | ||
const [currEnd, setEnd] = useState('now'); | ||
|
||
const parseDateString = (dateString) => { | ||
const date = dateMath.parse(dateString); | ||
return date ? date.toDate().getTime() : new Date().getTime(); | ||
}; | ||
|
||
const updateQueries = ({ start, end }) => { | ||
const startTimestamp = parseDateString(start); | ||
const endTimestamp = parseDateString(end); | ||
setQueries( | ||
retrievedQueries.filter( | ||
(item) => item.timestamp >= startTimestamp && item.timestamp <= endTimestamp | ||
) | ||
); | ||
}; | ||
|
||
const onTimeChange = ({ start, end }) => { | ||
const usedRange = recentlyUsedRanges.filter( | ||
(range) => !(range.start === start && range.end === end) | ||
); | ||
usedRange.unshift({ start, end }); | ||
setStart(start); | ||
setEnd(end); | ||
setRecentlyUsedRanges(usedRange.length > 10 ? usedRange.slice(0, 9) : usedRange); | ||
updateQueries({ start, end }); | ||
}; | ||
|
||
const onRefresh = async ({ start, end }) => { | ||
updateQueries({ start, end }); | ||
}; | ||
|
||
useEffect( | ||
() => { | ||
onRefresh({ start: currStart, end: currEnd }); | ||
}, | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[] | ||
); | ||
|
||
const searchTopNQueries = () => { | ||
LilyCaroline17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return { | ||
box: { | ||
placeholder: 'Search queries', | ||
schema: false, | ||
}, | ||
toolsRight: [ | ||
<EuiSuperDatePicker | ||
start={currStart} | ||
end={currEnd} | ||
recentlyUsedRanges={recentlyUsedRanges} | ||
isLoading={loading} | ||
onTimeChange={onTimeChange} | ||
onRefresh={onRefresh} | ||
updateButtonProps={{ fill: false }} | ||
/>, | ||
], | ||
}; | ||
}; | ||
|
||
return ( | ||
<div> | ||
<EuiInMemoryTable | ||
items={queries} | ||
columns={cols} | ||
sorting={sorting} | ||
loading={loading} | ||
search={searchTopNQueries()} | ||
executeQueryOptions={{ | ||
defaultFields: [ | ||
'timestamp', | ||
'latency', | ||
'cpu', | ||
'memory', | ||
'indices', | ||
'search_type', | ||
'node_id', | ||
'total_shards', | ||
], | ||
}} | ||
allowNeutralSort={false} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default QueryInsights; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.