135 Commits

Author SHA1 Message Date
b1592b5e36 Cloud migrations: store snapshots in the database (#108551)
* Cloud migrations: store snapshots in the database

* update github.com/grafana/grafana-cloud-migration-snapshot to v1.9.0

* make update-workspace

* use new field name in test

* return error after call to fmt.Errorf

* create methods for readability / fix session deletiong not deleting snapshots

* remove debugging changes

* update sample.ini

* update tests to include OrgID in ListSnapshotsQuery

* lint

* lint

* Update pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>

* remove TODO

* Update pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>

* remove one of the debug logs

---------

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
2025-07-25 11:41:21 -03:00
58e0c05150 E2C: Add new error for alert rule quota (#107225)
* add new error for alert rule quota

* add alert rule group quota error

* make openapi3-gen

* revert message

* update translation

* prettier

* update text per review suggestion
2025-07-09 15:25:20 -04:00
3ec907bbe6 CloudMigrations: Add warnings for bugs with HA setups (#107265)
add warnings for HA bug
2025-06-26 12:03:50 -04:00
e92baba748 Alerting: Support PDC in Grafana-managed recording rules (#106677) 2025-06-17 11:46:34 +02:00
db845ed8de CloudMigrations: Add Mute Timings as dependency for Notification Policies (#106751) 2025-06-16 18:08:18 +02:00
a65743e41d CloudMigrations: Skip default contact point from snapshot (#106600)
* CloudMigrations: Skip default contact point from snapshot

* Update cloud-migration-assistant.md

* Update cloud-migration-assistant.md

---------

Co-authored-by: Jacob Valdez <jacob.valdez@grafana.com>
2025-06-13 11:09:27 +02:00
a1f2693fd8 CloudMigrations: Omit autoincremented id for alert snapshots (#106598)
If you tried to migrate alerts from two differente sources/on-prem instances,
the autoincremented numeric id would be the same, and since we were creating
the resource in cloud with that same id (the API accepts it), it would
return an error "conflicting alert rule found" because that id is the primary key on the table.

We simply omit the numeric id now and let the API for the cloud instance generate it.
2025-06-12 15:38:21 +02:00
90c4868c8c CloudMigrations: Add test case for invalid permissions to fetch contact points (#106143) 2025-06-09 09:49:46 +02:00
b4fc33ff6b Chore: Fix cloud migration test when running against postgres (#105636)
make postgres integration tests happy
2025-05-19 22:59:31 +02:00
6205e126cc CloudMigrations: Fix issues with snapshot resource limits (#105425)
* fix bulk inserts

* commit progress so cursor doesn't sabotage me

* add more tests

* get everything working

* rename variable

* update comment

* regen mocks, fix k8s list method maybe

* fix bug with duplicate entries

* lint

* Snapshots: Use slices.Chunk for batching inserts

* remove extra linebreak

---------

Co-authored-by: Matheus Macabu <macabu.matheus@gmail.com>
2025-05-19 11:37:22 -04:00
652c374c4c CloudMigrations: Make table sort case insensitive (#103898)
* case insensitive sort

* fix for all db types

* add comment

* add unit test

* add a TODO to fix later
2025-04-11 20:29:07 +01:00
757be6365a CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
3fad6183aa CloudMigrations: Create resource dependency map to validate snapshot request (#102594)
* CloudMigrations: Create resource dependency map to validate snapshot request

* CloudMigrations: Validate resource types dependencies in create snapshot request

* CloudMigrations: Update service interface to pass parsed resource types for creation

* CloudMigrations: Conditionally append resource to snapshot if enabled

* CloudMigrations: Add /cloudmigration/resources/dependencies endpoint

* CloudMigrations: Properly filter dashboards and folders from snapshot
2025-04-08 17:46:25 +02:00
0fd7dfeb2a CloudMigrations: Implement table sorting in the UI (#103061)
* implement sorting

* swagger gen

* minor fixes

* clean up param reading

* add todo

* add errors only prop

* codegen stuff

* fix copy paste error

* forgot the api gen

* implement sorting on the frontend

* remove unused enums

* cleanup

* remove tests that are obe

* fix merge

* change page length based on checked box

* cleanup

* fix test

* i18n-extract

* var name tweaks

* use switch and conditional rendering instead of checkbox

* i18n-extract

* use initial sort

* fix type

* fix layout

* fix bugs

* make betterer happy

* fix var names
2025-04-08 08:14:17 -04:00
7165bc553a CloudMigrations: Add Cypress happy path test case scenarios (#103250) 2025-04-03 10:34:32 +02:00
4918d8720c Dashboard Restore: Remove experimental functionality under feature flag dashboardRestore for now - this will be reworked (#103204) 2025-04-03 02:52:54 -05:00
88e51d549c CloudMigrations: Add sorting and error filtering to Snapshot Results backend (#102753)
* implement sorting

* swagger gen

* minor fixes

* clean up param reading

* add todo

* add errors only prop

* codegen stuff

* fix copy paste error

* forgot the api gen

* cleanup

* remove tests that are obe

* fix test
2025-03-30 10:42:45 -04:00
9c0c9359a0 CloudMigrations: Refactor folder name resolution when fetching migration json data (#102604)
* CloudMigrations: Refactor folder name resolution when fetching migration json data

* Update pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go

---------

Co-authored-by: Michael Mandrus <41969079+mmandrus@users.noreply.github.com>
2025-03-24 08:17:11 +01:00
87638c0170 Alerting: Start splitting apart ngalert/api package. (#102075) 2025-03-13 09:28:35 +01:00
5917ed8227 Hackaton: Add more unit tests, take 4 (#101704)
* cloudmigration/cloudmigrationimpl: run integration tests in parallel

* tsdb/mysql: run tests with actual service and instance manager

* pluginsintegration/angulardetectorsprovider: reduce job interval in test

* util: extract test that should only be ran with -race enabled and unskip it
2025-03-07 14:06:47 +01:00
3539764008 Hackaton: Add more unit tests, take 3 (#101525)
* serviceaccounts/secretscan: test Service more thoroughly

* middleware/cookies: add tests for CookieOptions

* anonymous/anonimpl: cover a couple more methods

* components/imguploader: Implement WebDAV integration tests

* components/apikeygen: also check IsValid method

* bus: cover invalid callback signature cases

* cloudmigration/objectstorage: add basic unit tests

* login/social/connectors: add test case for GitHub OAuth fetch emails+orgs

* expr/classic: cover more evaluator types in tests
2025-03-05 08:00:12 +01:00
b110754c9a Hackaton: Add more unit tests, take 2 (#101473)
* login/social/socialimpl: add assertions for usage stats, support bundle and oauthinfo methods

* accesscontrol/acimpl: add tests for GetRoleByName

* anonymous/sortopts: add tests for Sorter

* cloudmigration/gmsclient: add basic test cases for all methods

* shorturls/shorturlimpl: add more edge test cases

* tag/tagimpl: add test to cover duplicate tag kv and nil pairs

* updatechecker: add test cases for module
2025-03-03 13:12:13 +01:00
77350ce84f CloudMigrations: Address CodeQL issue on unsanitized request params (#101125) 2025-02-21 14:29:52 +01:00
fde475e3d9 CloudMigrations: save snapshot of alert rule groups (#100109) 2025-02-06 12:35:59 +01:00
d71904cb27 Alerting: Expose updated_by in rules GET APIs (#99525)
---------

Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
2025-01-27 14:31:40 -05:00
b3209b1e01 CloudMigrations: Remove onPremToCloudMigrationsAuthApiMig feature flag (#99368) 2025-01-24 13:53:58 -03:00
c9d22f06c3 CloudMigrations: Bulk update local resources (#96002)
* wip

* make tests pass

* get all tests passing

* fixes

* some small cleanup

* fix test

* convert delimiter keys to struct keys

* dont execute empty sql statement

* remove printlns

* fix unit test

* a bit more cleanup

* whoops
2025-01-10 14:42:18 -05:00
3958fb9e0a CloudMigrations: Introduce RBAC role for migration assistant (#98588)
* CloudMigrations: delete unused code

* CloudMigrations: add access control and protect API + navtree with action

* CloudMigrations: register access control roles

* CloudMigrations: gate frontend based with access control

* CloudMigrations: fix api tests

* CloudMigrations: add docs on new actions and roles

* CloudMigrations: dont interpolate vars to make it more greppable

* CloudMigrations: run prettier
2025-01-09 06:03:42 +02:00
69adb3d25b Tests: Fix dashboard mock (#98647) 2025-01-08 00:20:35 +02:00
58ed8a9ec2 Cloud migration: Refactor get by org ID to dashboard svc (#98646) 2025-01-07 23:33:45 +02:00
1699dfa307 CloudMigrations: Add support for migration of plugin resources (#95612)
* start plugins migration

* more plugin work

* add warning

* fakepluginsettings test

* tests get plugins

* lint

* load logos

* go lint

* get all plugins once

* locales

* josh suggestion to inject query in rtk

* more plugin filters

* remove datasource warning

* access control for plugins

* remove unused method

* lint

* use gcom list
2025-01-06 10:37:15 +00:00
c824f5b9bf CloudMigrations: Add config for alert rules state behavior and remove experimental feature toggle on alerts migration (#97254)
* CloudMigrations: add config for controlling alert rules state behavior

* CloudMigrations: remove experimental 'onPremToCloudMigrationsAlerts' feature toggle
2024-12-17 12:56:18 +01:00
b9d6af34cd CloudMigrations: Obtain gcom plugins to enable plugins migration (#97784)
* just api

* preallocate
2024-12-13 10:59:43 +00:00
1bf35c97e5 CloudMigrations: fix flaky test on snapshot status (#96827)
* cloudmigration: uncomment flaky test

* cloudmigration: refactor test snapshot status
2024-11-25 09:28:00 +01:00
e9fae5bd7f CloudMigration: Create authapi service (#96581) 2024-11-21 20:46:06 +02:00
7bfaf2a7bf [Cloud Migrations] Fix panic in unit tests (#96389)
* Fix panic in unit test

* Reset mock to new one between tests
2024-11-13 16:06:32 +02:00
29ee90bc26 CloudMigrations: add parent folder name to alert rule resource (#96366) 2024-11-13 12:20:56 +01:00
924b0d0863 CloudMigration: Add user uid to on prem event collection (#94804)
* add useruid to report events

* test
2024-11-13 11:07:00 +00:00
750a0bed71 MigrationAssistant: Restrict dashboards, folders and datasources by the org id of the signed in user (#96339)
apply security patch: main/206-202410241510.patch
2024-11-12 13:03:16 -06:00
7f99e943a6 Do not use the span recorder in test (#96324) 2024-11-12 17:55:53 +01:00
fde9ddfc8c [Cloud Migration] Skip flaky cloud migration unit test (#96256)
Skip Flaky Cloud Migration test
2024-11-12 11:08:35 +01:00
477326b9c3 [CloudMigrations] Fetch cloud migration status asynchronously (#96084)
* Single go-routine without touching too many lines.
* Fix unit tests
* Use require for Eventually
* Use a 10 second internal to poll for new results.
2024-11-11 19:26:30 +01:00
1fdc48faba Alerting: Make context deadline on AlertNG service startup configurable (#96053)
* Make alerting context deadline configurable

* Remove debug logs

* Change default timeout

* Update tests
2024-11-07 18:23:55 +00:00
85c696c4ad SQL: Add macro support in select case (#88514)
* Feat: timeGroup macro handling in VQB

* Add tests

* Add functions to SQL ds

* Fix lint errors

* Add feature toggle

* Add rendering based on object

* Fix lint

* Fix CI failures

* Fix tests

* Address review comments

* Add docs

* Fix JSX runtime warnings

* Remove docs part that mentions suggest more macros

* Update docs/sources/shared/datasources/sql-query-builder-macros.md

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>

* Add smoke test for this feature

* lint

* Add supported macros to influx

* Add setupTests.ts to include in tsconfig.json

* Import jest-dom instead of setupTests.ts

---------

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
2024-11-04 17:13:35 +01:00
69f185b459 CloudMigrations: handle provisioned data source error (#95473) 2024-10-28 12:02:46 +01:00
b2de69d741 CloudMigrations: create snapshot for Alert Rules (#95404)
* CloudMigrations: create snapshot for Alert Rules

* CloudMigrations: display Alert Rules in resource list summary
2024-10-25 17:20:05 +02:00
2deced7d40 Alerting: Notifications Routes API (#91550)
* Introduce new models RoutingTree, RouteDefaults and Route and api-server to serve them that is backed by provisioning notification policy service.

* update method UpdatePolicyTree of notification policy service to return route and new version

* declare new actions alert.notifications.routes:read and alert.notifications.routes:write and two corresponding fixed roles.

---------

Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
2024-10-24 13:53:03 -04:00
152b83b3fb CloudMigrations: handle more error codes from GMS backend (#95257)
* CloudMigrations: remove unnecessary if feature toggle gating

* CloudMigrations: handle new error codes from backend
2024-10-24 15:55:02 +02:00
98e5048370 CloudMigration - Display different error messages for create migration errors (#94683)
* start on tokens

* more error messages

* more handling

* rephrased with suggestions from Daniel

* separate gms parse method

* use translation

* refactor initial idea to use error obj

* use error dto result

* handle gms client

* clean logs and comments

* fix tests

* tests for gms

* test and lint

* lint

* one more handling from gms

* typing in fe

* use error interface

* use validation error

* remove unused gms error

* use errorlib and helper function in fe

* regen api

* use same error util

* one more error to handle
2024-10-21 09:45:54 +01:00
8673c757a5 CloudMigrations: only append notification policy if feature flag is on and it exists (#94896) 2024-10-17 17:15:30 +02:00