672 Commits

Author SHA1 Message Date
Jo
06278615fb Fix: Increase login_attempt.ip_address column length for IPv6 support (#107035)
* fix: increase login_attempt.ip_address column length for IPv6 support

- Expand ip_address column from VARCHAR(30) to VARCHAR(50) to accommodate IPv6 addresses
- Add database migration with support for PostgreSQL, MySQL, and SQLite
- Add comprehensive integration tests for various IPv6 address formats
- Resolves 500 errors when login fails over IPv6, now returns proper 401 errors

Fixes #106362

* test: add missing test skip to TestIntegrationIPv6AddressSupport

Skip integration test when running with -short flag to separate unit and integration tests

* Update pkg/services/sqlstore/migrations/login_attempt_mig.go

Co-authored-by: Victor Cinaglia <victor@grafana.com>

* fix missing bracket

* fix: resolve PostgreSQL timestamp overflow in IPv6 test

- Use controlled time mock instead of time.Now() to avoid timestamp conversion issues
- Follow existing test patterns with xormStore and mock time functions
- Add proper Since parameter to GetIPLoginAttemptCount query
- Fixes PostgreSQL error: 'pq: value "-62135596800" is out of range for type integer'

* fix: resolve PostgreSQL UTF-8 encoding error in IPv6 test

Replace string(rune(i)) with fmt.Sprintf to avoid null bytes (0x00)
when i=0, which caused 'invalid byte sequence for encoding UTF8' error

---------

Co-authored-by: Victor Cinaglia <victor@grafana.com>
2025-06-24 16:11:45 +02:00
a8886ad5ec Annotations: Use dashboard uids instead of dashboard ids (#106676) 2025-06-13 13:59:24 -05:00
352aac162c Preferences: Use dashboard uid for the home dashboard (#106666) 2025-06-13 07:10:44 -05:00
589046bcdc Alerting: Persist alert instance FiredAt field (#105927)
* Persist alert instance fired at

* Update protos and tests
2025-05-27 10:04:26 +01:00
c4d3eb1cd0 Remove support for Google Spanner database. (#105846)
* Remove support for Google Spanner database.
2025-05-23 11:35:59 +02:00
69e657b296 SQLStore: Add index on is_service_account and last_seen_at columns in user table. (#105727)
Add index on is_service_account and last_seen_at columns in user table.
2025-05-21 17:44:44 +03:00
6b588f4c93 Migrations: Make sure users uid are set (#104996)
* Migrations: Make sure default admin has a uid

* Account for all users not only id 1

* Add spanner

* Wrong migration to add spanner

* Fix spanner mig
2025-05-07 13:40:32 +02:00
694b9dfe50 Chore: Replace xorm.io/xorm imports (#104458)
* replace xorm.io/xorm imports

* replace xorm from other go.mod files

* clean up workspace

* nolint does not make sense anymore as it is not a module

* try if nolint directive helps

* use nolint:all for xorm

* add more nolints

* try to skip xorm in linter config

* exclude xorm differently

* retrigger ci
2025-05-02 17:13:01 +02:00
757be6365a CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
ec2cd53b1a Tempo: Remove traceQLStreaming feature toggle (#103619)
Remove traceQLStreaming feature toggle and migration
2025-04-09 13:57:07 +01:00
10411361e7 Team: Add columns external_uid and is_provisioned to the team table (#103285)
* add columns external_id and is_provisioned to the team table

* generate openapi specs

* rename column to external_uid

* generate open api specs

* increase limit for external_uid to 256
2025-04-04 11:00:14 +03:00
15e7c3c439 Fix: Change secure_json_data column data type to medium text only MYSQL (#102557)
fix: change secure_json_data type to medium text only MYSQL
2025-03-27 12:59:07 -04:00
e1e1d3fd9f Fix: Prints should always include new lines (#102795)
* CI: Allow Bench conversion to fail

We shouldn't mark PRs and commits as X if they fail to convert logs with Bench.

* Fix: Prints should always include new lines

* fix: remove unused import
2025-03-27 12:27:53 +01:00
d0dbd1d156 spanner: Fix star migration that fills NULL dashboard_uid and org_id fields from dashboard table. (#102768) 2025-03-26 11:15:00 +01:00
cb532cafef SCIM: Validate provisioned users (#102099)
* Validate authID when user is provisioned

* Add new `user_unique_id` to `user_auth` table

* Validate provisioned user with saml assertion

* Rework `ExternalUID`

* Validate for ExternalUID only

* Enhance verbosity

* Move ExternalUID to saml config

* Rename db variable for externalUID

* Add verbosity to debug ExternalUID

* Assign new error for ExternalUID mismatch

* Add `GetByLoginFn`

* Add new configuration to saml tests

* add validation for empty externalUID
2025-03-24 09:28:51 +01:00
4e27ee2ff6 Unified Storage: Add index on dashboard_tag table for dashboard_uid column (#102551)
add index on dashboard_tag table for dashboard_uid column
2025-03-20 16:51:37 -06:00
24ebacb10b Alerting: Add migration to clean up rule versions table (#102484)
* add migration to clean up rule versions
* drop index right before creating a new one.
* fetch only rules which version greater than toKeep
2025-03-20 12:34:36 -04:00
0c58d39e76 Spanner-related fixes (#102376)
* Fix UNION syntax in resourcepermissions package.
* Fix migrations in usermig package to work with Spanner.
* Fix health query.
* Use more connections for integration tests.
* Add test-go-integration-spanner target to run integration tests against Spanner emulator.
* Add test for enterprise.
* Don't delete sequence number for migration_log.id column.

* Only bump max open connections to 20 for Spanner.
Lower integration test timeout.
2025-03-19 12:34:44 +01:00
e39b17d701 Alerting: Remove constraints for uniqueness of rule title (#102067)
* fix having duplicated names in same group in the UI

---------

Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
2025-03-18 13:27:44 -04:00
04f20127a2 Revert "Alerting: Add an index to alert_rule_version table on (rule_org_id, rule_uid) (#102347)" (#102368)
This reverts commit 9491fa18957cff5ae7ca986d82d567d66fc402cd.
2025-03-18 14:54:45 +01:00
fc9e5110d7 Access: Add migration to remove datasources:drilldown (#102188)
* Add migration to remove datasources:drilldown

* remove role assignments as well

* rename to datasources:drilldown

* remove the role assignments

* made it simple instead

* Update pkg/services/sqlstore/migrations/accesscontrol/datasource_drilldown_removal.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

* Update pkg/services/sqlstore/migrations/accesscontrol/datasource_drilldown_removal.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2025-03-18 13:06:30 +02:00
695ac91290 Alerting: Add backend support for keep_firing_for (#100750)
What is this feature?

This PR introduces a new alert rule configuration option, keep_firing_for (Prometheus documentation).

keep_firing_for prevents alerts from resolving immediately after the alert condition returns to normal. Instead, they transition into a "Recovering" state and are not considered resolved by the Alertmanager. Once the recovery period ends (or after the next evaluation if it is bigger than keep_firing_for), the alert transitions to "Normal" if it doesn't start alerting again:

Before                                          

+----------+     +----------+                    
| Alerting |---->|  Normal  |                    
+----------+     +----------+                    

-----
After

+----------+      +------------+     +----------+
| Alerting |----->| Recovering |---->|  Normal  |
+----------+      +------------+     +----------+                                                 

Why do we need this feature?

This feature prevents flapping alerts by adding a recovery period. This helps avoid false resolutions caused by brief alert
2025-03-18 11:24:48 +01:00
9491fa1895 Alerting: Add an index to alert_rule_version table on (rule_org_id, rule_uid) (#102347) 2025-03-18 11:15:55 +01:00
94020aa9cd Config: Remove setting editors_can_admin (#101607)
* Remove editors can admin

* delete file

* add ac_test back

* Add linting ignore

* more static ignore
2025-03-12 16:25:23 +00:00
7dd6f52630 Alerting: Add MissingSeriesEvalsToResolve option to the AlertRule (#101184) 2025-03-11 22:12:06 +01:00
32f651e9aa Spanner: update DB snapshot (#101879)
* Update spanner snapshot to include migrations from grafana-enterprise.

* Move sql dump tool (test) to grafana-enterprise.
2025-03-10 15:58:12 +01:00
dc75b454f5 Alerting: Improve performance of the setting GUID during migration (#101800) 2025-03-07 12:28:07 -05:00
32624b3251 Tests: skip failing test TestMigrateToSpannerDialect (#101730)
skip failing test TestMigrateToSpannerDialect
2025-03-06 20:47:37 +02:00
9e690bd620 Spanner support enhancements (#101634)
* Adds ability to run integration tests against spanner (by using GRAFANA_TEST_DB=spanner env variable. SPANNER_DB variable then specifies database to use: spannertest, emulator or string like /projects/<project>/instances/<instance>/databases/<db>)
* Adds feature to migration dialects to create database from a snapshot, instead of running individual migrations.
* Adds first version of Spanner snapshot, prepared from "OSS" migrations.
* Uses generated bit-reversed-positive values instead of auto_increment. (As an experiment)
2025-03-06 16:11:20 +01:00
c1b48cc488 Dashboards: Add apiVersion to dashboard table (#100845) 2025-03-04 07:47:45 +03:00
b7a0aeeb0d SCIM: Disable auto assign organization if the user has been provisioned (#101307)
* Add isProvisioned field to model

* Add new isProvisioned column to migration

* Disable auto assignment to organization if the user is provisioned

* add annotation to user model

* add annotation to user models

* Remove IsProvisioned field from Identity

* Move new field assignenment and add default value

* Update annotations for user query results

* Remove isProvisioned from identity

* Add new column to test

* Resolve user from identity at SyncOrgHook
2025-03-03 17:51:23 +01:00
879b121136 Alerting: Add GUID to alert rule tables (#101321)
* 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
2025-02-28 09:47:25 -05:00
cb43f4b696 Alerting: Add compressed protobuf-based alert state storage (#99193) 2025-01-27 18:47:33 +01:00
92d6762a3a Alerting: Store information about user that created\updated alert rule (#99395)
* introduce new fields created_by in rule tables
* update domain model and compat layer to support UpdatedBy
* add alert rule generator mutators for UpdatedBy
* ignore UpdatedBy in diff and hash calculation
* Add user context to alert rule insert/update operations
  Updated InsertAlertRules and UpdateAlertRules methods to accept a user context parameter. This change ensures auditability and better tracking of user actions when creating or updating alert rules. Adjusted all relevant calls and interfaces to pass the user context accordingly.

* set UpdatedBy in PreSave because this is where Updated is set
* Use nil userID for system-initiated updates
This ensures differentiation between system and user-initiated changes for better traceability and clarity in update origins.

---------

Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
2025-01-24 12:09:17 -05:00
7ab2539449 Dashboard tags: add dashboard_uid and org_id (#98500) 2025-01-06 08:58:16 -06:00
2364299a8c Alerting: Fix annotation state migration to retain nullability on MySQL (#96640) 2024-11-18 15:51:45 -05:00
b12c731d59 Stars: Add dashboard_uid and org_id to table (#96408) 2024-11-15 09:51:31 -06:00
c6a90ed3cd Alerting: Fix long KeepLast annotations failing to save (#96503)
Certain combinations of KeepLast state transition annotations exceed the current
 limit of 25 characters. This increases the column size limit to be able to
 handle the longest combination (27) with some extra space for comfort.
2024-11-15 10:43:56 -05: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
af513964c8 Alerting: Migration to remove scope from permission alert.notifications.receivers:create (#95805)
add migration to remove scope from receivers:create permission
2024-11-06 11:31:40 -05:00
2ba1740698 CloudMigrations: increase size of resource_uid column (#95684)
* len 255

* comment

* Update pkg/services/sqlstore/migrations/cloud_migrations.go

* comment on sqlite

* postgres varchar

---------

Co-authored-by: Michael Mandrus <41969079+mmandrus@users.noreply.github.com>
2024-11-01 09:09:50 +00:00
35697381d2 fix: make org_id not nullable and set default value (#95610) 2024-10-31 09:53:33 -04:00
f0391e31d2 Revert "fix: make org_id not nullable and provide default value" (#95606)
Revert "fix: make org_id not nullable and provide default value (#95556)"

This reverts commit 261b4a55645e54ec66c59e5ff9cacd1c3f589208.
2024-10-30 08:55:02 -04:00
261b4a5564 fix: make org_id not nullable and provide default value (#95556) 2024-10-29 13:21:48 -04:00
2f40fd6741 Dashboards: Remove unique name constraints (#90687) 2024-10-29 08:58:39 +03:00
b8b7c7901c Auth: Increase name_id and session_id length to 1024 in user_external_session (#95352)
Increase name_id and session_id length to 1024
2024-10-24 17:14:38 +02:00
6f7528f896 Migration: Remove table aliasing in delete statement to make it work for mariadb (#95226)
Migration: remove table aliasing in delete statement to make it work in mariadb
2024-10-23 10:49:20 +02:00
a50507e645 CloudMigration: Interpret error code from migration resource item (#94407)
* start on loading the error code

* error code to message mapping

* use resource code type

* use defined error code

* partial updates from comments

* i18nKey gen

* fixed t

* fixed translations

* typing
2024-10-17 14:09:09 +01:00
ba3629c01c Fix: Account for conflicting logins in dedupOrgInlogin migration (#94669) 2024-10-15 15:02:34 +02:00
fa330900ff IAM: turn off migration causing instances to crashloop (#94642) 2024-10-11 20:46:34 +03:00