Commit Graph
100 Commits
Author SHA1 Message Date
Tom RatcliffeandGilles De Mey 9ec48075ee Alerting: Fix escaping of silence matchers in utf8 mode (#95067)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2024-10-24 14:12:09 +01:00
Tom Ratcliffe 4c5483ee15 Alerting: Fix notification policies tests and implement "stateful" mock endpoints (#94732) 2024-10-17 11:57:57 +01:00
Tom Ratcliffe dfe2d5eb98 Alerting: Fix display of quotes in expression component (#94807) 2024-10-16 16:12:35 +03:00
Tom Ratcliffe 0841497cad Alerting: Show a warning when a template has been potentially misconfigured (#94698) 2024-10-15 14:00:20 +03:00
Tom Ratcliffe b91b9a1e38 Alerting: Use jest/expect-expect rule to check for assertions (#93112) 2024-10-11 13:08:50 +03:00
Tom Ratcliffe f08de95630 Alerting: Change styling so query results with no labels are clearer (#94404) 2024-10-11 10:54:15 +01:00
Tom RatcliffeandSonia Aguilar 074831153a Alerting: Config tracker - update link for default contact point (#94384)
Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
2024-10-10 10:18:36 +01:00
Tom Ratcliffe f6abde3328 Alerting: Remove accesscontrol license feature requirement for contact points RBAC (#94418) 2024-10-10 10:18:25 +01:00
Tom Ratcliffe af82dfa95d Alerting/Chore: Fix TimeRangeInput not working across multiple months (#93622) 2024-09-30 10:26:07 +01:00
Tom Ratcliffe 0b2478859a Alerting: Allow linking to silence form with __alert_rule_uid__ value preset (#93526) 2024-09-30 09:20:53 +01:00
Tom Ratcliffe e4698d9c52 Alerting: Fix eval interval not being saved when creating a new group (#93821) 2024-09-30 09:19:01 +01:00
Tom RatcliffeandMatt Jacobson fc51ec70ba Alerting: Add manage permissions UI logic for Contact Points (#92885)
* Add showPolicies prop

* Add manage permissions component for easier reuse within alerting

* Add method for checking whether to show access control within alerting

* Remove accidental console.log from main

* Tweak styling for contact point width and add manage permissions drawer

* Improve typing for access control type response

* Add basic test for manage permissions on contact points list

* Only show manage permissions if grafana AM and alertingApiServer is enabled

* Update i18n

* Add test utils for turning features on and back off

* Add access control handlers

* Update tests with new util

* Pass AM in and add tests

* Receiver OSS resource permissions

There is a complication that is not fully addressed: Viewer defaults to read:*
and Editor defaults to read+write+delete:*

This is different to other resource permissions where non-admin are not granted
any global permissions and instead access is handled solely by resource-specific
permissions that are populated on create and removed on delete.

This allows them to easily remove permission to view or edit a single resource
from basic roles.

The reason this is tricky here is that we have multiple APIs that can
create/delete receivers: config api, provisioning api, and k8s receivers api.
Config api in particular is not well-equipped to determine when creates/deletes
are happening and thus ensuring that the proper resource-specific permissions
are created/deleted is finicky.

We would also have to create a migration to populate resource-specific
permissions for all current receivers. This migration would need to be reset so
it can run again if the flag is disabled.

* Add access control permissions

* Pass in contact point ID to receivers form

* Temporarily remove access control check for contact points

* Include access control metadata in k8s receiver List & Get

GET: Always included.
LIST: Included by adding a label selector with value `grafana.com/accessControl`

* Include new permissions for contact points navbar

* Fix receiver creator fixed role to not give global read

* Include in-use metadata in k8s receiver List & Get

GET: Always included.
LIST: Included by adding a label selector with value `grafana.com/inUse`

* Add receiver creator permission to receiver writer

* Add receiver creator permission to navbar

* Always allow listing receivers, don't return 403

* Remove receiver read precondition from receiver create

Otherwise, Creator role will not be able to create their first receiver

* Update routes permissions

* Add further support for RBAC in contact points

* Update routes permissions

* Update contact points header logic

* Back out test feature toggle refactor

Not working atm, not sure why

* Tidy up imports

* Update mock permissions

* Revert more test changes

* Update i18n

* Sync inuse metadata pr

* Add back canAdmin permissions after main merge

* Split out check for policies navtree item

* Tidy up utils and imports and fix rules in use

* Fix contact point tests and act warnings

* Add missing ReceiverPermissionAdmin after merge conflict

* Move contact points permissions

* Only show contact points filter when permissions are correct

* Move to constants

* Fallback to empty array and remove labelSelectors (not needed)

* Allow `toAbility` to take multiple actions

* Show builtin alertmanager if contact points permission

* Add empty state and hide templates if missing permissions

* Translations

* Tidy up mock data

* Fix tests and templates permission

* Update message for unused contact points

* Don't return 403 when user lists receivers and has access to none

* Fix receiver create not adding empty uid permissions

* Move SetDefaultPermissions to ReceiverPermissionService

* Have SetDefaultPermissions use uid from string

Fixes circular dependency

* Add FakeReceiverPermissionsService and fix test wiring

* Implement resource permission handling in provisioning API and renames

Create: Sets to default permissions
Delete: Removes permissions
Update: If receiver name is modified and the new name doesn't exist, it copies
the permissions from the old receiver to the newly created one. If old receiver
is now empty, it removes the old permissions as well.

* Split contact point permissions checks for read/modify

* Generalise getting annotation values from k8s entities

* Proxy RouteDeleteAlertingConfig through MultiOrgAlertmanager

* Cleanup permissions on config api reset and restore

* Cleanup permissions on config api POST

note this is still not available with feature flag enabled

* Gate the permission manager behind FF until initial migration is added

* Sync changes from config api PR

* Switch to named export

* Revert unnecessary changes

* Revert Filter auth change and implement in k8s api only

* Don't allow new scoped permissions to give access without FF

Prevents complications around mixed support for the scoped permissions causing
oddities in the UI.

* Fix integration tests to account for list permission change

* Move to `permissions` file

* Add additional tests for contact points

* Fix redirect for viewer on edit page

* Combine alerting test utils and move to new file location

* Allow new permissions to access provisioning export paths with FF

* Always allow exporting if its grafana flavoured

* Fix logic for showing auto generated policies

* Fix delete logic for contact point only referenced by a rule

* Suppress warning message when renaming a contact point

* Clear team and role perm cache on receiver rename

Prevents temporarily broken UI permissions after rename when a user's source of
elevated permissions comes from a cached team or basic role permission.

* Debug log failed cache clear on CopyPermissions

---------

Co-authored-by: Matt Jacobson <matthew.jacobson@grafana.com>
2024-09-27 19:56:32 +01:00
Tom Ratcliffe cc68f1b673 Alerting: Fix sending secure settings when using K8S API for contact points (#93498) 2024-09-23 14:02:58 +01:00
Tom Ratcliffe f9796f05fe Alerting: Fix sending secure settings when using k8s API (#93320) 2024-09-13 15:01:05 +03:00
Tom Ratcliffe 03c48844dd Chore: Remove MSW worker from source control and rely on installation instead (#93268) 2024-09-12 16:03:50 +03:00
Tom Ratcliffe ef486133c2 Alerting: Make query wrapper match up datasource UIDs if necessary (#93057) 2024-09-09 14:01:46 +01:00
Tom Ratcliffeandjoshhunt aec73f3501 Alerting/Chore: Mock API (MSW) in browser (#89223)
Co-authored-by: joshhunt <josh@trtr.co>
2024-09-04 10:22:03 +01:00
Tom Ratcliffe 13ea3d85ae Alerting: Fix preview of silences when label name contains spaces (#92802) 2024-09-03 09:14:11 +01:00
Tom Ratcliffe d1dc595692 Alerting: Fix target rule group for moving alert rule group (#92816) 2024-09-02 15:28:12 +01:00
Tom Ratcliffe 9f5dca96f2 Alerting: Don't redirect after failed contact point creation (#92761) 2024-08-30 16:04:46 +01:00
Tom Ratcliffe 172662af58 Alerting: Stop rule state view from crashing when prom rule state is missing (#91483) 2024-08-30 14:47:28 +01:00
Tom RatcliffeandTobias Skarhed 3262f0256e A11y: Fix some accessibility issues on the build error page (#92691)
Co-authored-by: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com>
2024-08-30 13:42:45 +01:00
Tom Ratcliffe 690fbe6077 Alerting: Edit, create and delete contact points via k8s API (#91701) 2024-08-30 12:10:30 +01:00
Tom Ratcliffe 6298825cf7 Alerting: Consolidate mute timings selector logic (#92372) 2024-08-29 15:09:53 +01:00
Tom RatcliffeandGilles De Mey e2a1d59a96 Alerting: Remove disable logic for name field on time intervals when using k8s API (#91885)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2024-08-19 14:53:12 +01:00
Tom Ratcliffe 8136fbef1f Chore: Add capability for overriding local development behaviour using env vars (#85603) 2024-08-13 13:07:42 +01:00
735954386f Alerting: Consolidate contact points dropdown and add filter in alert rules (#91690)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
2024-08-13 12:56:13 +01:00
Tom Ratcliffe 3ec2084c23 Alerting: Remove all but one usage of TestProvider within test code (#91542) 2024-08-07 10:58:58 +01:00
Tom Ratcliffe 2eae30aeff Alerting: Add jest-dom eslint recommended rules (#91576) 2024-08-06 15:39:46 +01:00
Tom Ratcliffe 2be2f8a214 Alerting: Tidy up k8s utilities/constants (#91571) 2024-08-06 14:57:43 +03:00
Tom Ratcliffe b4a23e097a Alerting: Add types to react hook form usage register method (#91566) 2024-08-06 12:29:01 +01:00
Tom Ratcliffe 338b318bf4 Alerting: Use alerting API server for contact points list (#91073) 2024-08-05 16:01:48 +03:00
Tom Ratcliffe 734af2ea9f Alerting: Enable "dot-notation" rule (#91497) 2024-08-05 12:06:17 +01:00
Tom Ratcliffe 500ae2ff1e Alerting: Enable "prefer-const" rule (#91495) 2024-08-05 11:37:48 +03:00
Tom Ratcliffe e771500487 Alerting: Enable "no-unused-props" rule (#91492) 2024-08-05 09:18:38 +01:00
Tom Ratcliffe 1d96cd8ed9 Alerting: Use cloud notifier types for metadata on Cloud AMs (#91054) 2024-08-02 10:30:39 +01:00
Tom Ratcliffe 17067824fb Alerting: Conditionally use k8s API for simplified routing contact points selector (#90901) 2024-08-01 14:41:40 +01:00
Tom Ratcliffe 6c64d1d443 Alerting: Consume k8s Time Intervals API (#90094) 2024-07-31 16:59:15 +03:00
Tom Ratcliffe 562380079f Alerting: Chore - remove unused alerting upgradeApi (#91250) 2024-07-31 12:57:48 +01:00
Tom Ratcliffe 6fcf594b32 Alerting: Add eslint testing-library plugin dependency and create separate ESLint config (#91052) 2024-07-30 15:16:54 +03:00
Tom Ratcliffe e877b82af7 Chore: Update imports from RTKQ (#91182) 2024-07-30 12:10:18 +01:00
Tom Ratcliffe 9d639278f4 Alerting: Refactor simplified routing contact points hook (#90762) 2024-07-29 19:22:31 +03:00
Tom Ratcliffe 604c99f137 Alerting: Don't show success message after updating AM config (#90934) 2024-07-29 12:02:34 +01:00
Tom Ratcliffe 4e364ea043 Alerting: Split out contact points components to separate files (#90605) 2024-07-22 10:54:13 +03:00
Tom Ratcliffe a61cd94a70 Alerting: Tidy up contact points/misc other tests' mock server behaviour (#90469) 2024-07-19 16:11:48 +01:00
Tom Ratcliffe 7829fced94 Alerting: Hide edit/view rule buttons according to deleting/creating state (#90375) 2024-07-19 09:55:12 +00:00
Tom Ratcliffe 79df1b1e10 Alerting: Remove some unused mock server methods (#90432)
Remove some unused mock server methods
2024-07-17 16:50:25 +02:00
Tom Ratcliffe 919bc47dba Alerting: Move alertmanager warning to consistent place within notification policies (#90521)
Move alertmanager warning to consistent place within notification policies
2024-07-17 16:46:00 +02:00
Tom Ratcliffe 0547a9ed88 Alerting: Remove unneeded uses of setBackendSrv in alerting tests (#90380) 2024-07-15 09:09:24 +01:00
Tom Ratcliffe 5d8ca38b9b Alerting: Fix Recording Rules creation issues (#90362) 2024-07-12 15:52:45 +01:00
Tom Ratcliffe f140594cf1 Alerting: Make whitespace more visible on labels (#90223) 2024-07-11 17:33:27 +01:00
Tom Ratcliffe b18b1efec4 Alerting: Add (manual) script to generate alerting RTKQ APIs from OpenAPI spec (#89482) 2024-07-02 18:31:37 +01:00
Tom Ratcliffe 86d41b1e23 Alerting: Update warning message for Telegram parse_mode and default to empty value (#89630) 2024-06-27 10:33:40 +01:00
Tom Ratcliffe c88de7f4d0 Alerting: Don't crash the page when trying to filter rules by regex (#89466) 2024-06-20 16:24:49 +01:00
Tom Ratcliffe 3badf73b45 Alerting: Fix setting of existing Telegram Chat ID value (#89287) 2024-06-18 14:24:23 +01:00
Tom Ratcliffe 2dd44e2f58 Alerting: Remove duplicated alertRule handlers file and usage (#89100) 2024-06-14 13:42:00 +02:00
Tom Ratcliffe a9171aa9fe Alerting: Fix display of falsy alert values in state history (#89156) 2024-06-14 13:41:01 +02:00
Tom Ratcliffe 26233e98a8 Alerting: Fix saving telegram contact point to Cloud AM config (#89182)
* Add test for saving telegram contact point to AM config

* Fix default value for select options in AM config
2024-06-14 10:56:25 +01:00
170d476bdc Alerting: Add RBAC logic for silences creation (#87322)
* Remove role requirement for editing silence (instead handled by silence editor displaying error)

* Send query params for metadata/access control silence logic

* Add new access control types to enum

* Add folder-specific checks for silences

* Remove filtering in alert manager picker

* fix flakey rule viewer test and update permissions helper

* Use `returnTo` in rule viewer page

* Fix incorrect display of duration

* Clean up some mock server behaviour in rule details tests

* Tweak styles for silences alerts table

* Remove alertmanager picker from silences drawer

* Add error if user cannot edit a silence

* Show alert rule name in silences table and consume RBAC logic

* Update mocks to include RBAC access control logic

* Update silences tests

* Update silences type to include access control info

* Update comment for missing alertmanager

* Update mock handlers and query param logic

* Tweak query params again

* Update access control mock

* Revert AM picker fix as user may not have access to Grafana AM

* Swap ternary order

* Change text for no alert rule targeted

* Don't show error alert from RTKQ query and remove alert instance preview in case of error

* Add missing translations

* Fix test adding missing mock for getting alert rule

* Add missing translations in SilencesTable

* Add translations autogenerated files

* fix allowing edit silence in external alert manager

---------

Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
2024-06-05 15:09:26 -04:00
Tom Ratcliffe dfd64ed469 Alerting: Ensure we fetch AM config before saving new configuration (#88458) 2024-05-31 17:19:01 +02:00
Tom Ratcliffe 5bb7d4da4c Alerting: Remove regex reference in silences filter tooltip (#88455) 2024-05-30 09:05:34 +01:00
Tom RatcliffeandGilles De Mey 3adb07cf4d Alerting: Make regex notification routing preview consistent with notification policies implementation (#88413)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2024-05-29 17:04:35 +01:00
Tom Ratcliffe 859b3ff78b Alerting: Fix "copy link" not including full URL (#88210) 2024-05-24 15:02:46 +02:00
Tom Ratcliffe ebdad80dfa Alerting: Fix rules deleting when reordering whilst filtered (#88221) 2024-05-24 13:49:52 +02:00
Tom Ratcliffe dbf258b837 Alerting: Center "need help" icons (#87981) 2024-05-21 12:04:10 +01:00
Tom Ratcliffe 938fcab1c8 Alerting: Skip flakey silencing test (#87994) 2024-05-16 18:49:18 +03:00
Tom Ratcliffe 9e29c215c3 Alerting: Update silences creation to support __alert_rule_uid__ and move into drawer (#87320) 2024-05-16 09:34:07 +01:00
Tom Ratcliffe aae6b5312a Alerting: Fix "evalutation" typo (#87930) 2024-05-15 19:05:45 +03:00
Tom Ratcliffe f4d55d2612 Alerting: Restructure mock server handlers slightly and remove unnecessary handlers (#87759) 2024-05-15 16:53:16 +01:00
Tom Ratcliffe 08884f16af Chore: Remove redux-rtl test helper (#87596) 2024-05-13 11:03:21 +01:00
Tom Ratcliffe a597300027 Chore: Allow MenuItems to have role=menuitem when URL is set (#86886)
Allow passing a role into a MenuItem component, and fallback to default behaviour if not passed
2024-05-07 13:12:02 +01:00
b0f6913ef6 Alerting: unify alert rule actions between list and detail view (#86071)
* Add mock method for getting a plugin

* Update tests to find "more" button via label

* Remove test for Silence action in rule details

* Unify alert rule actions to pull from same place

* Restore behaviour of only showing incident button when firing

* Fix identifier and pause permission/logic

* Remove TODO comment related to refactor

* Update snapshot for useAbilities

* Undo optional param

* Rename alert rule menu hook to component

* Refactor hook to component

* Rename Rule action buttons component

* Chore: update style syntax for RuleDetails

* Add tests for refactored alert rule menu

* Only re-fetch Grafana managed alerts after pausing/resuming

* Remove console log and check for extensions

* Improve share rule generation of GMA rules

* Rename component

* Update action

* Refactor plugins and fix tests

* lint

---------

Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2024-04-30 16:17:55 +01:00
Tom Ratcliffe 0a02508415 Add more robust error handling for stringifying API responses 2024-04-29 14:15:48 +01:00
Tom Ratcliffe a34d22dcbf Include alertmanager param on creation 2024-04-29 14:15:48 +01:00
Tom Ratcliffe e0ee0b09db Add test to check that a broken alertmanager will handle errors correctly 2024-04-29 14:15:48 +01:00
Tom Ratcliffe aa2f52a2a1 Tidy up error message handling 2024-04-29 14:15:48 +01:00
Tom Ratcliffe fd07b3d431 Link silence test handlers together more clearly and test more cases 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 31231cf5bf Change test render method to use locationService 2024-04-29 14:15:48 +01:00
Tom Ratcliffe a34c02fcf2 Address misc PR feedback 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 9860117399 Add more fine grained tag invalidation/providing for Silences 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 4fb1ac2bec Check error state more reliably 2024-04-29 14:15:48 +01:00
Tom Ratcliffe a0373c66c3 Add fallback for alertmanager alerts 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 9bf2cf0a52 Rename silences RTKQ tag 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 4d4bf39184 Check for server received body
This is not ideal! Preference would be to have a more robust mock server
that responds to the received silence and appends it to a stateful list for the test
and then resets afterwards
2024-04-29 14:15:48 +01:00
Tom Ratcliffe 0dc003aadc Split handlers out into separate files 2024-04-29 14:15:48 +01:00
Tom Ratcliffe f419c9b53a Add comment explaining reset in silences editor 2024-04-29 14:15:48 +01:00
Tom Ratcliffe df5c62b8ad Misc tidy up 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 21a3f4817a Add correct tag invalidation after creating a silence 2024-04-29 14:15:48 +01:00
Tom Ratcliffe cdfc6baea4 Remove unused fetchAlerts method 2024-04-29 14:15:48 +01:00
Tom Ratcliffe f397830098 Refactor Silences test 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 10fcd541e3 Add handlers to mock server 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 341449f4f5 Remove unused actions/reducers 2024-04-29 14:15:48 +01:00
Tom Ratcliffe a1d2a9670b Restructure Silences components for better separation of concerns 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 11ed882c84 Add mock server handlers necessary for Silences 2024-04-29 14:15:48 +01:00
Tom Ratcliffe 8f27ec2521 Add silences RTK Query API 2024-04-29 14:15:48 +01:00
Tom Ratcliffe f43762f39a Remove (most) occurrences of HorizontalGroup within Alerting 2024-04-25 12:54:41 +01:00
Tom Ratcliffe 0582e05f8f Add PoC for different MSW approach 2024-04-24 15:57:11 +01:00
Tom Ratcliffe 349df74578 Rename debug target to "UI" rather than Jest 2024-04-23 11:26:56 +01:00
Tom Ratcliffe 97b66c2a95 Apply prettier fixes to VSCode debug config 2024-04-23 11:26:56 +01:00
Tom Ratcliffe 37a86872db Remove port and add NODE_ENV to VSCode debug config 2024-04-23 11:26:56 +01:00