ui: add insights overview page v1#84612
Conversation
6e3b907 to
8caf3fd
Compare
|
https://www.loom.com/share/2682ad5c9b00439d986a596df2d5f098 (Note that I decreased the duration threshold for this demo to match the average workload contention time) |
8caf3fd to
a16d790
Compare
a16d790 to
cf53c67
Compare
|
Looking for general frontend feedback here before proceeding with tests. Specifically, the following files, as they will have the most impact on v2+ work:
Please ignore the following files, as they are actually part of a separate branch:
I'm going to rebase on these changes when they are merged. |
maryliag
left a comment
There was a problem hiding this comment.
Awesome!! Some comments from me! Hopefully I looked at all the right files 😄
Reviewed 3 of 32 files at r1, 32 of 40 files at r2.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @ericharmeling and @maryliag)
pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 40 at r2 (raw file):
app_name FROM crdb_internal.transaction_contention_events AS tce
here you can add the WHERE to filter only the ones you care about, minimizing the joins you need to make
pkg/ui/workspaces/cluster-ui/src/insights/types.ts line 42 at r2 (raw file):
const HIGH_WAIT_CONTENTION_THRESHOLD = 2; const isHighWait = (
I think the responsibility of deciding if this is high wait should be on the api, so it would only return the high wait ones and the UI doesn't have to worry about it.
pkg/ui/workspaces/cluster-ui/src/insights/types.ts line 60 at r2 (raw file):
export const InsightTypes = [ { name: "highWaitTime", insight: highWaitTimeInsight, check: isHighWait },
if you follow my previous comment, then the check won't be necessary here
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 25 at r2 (raw file):
export type InsightEventFilters = Omit< ActiveStatementFilters,
it can be tricky to use the ActiveStatementFilters as a base, instead of Filters, because if you make a change on that one that you don't want to reflect here, people won't probably associate with active execution with the insights page or realize they will need to change here.
Probably safer to use Filters
Also, probably no for this PR since there is only one type, but we will need to introduce a filter for insight type
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 34 at r2 (raw file):
const insights: Insight[] = []; InsightTypes.forEach(insight => { if (insight.check(insightState)) {
you won't need this check here anymore
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 38 at r2 (raw file):
} }); console.log(insights);
nit: don't forget to remove this :)
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 53 at r2 (raw file):
const insightsForTxn = getInsights(txn); if (insightsForTxn.length < 1) { console.log("no insights for txn");
nit: this one too
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsOverview.tsx line 26 at r2 (raw file):
transactionInsightsProps, }: SqlInsightsOverviewProps): React.ReactElement => { const sqlInsightsOptions: Option[] = [
the selection between statement and transaction is a dropdown select, not a bullet
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/emptyInsightsTablePlaceholder.tsx line 38 at r2 (raw file):
title: "No insight events since this page was last refreshed.", icon: emptyTableResultsImg, message: "Insight events are cleared every hour.",
I'm not sure if that is the case for both the contention table and for the insights table. You might want to use something more generic or remove the "message" completely, leaving just the title which is enough for this case.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/insightsColumns.tsx line 20 at r2 (raw file):
insights: "Insights", startTime: "Start Time (UTC)", elapsedTime: "Elapsed Time (ms)",
don't add the ms to the column title, we have a formatter that adds the unit, and makes the adjustment for each case to decide between ms, s, ns, and so on
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/insightsColumns.tsx line 79 at r2 (raw file):
content={ <p> The category of insight identified as the cause of a slow {execType}{" "}
I don't think we can say is slow, because we will be adding different things that might be causing other issues besides being slow. Maybe something more generic:
The category of insight identifies for the {execType} execution.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 41 at r2 (raw file):
<Link to={`/insights/${item.executionID}`}> {String(item.executionID)} </Link>
while the details page is not created, better keep this as a label, so we don't have the state where it crashes when people click on the link. Once you create the details page, you can add the link back.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 44 at r2 (raw file):
), sort: (item: TransactionInsight) => String(item.executionID), alwaysShow: true,
since you're not adding a column picker, you don't need the alwaysShow. That is used when the page has a column picker and we don't want that column to be on the list, meaning it can never be unselected.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 51 at r2 (raw file):
cell: (item: TransactionInsight) => item.query, sort: (item: TransactionInsight) => item.query, alwaysShow: true,
same as above
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 72 at r2 (raw file):
name: "elapsedTime", title: insightsTableTitles.elapsedTime(execType), cell: (item: TransactionInsight) => `${item.elapsedTime} ms`,
use the utils function we have for Duration, which already takes care of the unit. Also, that function expects the value to be passed in nanoseconds, so make sure you're doing the right conversion
d202d7b to
b206057
Compare
ericharmeling
left a comment
There was a problem hiding this comment.
TFTR!
I did a lot of refactoring around the types and the SQL API to address your comments and to further accommodate adding statements and new insight types. At a certain point we can't reuse things though (like queries) until we have a dedicated insights table, so we'll have to either make new endpoints or make the one I added here a little more sophisticated. PTAL!
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @maryliag)
pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 40 at r2 (raw file):
only the ones you care about
I assume you are referring to the ones with a contention duration higher than a given threshold, correct?
pkg/ui/workspaces/cluster-ui/src/insights/types.ts line 42 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
I think the responsibility of deciding if this is high wait should be on the api, so it would only return the high wait ones and the UI doesn't have to worry about it.
Done.
pkg/ui/workspaces/cluster-ui/src/insights/types.ts line 60 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
if you follow my previous comment, then the check won't be necessary here
Done.
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 25 at r2 (raw file):
it can be tricky to use the ActiveStatementFilters as a base, instead of Filters, because if you make a change on that one that you don't want to reflect here, people won't probably associate with active execution with the insights page or realize they will need to change here.
Probably safer to use Filters
Great point! Done. I also refactored some other dependencies on SqlActivity things (e.g., SQLActivityError)
Also, probably no for this PR since there is only one type, but we will need to introduce a filter for insight type
SGTM
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 34 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
you won't need this check here anymore
Removed
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 38 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
nit: don't forget to remove this :)
😁 Removed.
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 53 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
nit: this one too
Removed.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsOverview.tsx line 26 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
the selection between statement and transaction is a
dropdown select, not a bullet
I created a small dropdown component to use as a new pageconfig for the execution type selection here.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/emptyInsightsTablePlaceholder.tsx line 38 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
I'm not sure if that is the case for both the contention table and for the insights table. You might want to use something more generic or remove the "message" completely, leaving just the title which is enough for this case.
Removed the message.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/insightsColumns.tsx line 20 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
don't add the ms to the column title, we have a formatter that adds the unit, and makes the adjustment for each case to decide between ms, s, ns, and so on
Done.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/insightsColumns.tsx line 79 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
I don't think we can say is slow, because we will be adding different things that might be causing other issues besides being slow. Maybe something more generic:
The category of insight identifies for the {execType} execution.
Done.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 41 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
while the details page is not created, better keep this as a label, so we don't have the state where it crashes when people click on the link. Once you create the details page, you can add the link back.
Done.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 44 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
since you're not adding a column picker, you don't need the alwaysShow. That is used when the page has a column picker and we don't want that column to be on the list, meaning it can never be unselected.
Removed.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 51 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
same as above
Removed.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsTable.tsx line 72 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
use the utils function we have for
Duration, which already takes care of the unit. Also, that function expects the value to be passed in nanoseconds, so make sure you're doing the right conversion
Done.
|
(Oh an I also updated the Loom in the comment above) :) |
de2e425 to
44f9f6b
Compare
|
Update: added a tooltip to the queries ("Transaction Execution") column in cases where there are more than one query or the query is longer than a given limit. |
maryliag
left a comment
There was a problem hiding this comment.
Awesome improvements! Just a few comments from me!
Reviewed 1 of 40 files at r2, 13 of 19 files at r3, 6 of 8 files at r5, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @ericharmeling and @maryliag)
pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 40 at r2 (raw file):
Previously, ericharmeling (Eric Harmeling) wrote…
only the ones you care about
I assume you are referring to the ones with a contention duration higher than a given threshold, correct?
Yes, that's correct. You don't need to add this extra select, you can do the WHERE at the end.
SELECT
blocking_txn_id,
blocking_queries,
collection_ts,
contention_duration,
app_name
FROM
crdb_internal.transaction_contention_events AS tce
JOIN (
SELECT
transaction_fingerprint_id,
app_name,
array_agg(metadata ->> 'query') AS blocking_queries
FROM
crdb_internal.statement_statistics
GROUP BY
transaction_fingerprint_id,
app_name
) AS bqs ON bqs.transaction_fingerprint_id = tce.blocking_txn_fingerprint_id
WHERE
contention_duration > INTERVAL '${HIGH_WAIT_CONTENTION_THRESHOLD.toISOString()}'
if you ran both this and the one you have with EXPLAIN SELECT...., you will see it generates the same plan
pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 35 at r5 (raw file):
// The only insight we currently report is "High Wait Time", which is the insight // associated with each row in the crdb_internal.transaction_contention_events table
nit: add period to comments
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/insightTable.module.scss line 32 at r5 (raw file):
color: $colors--link; display: flex; line-height: 24px;
you can use $line-height--medium here
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsView.tsx line 191 at r5 (raw file):
<PageConfig> <PageConfigItem> <DropDownSelect
since this is not changing the data, comment this part out and as soon as we have statements data to show, we can add it back with the proper handle.
You can comment and add a TODO
44f9f6b to
5cfe388
Compare
ericharmeling
left a comment
There was a problem hiding this comment.
TFTR!
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @maryliag)
pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 40 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
Yes, that's correct. You don't need to add this extra select, you can do the WHERE at the end.
SELECT blocking_txn_id, blocking_queries, collection_ts, contention_duration, app_name FROM crdb_internal.transaction_contention_events AS tce JOIN ( SELECT transaction_fingerprint_id, app_name, array_agg(metadata ->> 'query') AS blocking_queries FROM crdb_internal.statement_statistics GROUP BY transaction_fingerprint_id, app_name ) AS bqs ON bqs.transaction_fingerprint_id = tce.blocking_txn_fingerprint_id WHERE contention_duration > INTERVAL '${HIGH_WAIT_CONTENTION_THRESHOLD.toISOString()}'if you ran both this and the one you have with
EXPLAIN SELECT...., you will see it generates the same plan
Ooo very nice. Done.
pkg/ui/workspaces/cluster-ui/src/api/insightsApi.ts line 35 at r5 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
nit: add period to comments
Done.
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/sqlInsightsTable/insightTable.module.scss line 32 at r5 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
you can use
$line-height--mediumhere
Done
pkg/ui/workspaces/cluster-ui/src/insights/sqlInsights/transactionInsights/transactionInsightsView.tsx line 191 at r5 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
since this is not changing the data, comment this part out and as soon as we have statements data to show, we can add it back with the proper handle.
You can comment and add a TODO
Done.
|
Hi Eric, nit but can we change this from SQL insights to Workload Insights? https://www.figma.com/proto/xpnRkP9cLXERVceRC4cec4/22.2_SQL-obsrv_query-performance?page-id=301%3A3805&node-id=1082%3A57580&viewport=408%2C707%2C0.11&scaling=min-zoom&starting-point-node-id=1082%3A56829 |
maryliag
left a comment
There was a problem hiding this comment.
Great! You probably will need to wait for Xin Hao PR to get merged in first, and do the rename Kevin mentioned, otherwise
Reviewed 4 of 4 files at r6, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @maryliag)
|
One thing to note: I believe the cookie-based auth used for the v2 API requires the DB console connection to be secure. So insecure clusters won't let you access the Insights page (or any page that makes a v2 API call). Here's a loom that shows what happens: https://www.loom.com/share/a951fb74ae7f44b4b8bf75c5c39641ef This shouldn't be a huge problem, since we only use insecure clusters for testing and actively discourage customers from using the now-deprecated |
5cfe388 to
d570394
Compare
Done! I updated the loom link above to show latest. |
c34157b to
f5d03ac
Compare
803280a to
9b4ce38
Compare
maryliag
left a comment
There was a problem hiding this comment.
Great work on this! Just want to make sure, is your loom the most up to date state of the page?
Just had a few nits
Reviewed 15 of 15 files at r7, 19 of 25 files at r8, 1 of 5 files at r9, 14 of 14 files at r10, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ericharmeling and @maryliag)
pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/util/workloadInsightsError.tsx line 21 at r10 (raw file):
}; export const WorkloadInsightsError = (
can't you just use the errorComponent we already have? It also has the statsType that you can just pass the stmt/txn text
pkg/ui/workspaces/cluster-ui/src/store/insights/insights.reducer.ts line 47 at r10 (raw file):
state.valid = false; }, // Define actions that don't change state
nit: period
This commit adds the v1 Insights page to the DB Console, via the cluster-ui package. The v1 Insights page only includes a Transactions Insights overview page, populated with information served at a new "endpoint" built on the v2 SQL-over-HTTP API. Release note (ui change): Added new Insights page to DB Console
9b4ce38 to
409074f
Compare
ericharmeling
left a comment
There was a problem hiding this comment.
Just want to make sure, is your loom the most up to date state of the page?
Just updated the loom link in that first comment (https://www.loom.com/share/2682ad5c9b00439d986a596df2d5f098).
TFTR!
Reviewable status:
complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @maryliag)
pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/util/workloadInsightsError.tsx line 21 at r10 (raw file):
I originally was using the SQLActivityError component, but decided to make one for workload insights so as not to have a dependency on a SQLActivity component, following our earlier exchange.
it can be tricky to use the ActiveStatementFilters as a base, instead of Filters, because if you make a change on that one that you don't want to reflect here, people won't probably associate with active execution with the insights page or realize they will need to change here.
Probably safer to use Filters
Great point! Done. I also refactored some other dependencies on SqlActivity things (e.g., SQLActivityError)
I can definitely change it back though if you think that's the better move.
pkg/ui/workspaces/cluster-ui/src/store/insights/insights.reducer.ts line 47 at r10 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
nit: period
Done.
maryliag
left a comment
There was a problem hiding this comment.
Just one small nit that I just realize about the search, otherwise
Reviewed 1 of 25 files at r8, 2 of 2 files at r11, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @ericharmeling and @maryliag)
pkg/ui/workspaces/cluster-ui/src/insights/utils.ts line 93 at r11 (raw file):
txn => !search || txn.executionID?.includes(search) ||
we want the search to be case insensitive, so add toLowerCase to the search, txn.executionID and query
pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/util/workloadInsightsError.tsx line 21 at r10 (raw file):
Previously, ericharmeling (Eric Harmeling) wrote…
I originally was using the
SQLActivityErrorcomponent, but decided to make one for workload insights so as not to have a dependency on a SQLActivity component, following our earlier exchange.it can be tricky to use the ActiveStatementFilters as a base, instead of Filters, because if you make a change on that one that you don't want to reflect here, people won't probably associate with active execution with the insights page or realize they will need to change here.
Probably safer to use FiltersGreat point! Done. I also refactored some other dependencies on SqlActivity things (e.g., SQLActivityError)
I can definitely change it back though if you think that's the better move.
I didn't realize that one was on the sqlActivity. Never mind, you can keep this one
|
This looks awesome! bors r+ |
|
Build succeeded: |

This commit adds the v1 Insights page to the DB Console, via the cluster-ui package. The v1 Insights page only includes a Transactions Insights overview page, populated with information served a new "endpoint" built on top of the SQL-over-HTTP API.
Note this PR is dependent on the changes in #84617 and #85080.
After #84998 is merged with all the needed columns, we can rewrite the insights API to query the internal insights table.
Fixes #83774.
Release note (ui change): Added new Insights page to DB Console