feat: add grafana create, update anddelete alert rules #3860
feat: add grafana create, update anddelete alert rules #3860WashingtonKK wants to merge 9 commits intosuperplanehq:mainfrom
Conversation
|
👋 Commands for maintainers:
|
| if resourceType != resourceTypeDataSource { | ||
| return []core.IntegrationResource{}, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
ListResources errors on unknown types when client fails
Low Severity
NewClient is now called before the resourceType switch, so if the integration isn't fully configured (e.g., missing API token), ListResources returns an error even for unknown resource types. Previously, the unknown-type check happened first and returned an empty list without attempting client creation. This changes the error contract for the default case from ([], nil) to (nil, error).
Additional Locations (1)
| eventId: execution.rootEvent.id, | ||
| }, | ||
| ]; | ||
| } |
There was a problem hiding this comment.
Duplicated event section builder across mapper files
Low Severity
buildGrafanaEventSections in alert_rule_shared.ts duplicates the logic of baseEventSections in query_data_source.ts. Both find the root trigger node, look up its renderer, extract the title, and return a single-element EventSection[] with the same fields. The minor differences (guard clauses, optional fallbacks) could be unified into one shared utility to avoid divergence during future maintenance.
Additional Locations (1)
… handler - Simplified instructions for connecting Grafana in `grafana.go`. - Enhanced `OnAlertFiring` trigger to support alert name filtering with predicates. - Updated webhook handler to manage shared secrets more effectively. - Added tests for alert name filtering and webhook handling. - Removed unused custom field renderer and related components. - Improved metadata handling in the Grafana webhook setup. - Refactored timestamp formatting utility to use timezone-aware functions. Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
…larity Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
… timestamp formatting Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
…ata handling Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
…al setup requirements Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
83e397a to
cf6ef60
Compare
|
Recreated on the renamed branch as #3873 (feat/grafana-alert-rules). Closing this PR so the active review thread stays on the new branch name. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| {Label: "OK", Value: "OK"}, | ||
| {Label: "Keep Last State", Value: "KeepLast"}, | ||
| } | ||
| } |
There was a problem hiding this comment.
Shared dropdown options invalid for execErrState field
Medium Severity
The alertRuleStateOptions() function is shared for both the noDataState and execErrState select fields, but Grafana's API accepts different valid values for each. The Grafana provisioning API accepts NoData, Alerting, OK, KeepLast for noDataState, but Error, Alerting, OK, KeepLast for execErrState. The shared options include NoData (invalid for execErrState) and omit Error (a valid execErrState value). Selecting "No Data" for execution error state causes an API rejection.


Implements: #3850
This expands the Grafana Integration by adding three components:
grafana.CreateAlertRulegrafana.UpdateAlertRulegrafana.DeleteAlertRuleDemo Video
Note
Medium Risk
Adds new Grafana provisioning API interactions (alert rules + notification policy route upserts/removals) and changes webhook secret management/filtering, which could affect alert delivery and provisioning behavior if Grafana API responses differ from expectations.
Overview
Extends the Grafana integration with new alert-rule components:
grafana.createAlertRule,grafana.getAlertRule, andgrafana.updateAlertRule, including shared config/schema/validation and example outputs.Updates the Grafana client and webhook handler to provision notification policy routes (in addition to contact points), generate/persist webhook bearer secrets in webhook storage (legacy
sharedSecretstill supported), and optionally filter alert webhooks byalertnamepredicates consistently across provisioning and runtime.Enhances resource pickers and UI: adds listable
folder/alert-ruleintegration resources, switches Query Data SourcetimeFrom/timeToto datetime fields with a default lookback, improves execution detail rendering (timestamp formatting + query result summary), and refreshes Grafana docs/instructions accordingly.Written by Cursor Bugbot for commit cf6ef60. This will update automatically on new commits. Configure here.