* re-organize folders regarding import feature
* Revert folder changes
* Add Yaml import input fields
* Set recording rules target if empty
* wip
* Convert YAML content to RulerRulesConfigDTO and use this for the import payload
* fixing some issues
* wip
* add tracking
* use yaml filename for namespace in case is not specified in the yaml content
* refactor
* add alertingImportYAMLUI ff check for yaml option
* Add test for parseYamlToRulerRulesConfigDTO
* move import feature to the More menu at the top
* add test for filterRulerRulesConfig, and fix the function
* extract parseYamlToRulerRulesConfigDTO to a separate file
* Add permission check for the import button
* Change data flow in import form, add basic tests for the import form
* remove commented code
* Add yaml import form test
* Add more tests
* Tidy up, remove type assertions in yaml converter
* Improve yaml file validation in the form
* Fix lint issues
* Fix lint
* use only Admin role for checking if the feature is available for the user
* Fix parsing recording rules
* Fix file re-selection in YAML import
* prettier
* refactor
* Remove FileReader, add more explanation to file upload reset
---------
Co-authored-by: Konrad Lalik <konradlalik@gmail.com>
* Add pause/unpause bulk actions button in the alert list view
* add delete bulk action
* Add tracking and refactor FolderActionMenuItem
* update translations and text
* update text
* add finally
* use ability for delete action
* don't show bulk actions if no action is allowed
* invalidate tags for delete action
* revert invalidating and redirect to list page instead
* redirect when pausing/unpausing
* add pause/unpause endpoints
* add translations
* add folder name in delete modal
* address pr review
* disable pause/unpause
* update redirect
* remove unnecessary prop
* rename FolderActionMenuItem component to PauseUnpauseActionMenuItem
* address review comments
* fetch rules before redirecting in list view 1
---------
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
Co-authored-by: Mariell Hoversholm <mariell.hoversholm@grafana.com>
* Move filtering code to generators for performance reasons
Discarding rules and groups early in the iterable chain limits the number of promises we need to wait for which improves performance significantly
* Add error handling for generators
* Add support for data source filter for GMA rules
* search WIP fix
* Fix datasource filter
* Move filtering back to filtered rules hook, use paged groups for improved performance
* Add queriedDatasources field to grafana managed rules and update filtering logic to rely on it
- Introduced a new field `queriedDatasources` in the AlertingRule struct to track data sources used in rules.
- Updated the Prometheus API to populate `queriedDatasources` when creating alerting rules.
- Modified filtering logic in the ruleFilter function to utilize the new `queriedDatasources` field for improved data source matching.
- Adjusted related tests to reflect changes in rule structure and filtering behavior.
* Add FilterView performance logging
* Improve GMA Prometheus types, rename queried datasources property
* Use custom generator helpers for flattening and filtering rule groups
* Fix lint errors, add missing translations
* Revert test condition
* Refactor api prom changes
* Fix lint errors
* Update backend tests
* Refactor rule list components to improve error handling and data source management
- Enhanced error handling in FilterViewResults by logging errors before returning an empty iterable.
- Simplified conditional rendering in GrafanaRuleLoader for better readability.
- Updated data source handling in PaginatedDataSourceLoader and PaginatedGrafanaLoader to use new individual rule group generator.
- Renamed toPageless function to toIndividualRuleGroups for clarity in prometheusGroupsGenerator.
- Improved filtering logic in useFilteredRulesIterator to utilize a dedicated function for data source type validation.
- Added isRulesDataSourceType utility function for better data source type checks.
- Removed commented-out code in PromRuleDTOBase for cleaner interface definition.
* Fix abort controller on FilterView
* Improve generators filtering
* fix abort controller
* refactor cancelSearch
* make states exclusive
* Load full page in one loadResultPage call
* Update tests, update translations
* Refactor filter status into separate component
* hoist hook
* Use the new function for supported rules source type
---------
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
* add feature toggle alertingMigrationUI
* wip
* wip
* wip2
* add button to export in alert list and add target folder in the form
* update namings
* protext migration route with alertingMigrationUI feature toggle
* remove unused error style
* add namspace and group filter
* fix translations and prettier
* fix duplication
* use the new endpoint
* update right roles for the FE route
* refactor
* notify success
* address feedback
* fix translations
* Simplify migration UI for alert rules to GMA format
Extracts migration button component and reuses it in banner for better
code organization and consistency.
* Fix root folder check in import alert rules UI
Replace hardcoded empty string check with lodash isEmpty for folder UID
validation
* Add collapsible section for import rule options
* address feedback
* Split useAlertRuleSuggestions, one for labels, and other for namespaces
* refactor splited hooks
* Alerting: (PR review) Redesign slightly + use combobox (#102614)
Redesign slightly + use combobox
* udpate naming
* remove eslint-disable-next-line @grafana/no-untranslated-strings and add hasDataSourcesConfigured as a condition to render the banner
* use button instead of banner
* fix routes
* use new api
* update api
* remove query params
* update translations
* update ff files
* skip subpath when redirecting to the alert list view with filters
* prettier
* disable provenance
* prettier
* Don't send target forlder uid in the payload as undefined if it's not selected
* prettier
* add confirmation modal with a preview
* remove unnecessary export
* Add target datasource UID for recording rules
* Use skipToken
* Add recording rule datasource and update designs
* Use different hook to fetch rulerRules
---------
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
* add column guid to alert rule table and rule_guid to rule version table
+ populate the new field with UUID
* update storage and domain models
* patch GUID
* ignore GUID in fingerprint tests
* get alert rule versions by GUID
* update rule delete to reset uid in history instead of deleting rows
* add test
* Update delete rule to require UserUID, remove all versions and create "delete" version
that holds information about who and when deleted the rule
* update usages of the delete method
* add list deleted rules to store
* list api to support deleted query parameter
* add list deleted rules to store
^ Conflicts:
^ pkg/services/ngalert/store/alert_rule_test.go
* list api to support deleted query parameter
* Restore deleted rules
* fix recovering manually recording rules
* update role control for the trash route
* add alertingRuleRecoverDeleted feature toggle enabled by default
* fix access control for trash menu item in the navtree
* Add alertingRuleRecoverDeleted feature toggle,
add Delete permanently alert rule menu option
* hide remove permanently functionality in the UI until we have the api available for it
* discard wrong changes after merging
* Reverted changes in pkg/apis/dashboard_manifest.go after fixing conflicts
* Reverted changes in go.work.sum after fixing conflicts
* Reverted changes in pkg/apis/dashboard_manifest.go after fixing conflicts
* Reverted changes in pkg/services/ngalert/models/alert_rule.go after fixing conflicts
* Reverted changes in pkg/apis/dashboard_manifest.go after fixing conflicts
* restore delete permanently and add the queryparam for it
* update snapshots
* fix translations
* protect trash route by the feature toggles
* use the new rulerRuleType for checks
* revert ability to delete permanently and alert rule from the ui
* remove unnecessary update after reverting
* fix ff
* add tracking
* use recently deleted instead of trash
* create isRecoverDeletedRulesEnabled for checking ffs
* address pr feedback 1
* include alert rule uid in getRowId
* use RulerGrafanaRulesConfigDTO for deleted rules response
* use isLoading in the AlertingPageWrapper
* fix wrong check for recording rules type
* add test for restoring manually through the alert rule form
* add test for restoring deleted rule
* use importAlertingComponent
* udpate mock
* address pr feedback
* update translations
* address feedback
* address feedback 2
* address feedback 3
* address feedback 4
* move transformation of the response to the endpoint
* fix typo
* refactor grafanaRuleDtoToFormValues
* update translations
* use guid for identifying rows
* prettier
* use ONLY the guid for identifying rows
* Add provides/invalidates tags for deleted rules
---------
Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
* Restore feature: wip
* Refactor modal to separate component
* fix restoring from the drawer
* rename components folder to version-history, and move version-utils.file there
* skip fetching rule when uid is empty, add returnTo when restoring manually
* Fix drawer fetching infinitely
* Move drawer to separate file
* add tracking for restore success and restore failure
* Fix name of error interaction
* Add `compare` to each row in version history
* Add warning when manually restoring and trigger form validation
* Fix initial validation for contact point selector
* Wait for successful fetch before potential error
* Add disabled state when loading
* Fix loading check for contact point selector
* Fix typo
* Move hook to separate file and move other method into utils
* Update imports and remove manual state management
* Fix infinite render
* Remove onError from dep array
* Use separate flag for showing manual restore alert
* Rename to createdAt
* add and use ability to restore to check if retore is allowed
* Fix test and add isGrafanaManagedAlertRule to the ability check
* Address PR feedback
* Change to isManualRestore for trigger check
* udpate AlertRuleAction.Restore ability
* make the alertingRuleVersionHistoryRestore ff , enabled by default
* fix ff
---------
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
* Add alertingRuleVersionHistory feature toggle
* WIP: Add version history tab
* revert temp change in index.ts
* wip2
* --wip--
* sync code with the BE changes in the endpoint
* add translations
* Add translations
* use ff only for restore feature
* WIP: Add tracking, make version required, and start mapping dif results
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
* Tweak more translations and improve types
* Add button to show/hide JSON diff
* update type for top level rule fields
* Create types
* Make updated_by/version properties optional
* Update mocks to remove updated by and version
* add comments to restore code
* rename fetature flag, as we use this one only for the restore feature
* Update version history to handle special cases
* Add diff numbers
* Fix conflicts
* Move generic computeVersionDiff to a utils file
* Update DOM structure of version summary and tidy up types
* Add tests for version comparison logic
* Lint fix utils file
* Rename props and add docs
* Change to EmptyState and log when no versions
* Remove CreatedBy component and simplify
* Add missing i18n for version history
* add test for computeVersionDiff
* update test
* fix number diff order and add a test
* fix prettier
* fix prettier
* Add promise resolve back in
* Rename to humanReadableDiff and tweak translation
* Show tab for recording rules as well
* Split components out to separate files
* Add optional interval seconds
* Update i18n
* Remove commented code
* Remove value
* Remove unneeded version
* Consistent rendering of updated by
* Mode parseVersionInfo to a separate pure function
* update invalidate/provide tags for getAlertVersionHistory
* Use checkedVersions state only in the parent component
* update getSpecialUidMap name and create an interface
* Fix prettier
* update tab description
* use set instead of map for checkedVersions
---------
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
* add new button for exporting new alert rule
* Fix test
* allow only HCL format for exporting new alert rule
* fix initial tab
* Update public/app/features/alerting/unified/components/rule-editor/alert-rule-form/ModifyExportRuleForm.tsx
Co-authored-by: Konrad Lalik <konradlalik@gmail.com>
* Update public/app/features/alerting/unified/components/rule-editor/alert-rule-form/ModifyExportRuleForm.tsx
Co-authored-by: Konrad Lalik <konradlalik@gmail.com>
* address review comments
* update translations
---------
Co-authored-by: Konrad Lalik <konradlalik@gmail.com>
* Implement UI for grafana-managed recording rules
* use undefined for the duration instead of null , for recording rules
* Fix tests
* add tests
* Add pause functionality for grafana recording rules
* update translations
* remove obsolete snapshot
* use createUrl instead of renderUrl
* refactor
* Add validation for grafana recording rule name
* create util functions for rule types and add record field in mock function
* add util isDatatSourceManagedRuleByType
* refactor
* Add metric field in alert rule form
* fix alert name component
* update width for alert name and metric
* fix test
* add validation back to cloud recording rules name
* Alerting: Recording rules PR review (#90654)
Update type helper methods
* add slash in createUrl
* fix baseurl in the returnTo
* nits
* Add metric on expanded row in the alert list view
* nits
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
* update snapshot
---------
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
* WIP
* Refactor and update how we display these fields in the form
* Add test for getTemplateOptions and udpate parseTemplates to handle minus simbol
* fix betterer
* Fix wrapper
* Create new usePreviewTemplate to be reused from TemplatePreview and TemplateContentAndPreview
* remove unnecessary check
* track interactions
* Include the whole content of the template in the preview
* Update parseTemplates function to return default templates
* handle nested templates in parseTemplates function
* Missing border fixed, whitespaces preserved and no empty space at the bottom
* remove unused styles and add a comment in test
* Add missing error in getPreviewResults
* fix styles for template selector containers
* Alerting: PR feedback to move default templates into RTKQ (#88172)
Move default templates to RTKQ API + constant
* move parseTemplates to a utils file and refactor last part of this function
* Keep selected options when loading exising input and when switching between tabs
* Update descritpion in tabs
* Fix not previewing when loading existing values
* Update text addressing Brenda's feedback
* Add test for matchesOnlyOneTemplate function
* Add minheight to viewer container and fix getContentFromOptions function
---------
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
Revert "Alerting: Show annotations markers in TimeSeries panel when using Loki as … (#72084)"
This reverts commit de6ef53c8a317745a874ef6ce8dbb736369fb0af.
* WIP: Show annotations markers in TimeSeries panel when using Loki as alert state history
* WIP changes
* Fix converting log records to data frame for panel
* Move fetching alert state history with Loki to the PannelQueryRunner to keep the panel flow
* use dasboardUID and panelUID for requesting Loki ash
* fix wrong prettier change
* Only request loki ash when having alertstate
* Use panelID as param in history query
* Refactor: move getRuleHistoryRecordsForPanel and remove filtering code as is not used
* Adress PR review comments
* Add try catch for ash request
* Add tests for updatePanelDataWithASHFromLoki method
* Address PR review suggestions
* review suggestion
* Add test for logRecordsToDataFrameForPanel method
* pr Review nit suggestion
* Dont show toast messages from Loki request
* Track events for rule creation/abortion
These events will be sent to Rudderstack using the EchoSrv in order to be consumed from Intercom
* Change method names and send user_id
* Track validation errors
* Only track errors for rule creation
* Add messages for new trackings
* Track clicking on alert state filters
* Track creating alert rule from panel
* Track creating alert rule from scratch
* Track on success and when cancelling a rule creation
* Log leaving rule group edit without saving
* Log filtering alert instances by label
Also debouncing the search to prevent sending too many log requests
* Log loading the Alert Rules list
* Move log messages to centralized location
* Add tests on log trackings
* Fix linting