Skip to content

RCA of terminate_after - #3

Open
RyanL1997 wants to merge 1 commit into
mainfrom
terminate-after-issue-rca
Open

RCA of terminate_after#3
RyanL1997 wants to merge 1 commit into
mainfrom
terminate-after-issue-rca

Conversation

@RyanL1997

Copy link
Copy Markdown
Owner

Description

Issues Resolved

Screenshot

Testing the changes

Changelog

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Jialiang Liang <jiallian@amazon.com>
RyanL1997 pushed a commit that referenced this pull request Jul 16, 2026
…ch-project#12168)

* feat: Add Create alert rule button to Metrics page

Adds a 'Create alert rule' entry point at the top of the Metrics page
that opens a flyout pre-populated with all current PromQL queries.
Each query becomes a separate Cortex alerting rule with configurable
threshold, operator, and for-duration.

- Add CreateMetricsRuleFlyout component
- Add button to metrics_page_tabs toolbar (visible in both Explore/Query tabs)
- Read queries from QueryStringManager (no Update click required)
- Support multi-query rule group creation via POST /api/alerting/prometheus/{dsId}/rules

Signed-off-by: Riya Saxena <riysaxen@amazon.com>

* fix: Fix deriveRuleName for wrapped PromQL and test timer handling

- deriveRuleName now extracts inner metric name from function wrappers
  (e.g., rate(http_requests_total[5m]) -> http_requests_total)
- Tests use fake timers to handle async save/poll/close flow
- Add http.get mock for polling logic

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

* test: Add dedicated unit tests for deriveRuleName regex patterns

- Export deriveRuleName for direct testing
- Add parameterized tests covering: function-wrapped metrics,
  simple metric names, label selectors, nested functions, and fallback

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

* fix: Read selected metric from Explore tab for alert rule creation

When on the Explore tab, parsedQueries now falls back to reading
metricsExploreState.metric from Redux state, so the Create alert rule
flyout pre-populates with the selected metric name instead of showing
'No queries to create rules from'.

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

* test: Add Explore tab integration tests for flyout

- Verify single metric from Explore tab renders one rule card
- Verify plain metric name derives correct rule name

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

* fix: Simplify flyout save states - show 'Creating in Prometheus...' throughout

- Remove separate 'Confirming rule creation...' state from button
- Show 'Creating in Prometheus...' for the entire save duration
- Toast now says 'N alert rule(s) created successfully' (matches Rules tab UX)

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

* fix: Pass addToast to flyout so success/error toasts are shown

Wire services.notifications.toasts to the CreateMetricsRuleFlyout
addToast prop so users see 'N alert rule(s) created successfully'
toast on save, matching the Rules tab UX.

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

* fix: Remove 90s polling from Metrics page flyout — close immediately on success

Match the optimistic pattern from the Rules tab: POST rules, show success
toast, close flyout immediately. Removed 'confirming' state, http.get
prop (no longer needed for polling), and the 18x5s polling loop.

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

* fix: Address lezzago + joshuali925 review comments

- Deduplicate rule names to prevent Cortex group overwrites (lezzago)
- Prevent flyout close during active save (lezzago)
- Fix threshold input to allow decimals/negatives (joshuali925 #3)
- Use splitMultiQueries helper instead of hand-rolled splitter (joshuali925 #2)
- Remove 'as any' cast on http prop (joshuali925 #5)

Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>

---------

Signed-off-by: Riya Saxena <riysaxen@amazon.com>
Signed-off-by: Riyaz Saxena <riysaxen@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant