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

Alerting: Reduce number of request fetching rules in the dashboard view using rtkq #86991

Merged
merged 17 commits into from May 10, 2024

Conversation

soniaAguilarPeiron
Copy link
Member

@soniaAguilarPeiron soniaAguilarPeiron commented Apr 26, 2024

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 in usePanelCombinedRules (necessary in the panel alert tab), and in the AlertRulesDrawerContent.

Actually, this change will only avoid duplicated requests in the AlertRulesDrawerContent and the UnifiedAlertStatesWorker that are the ones using the same params in the request (dashboardId), while in the alert tab is using dashboardId + panelId parameters

Why 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:

Screenshot 2024-04-26 at 14 25 55

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@soniaAguilarPeiron soniaAguilarPeiron added this to the 11.1.x milestone Apr 26, 2024
@soniaAguilarPeiron soniaAguilarPeiron self-assigned this Apr 26, 2024
@soniaAguilarPeiron soniaAguilarPeiron requested review from a team as code owners April 26, 2024 12:58
@soniaAguilarPeiron soniaAguilarPeiron requested review from oscarkilhed, kaydelaney, gillesdemey, tomratcliffe and konrad147 and removed request for a team April 26, 2024 12:58
@soniaAguilarPeiron soniaAguilarPeiron force-pushed the alerting/reduce-requests-in-dashboard-view branch 2 times, most recently from 4be1a3f to 2372877 Compare April 29, 2024 08:08
@soniaAguilarPeiron soniaAguilarPeiron force-pushed the alerting/reduce-requests-in-dashboard-view branch from 2372877 to 9613576 Compare April 29, 2024 08:15
@gillesdemey
Copy link
Member

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/dashboard-scene/scene/AlertStatesDataLayer.ts) – which I believe is going to be enabled for everyone in cloud and the old query runner is in code freeze.

@soniaAguilarPeiron soniaAguilarPeiron force-pushed the alerting/reduce-requests-in-dashboard-view branch from 9dda6db to c9b219b Compare April 30, 2024 11:32
@soniaAguilarPeiron soniaAguilarPeiron force-pushed the alerting/reduce-requests-in-dashboard-view branch from d29a532 to 9a4b019 Compare April 30, 2024 11:47
@soniaAguilarPeiron soniaAguilarPeiron force-pushed the alerting/reduce-requests-in-dashboard-view branch from 9a4b019 to 40708e8 Compare April 30, 2024 11:52
Copy link
Member

@gillesdemey gillesdemey left a 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();

Copy link
Member Author

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

Copy link
Member

@axelavargas axelavargas left a 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.

@soniaAguilarPeiron soniaAguilarPeiron merged commit 4b72020 into main May 10, 2024
14 checks passed
@soniaAguilarPeiron soniaAguilarPeiron deleted the alerting/reduce-requests-in-dashboard-view branch May 10, 2024 10:27
obetomuniz added a commit that referenced this pull request May 10, 2024
…-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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants