43 Commits

Author SHA1 Message Date
8c54bba8d3 Alerting: Add details to the payload when tracking import to GMA (#106404)
add details to the payload when tracking import to GMA
2025-06-10 14:28:10 +02:00
80c47a64b1 Alerting: Add ability to import rules to GMA from Prometheus YAML (#105807)
* 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>
2025-05-29 15:12:24 +02:00
277d271476 Alerting: Add delete bulk action in the alert list view (#104611)
* 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>
2025-05-07 11:25:31 +02:00
0a8dccc19a Alerting: New alert list filter improvements (#103107)
* 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>
2025-04-11 10:02:34 +02:00
9b91dc7855 Alerting: Migration UI (#102010)
* 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>
2025-04-03 14:04:11 +01:00
f9471ac10b Alerting: Recover deleted alert rules (#101869)
* 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>
2025-03-27 16:39:26 +02:00
6822805c32 Grafana Runtime: Use package.json exports for internal code (#102100)
* refactor(frontend): update runtime import paths for grafana/runtime/src -> grafana/runtime

* feat(runtime): introduce internal api entrypoint and exports property

* refactor(frontend): update runtime imports to use internal entrypoint

* chore(betterer): update results file

* refactor(bookmarks): update runtime/unstable import

* chore(betterer): update results file

* test(frontend): fix failing tests due to mocking nested runtime imports

* test(datasourcesrv): fix failing tests due to mocks

* chore(alerting): clean up redundant import

* fix(packages): fix default require export pointing to types declaration file

* docs(packages): update readme related to exports

* chore(internationalization): fix import paths

* chore(betterer): update results file
2025-03-27 08:59:57 +01:00
adbc5b2b88 Alerting: Hide "unauthorized" warning for anonymous users (#101811)
* remove nav analytics

* revert

* Remove new user check for alerting navigation tracking

* Delete Analytics.test.ts
2025-03-11 12:51:48 +01:00
e73b78a134 Alerting: Rule history restore feature (#100609)
* 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>
2025-02-28 13:14:23 +02:00
2eaada17db Alerting: Track if new gm rules are created with queries and expressions transformable to simple mode (#101121)
track if new gm rules are created with queries and expressions transformable to simple mode
2025-02-21 14:50:29 +01:00
3bb3a74ac1 Alerting: Add tracking for the mode used in query and notifications step when c… (#100824)
Add tracking for the mode used in query and notifications step when creating a grafana rule
2025-02-17 18:09:02 +02:00
2014d27def Alerting: Add alert rule version history - part1 (#99490)
* 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>
2025-02-17 13:25:32 +01:00
4f7ffafe98 Alerting: Consistently order member imports in alerting code (#97688)
* Lint import member orders within alerting

* Consistently order member imports in alerting code
2024-12-10 17:42:33 +00:00
624f44fdb5 Alerting: Add new button for exporting new alert rule in HCL format (#96785)
* 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>
2024-11-25 11:52:28 +01:00
54cc666aa0 Alerting: Add useReturnTo hook to safely handle returnTo parameter (#96474)
Add useReturnTo hook to safely handle returnTo parameter

Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
2024-11-14 18:08:58 +02:00
0dd5373e4a Alerting: Add interactions for Fullstory (#94631)
add interactions for Fullstory
2024-10-11 19:23:58 +02:00
00381711a4 Alerting: useProduceNewRuleGroup for creating / updating alert rules. (#90497)
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
2024-08-22 15:57:23 +03:00
8423d06988 Alerting: Implement UI for grafana-managed recording rules (#90360)
* 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>
2024-07-26 13:52:22 +02:00
dbc755925d Alerting: Track central ash interactions (#90330)
* Track central ash interactions

* refactor
2024-07-19 11:11:29 +02:00
caeb9bcea2 Alerting: Template selector in contact points form (#87689)
* 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>
2024-05-24 13:35:48 +02:00
5e25afe6e9 Alerting: New settings page (#84501) 2024-05-03 17:42:42 +02:00
7a741a31bd Alerting: Track when switching from simplified routing to policies routing or vice versa (#83108)
Track when switching from simplified routing to policies routing or vice versa
2024-03-11 08:47:22 +01:00
f5dab6b5a5 Alerting: Refactor analytics to use pushMeasurements (#83850) 2024-03-07 16:41:38 +01:00
183a42b7f6 Alerting: Improve alert rule and search interaction tracking (#83217)
* Fix alert rule interaction tracking

* Add search component interaction tracking

* Add fine-grained search input analytics
2024-02-28 16:52:56 +01:00
572c182a81 Unify frontend monitoring (#80075)
* Unify frontend monitoring

* Add missing mock

* Add missing mock

* Keep source:sandbox

* Create separate logger for plugins/sql package

* chore: rename "logAlertingError" to "logError"

* Use internal Faro logging for debugging instead of redundant browser logging

* Post-merge fix

* Add more docs about debug levels

* Unify logger names

* Update packages/grafana-runtime/src/utils/logging.ts

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>

* Update packages/grafana-runtime/src/utils/logging.ts

Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>

---------

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
2024-02-01 15:08:40 +01:00
4fc0294aab Add logging prometheus and ruler rules totals (#76812) 2023-10-25 16:47:32 +02:00
68c25080e6 Alerting: Allow users to give feedback on each insights panel (#75990)
* Add menu to track user feedback on each pane;

* Add RatingModal component

* Open modal with panel header actions

* Fix lint
2023-10-05 09:02:18 -03:00
cad39b7397 Alerting: Revert "Alerting: Show annotations markers in TimeSeries panel when u… (#74576)
Revert "Alerting: Show annotations markers in TimeSeries panel when using Loki as … (#72084)"

This reverts commit de6ef53c8a317745a874ef6ce8dbb736369fb0af.
2023-09-08 10:57:31 +02:00
7baf9cc033 Alerting: Custom contact point for OnCall in Grafana AM (#72021) 2023-09-06 12:33:35 +02:00
27fb922f9b Alerting: Add new Recording Rule button when the list is empty (#73502)
* Add button to create RR when there are no alerts

* Remove unneeded import

* Change cards to be shown vertically
2023-08-22 13:05:22 -03:00
de6ef53c8a Alerting: Show annotations markers in TimeSeries panel when using Loki as … (#72084)
* 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
2023-08-01 12:00:39 +02:00
c67bafbd5a Alerting: Survey changes (#68043)
* Track alert rule list navigation

* Change min user creation date to 7 days

* Fix tests
2023-05-10 13:26:57 -03:00
15d4169813 Frontend logging: Remove Sentry javascript agent support (#67493)
* remove Sentry

* fix sourcemap resolve
2023-05-02 12:10:56 +03:00
93b32eec4b Alerting: fix users call 403 by calling /user instead of /users/{id} (#64544)
Fetch user data with calling /user endpoint

This avoids a permission error we were getting by calling /users/{id}
2023-03-10 09:56:01 -03:00
9e1ea8c990 Alerting: Avoid printing [object][Object] in error message (#64023)
Avoid printing [object][Object] in error message
2023-03-02 10:48:44 -05:00
3b2ec752fb Alerting: change context parameter type (#61197)
Change boolean value to string as the Faro API doesn't accept boolean types for the entries of the context object
2023-01-10 12:17:11 -03:00
7604360622 Alerting: Add info to alert rule creation metric (#61105)
Add extra info to alert rule creation metrics
2023-01-09 15:27:02 -03:00
115218b1ff Alerting: only track events for survey if user is not new (#61005)
* Only track events data if user is not new

To know this we evaluate the creation date to be older than two weeks

* Address PR comments
2023-01-09 14:41:03 -03:00
e3805e1309 Alerting: Track events for rule creation/abortion (#59912)
* 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
2022-12-14 11:50:15 -03:00
228ec4c0f3 Chore: Switch Grafana to using faro libraries (#58186) 2022-11-08 10:36:27 +01:00
a59dc8b7ad Alerting: Query time logging (#57585) 2022-10-31 15:55:47 +01:00
0d348dc0b1 Alerting: log alert rule creation and clicking state filters (#55698)
* 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
2022-10-03 11:00:19 -03:00
003a1cdaa0 Alerting: log some basic user interactions (#55401)
* 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
2022-09-23 08:51:16 -03:00