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
Alerting: Reduce number of request fetching rules in the dashboard view using rtkq #86991
Alerting: Reduce number of request fetching rules in the dashboard view using rtkq #86991
Conversation
4be1a3f
to
2372877
Compare
2372877
to
9613576
Compare
…sts-in-dashboard-view
One general comment, since the old dashboard runner is going to be deprecated we should (also) implement this in the new scenes runner ( |
public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.ts
Outdated
Show resolved
Hide resolved
public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.ts
Outdated
Show resolved
Hide resolved
public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.test.ts
Outdated
Show resolved
Hide resolved
public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataAlertingTab.test.tsx
Show resolved
Hide resolved
9dda6db
to
c9b219b
Compare
…sts-in-dashboard-view
d29a532
to
9a4b019
Compare
9a4b019
to
40708e8
Compare
…d as optional params and rename the hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -316,25 +337,6 @@ describe('PanelAlertTabContent', () => { | |||
}; | |||
|
|||
expect(defaultsWithDeterministicTime).toMatchSnapshot(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we agreed on removing this test after talking to @konrad147 as it's not clear that is testing the right thing.
I tested manually, and the link to the alert rule is correctly updated once the variable changes
…sts-in-dashboard-view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @soniaAguilarPeiron , I was checking the code, and overall looks good :).
I left a question regarding some functionality I don't know was intentional to remove.
…-tracker * gops-configuration-tracker: (56 commits) SAML: add referemce to azure ad limitations (#87571) Update dependency glob to v10.3.14 Chore: Updated go.work.sum file (#87622) Update dependency @types/lodash to v4.17.1 (#87419) AdHocFilters: Use queries in ad hoc filters api calls (#87624) TimeSeries: Improve keyboard focus and fix spacebar override (#86848) Dropdown: Fixes double call to onVisibilityChange (#87607) [DOC] Adds missing link to Pyroscope core data source (#85493) Docs: Add Configuring Elasticsearch documentation for required privileges (#87593) Update dependency eslint-plugin-jsdoc to v48.2.4 Chore: Add login protection when user is trying different uppercase letters (#87588) Explore: lookup datasource by name when present in legacy URLs (#85222) Update dependency @prometheus-io/lezer-promql to v0.52.0 (#87554) Update dependency systemjs to v6.15.1 (#87594) Chore: Remove deprecated re-exported template variable types (#87459) Chore: Use getNextRefId instead of deprecated getNextRefIdChar (#87460) Chore: Remove use of deprecated method in AC code (#87541) Chore:: Update authlib version (#87603) Alerting: Reduce number of request fetching rules in the dashboard view using rtkq (#86991) refactor: rename variable ...
What is this feature?
This pull request resolves the issue of fetching dashboard alert rules twice within the dashboard view.
The problem was that while rendering the dashboard view we were mixing Redux store selects and RTKQ requests...leading to a loss of caching ability and duplicate requests.
To address this, I opted to use
RTK Query
for caching, aligning with our ongoing transition to this approach in the alerting codebase.For this, in this PR, a new
useCombinedRulesByDashboard
hook is created to return combined rules using RTKQ instead of the Redux store. This hook is used inusePanelCombinedRules
(necessary in the panel alert tab), and in theAlertRulesDrawerContent
.Actually, this change will only avoid duplicated requests in the
AlertRulesDrawerContent
and theUnifiedAlertStatesWorker
that are the ones using the same params in the request (dashboardId), while in the alert tab is using dashboardId + panelId parametersWhy do we need this feature?
Fetching rules twice , could be expensive.
Who is this feature for?
All users.
Special notes for your reviewer:
After the change:
Please check that: