Commit Graph

15403 Commits

Author SHA1 Message Date
colin-stuart
da2c382d80 Tests: Add SearchOrgUsersFn to FakeOrgService (#101589)
add SearchOrgUsersFn to FakeOrgService
2025-03-05 09:02:01 -05:00
Matheus Macabu
61eb837dd6 Chore: Bump Go to 1.23.7 (#101576) 2025-03-05 14:55:36 +01:00
Alexander Akhmetov
d44728f4e5 Alerting: Metric to count imported from Prometheus rules (#100847) 2025-03-05 14:02:28 +01:00
Matheus Macabu
2638de6aeb Anonymous: Add 1min leeway in device count + search in tests for MySQL 5.7 (#101608) 2025-03-05 12:32:37 +01:00
Alexander Zobnin
01899d761e Zanzana: Upgrade to OpenFGA v1.8.6 (#101553)
* Zanzana: Upgrade to OpenFGA v1.8.6

* upgrade openfga
2025-03-05 11:58:31 +01:00
Matheus Macabu
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
Ryan McKinley
dc2defd84f K8s/Annotations: Use manager/source annotations rather than repo (#101313)
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
2025-03-05 08:54:20 +02:00
Stephanie Hingtgen
e806a00701 K8s: Dashboards: Add useful error message for too large (#101590) 2025-03-04 17:11:42 -06:00
Stephanie Hingtgen
67221fb328 K8s: Folders: Fix not found errors (#101585) 2025-03-05 00:31:41 +02:00
Stephanie Hingtgen
7c35d741ba Folders: Add validation that folder is not a parent of itself (#101569) 2025-03-04 13:56:21 -06:00
Stephanie Hingtgen
b8e1511c7f K8s: Increase max request body (#101564) 2025-03-04 11:27:43 -06:00
Yuri Tseretyan
67b44ad22a Alerting: Fix state reason (#101530)
---------

Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
2025-03-04 17:05:41 +02:00
Kevin Minehart
2f3aff0e04 Dashboards: Prevent title longer than 5 000 characters (#101554)
Co-authored-by: AgnesToulet <35176601+AgnesToulet@users.noreply.github.com>
2025-03-04 17:02:54 +02:00
Jack Westbrook
bbfeb8d220 Feature: Introduce subresource integrity checks (SRI) for frontend assets (#100983)
* feat(featuremgmt): introduce feature toggle for enabling sri checks

* feat(frontend): use assetSriChecks feature toggle to inject integrity hash into script tags

* chore(webpack): align sri algorithms across dev and prod builds

* docs(featuremgmt): update assetSriChecks to pass CI

* docs(featuremgmt): fix more spelling complaints with assetSriChecks

* Add crossorigin attribute

* chore(webpack): add subresource-integrity plugin

* build(webpack): wrap webpack jsonp loader integrity checks in feature flag checks

* revert(index.html): remove crossorigin attribute if assertSriChecks is disabled

---------

Co-authored-by: Kristian Bremberg <kristian.bremberg@grafana.com>
2025-03-04 11:56:35 +01:00
Alexander Akhmetov
60827fe499 Alerting: Return 403 if no datasource access or quota has been exceeded (#101522) 2025-03-04 10:04:47 +01:00
Stephanie Hingtgen
503bc2ba66 K8s: Indexing: Fix v2 (#100683) 2025-03-04 08:04:53 +02:00
Ryan McKinley
c1b48cc488 Dashboards: Add apiVersion to dashboard table (#100845) 2025-03-04 07:47:45 +03:00
alerting-team[bot]
d9538fd5dc Alerting: Update alerting module to bb85a58ec8975d91b49d746dbd11d312f0485ecc (#101537)
[create-pull-request] automated change

Co-authored-by: yuri-tceretian <25988953+yuri-tceretian@users.noreply.github.com>
2025-03-03 18:10:15 -05:00
Sarah Zinger
ed3f96ce28 Fix misleading log line (#101532) 2025-03-03 15:52:47 -05:00
Charandas
cedb4ef9c1 fix: testutil blocking PR checks from passing (#101527) 2025-03-03 10:56:30 -08:00
Ieva
5f6b00a72f Revert "Authz: Removes setting viewers_can_edit" (#101528)
Revert "Authz: Removes setting `viewers_can_edit` (#101265)"

This reverts commit 4ce41acade.
2025-03-03 20:26:55 +02:00
Charandas
22d39f585d fix: don't double set aggregator certs (#101444) 2025-03-03 09:50:11 -08:00
Ivana Huckova
66279081c6 Elasticsearch: Invalid response JSON parsing error should be downstream (#101506)
* Elasticsearch: Invalid response JSON parsing error should be downstream

* Add test

* Update test
2025-03-03 18:14:43 +01:00
Alexander Akhmetov
c7c68322b1 Alerting: Allow specifying a folder for Prometheus rule import (#101406)
What is this feature?

Allows the creation of alert rules with mimirtool in a specified folder.

Why do we need this feature?

Currently, the APIs for mimirtool create namespaces and rule groups in the root folder without the ability to set a custom folder. For example, it could be a special "Imported" folder, etc.

This PR makes it possible with a special header: mimirtool ... --extra-headers="X-Grafana-Alerting-Folder-UID=123". If it's not present, the root folder is used, otherwise, the specified one is used.

mimirtool does not support nested folder structures, while Grafana allows folder nesting. To keep compatibility, we return only direct child folders of the working folder (as namespaces) with rule groups and rules that are directly in these child folders as if there are no nested folders.

For example, given this folder structure in Grafana:

```
	grafana/
	├── production/
	│   ├── service1/
	│   │   └── alerts/
	│   └── service2/
	└── testing/
	    └── service3/
```

If the working folder is "grafana":

    Only namespaces "production" and "testing" are returned
    Only rule groups directly within these folders are included

If the working folder is "production":
   -  Only namespaces "service1" and "service2" are returned
    Only rule groups directly within these folders are included
2025-03-03 17:59:01 +01:00
linoman
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
Serge Zaitsev
165bca6417 Chore: Add initial/experimental xorm spanner driver (#101398)
* make it build and start

* run some migrations

* add build tags, remove log

* remove unused code

* revert go.mod changes

* move initialisation into dialect file

* update workspace

* update workspace once again

* clean up dependencies

* further cleanup

* Address some review feedback.

* Fix go.sum.

---------

Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
2025-03-03 17:02:10 +01:00
Matheus Macabu
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
dependabot[bot]
d1b20c652d Bump github.com/go-jose/go-jose/v3 from 3.0.3 to 3.0.4 (#101385)
* Bump github.com/go-jose/go-jose/v3 from 3.0.3 to 3.0.4

Bumps [github.com/go-jose/go-jose/v3](https://github.com/go-jose/go-jose) from 3.0.3 to 3.0.4.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Changelog](https://github.com/go-jose/go-jose/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-jose/go-jose/compare/v3.0.3...v3.0.4)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* update workspace

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-03-03 12:11:08 +01:00
Filip "Ret2Me" Poplewski
561156c4da Auth: Add support for the TlsSkipVerify parameter to JWT Auth (#91514)
* feat(auth/JWTAuth): add support for the TlsSkipVerify parameter

* feat(auth/JWTAuth): add param to default.ini and sample.ini

---------

Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
2025-03-03 11:18:14 +02:00
Ryan McKinley
0764ecb98d K8s/DualWriter: Use dualwriter package for all dual writers (#101393) 2025-03-01 21:26:14 +03:00
Matthew Jacobson
2466685a41 Alerting: Improve template testing by trying non-root scopes (#101471)
Expand template testing to try additional scopes if the root scope fails.
This mitigates errors for definitions like pagerduty.default.instances,
which require the .Alerts scope. Added support for .Alerts and .Alert
scopes.
2025-02-28 20:27:27 +02:00
Yuri Tseretyan
1d54850a68 Alerting: Get alert rule versions by GUID (#101469)
* get alert rule versions by GUID

* protect guid field from accidental update
2025-02-28 11:27:46 -05:00
Todd Treece
620d213856 K8s: Set priority for aggregated discovery (#101427) 2025-02-28 17:39:41 +02:00
Yuri Tseretyan
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
Matheus Macabu
9eaaf95701 Hackaton 12: Add some unit tests, take 1 (#101457)
* tsdb/graphite: add happy path test for QueryData

* infra/httpclient/httpclientprovider: add tests for RedirectLimitMiddleware
2025-02-28 16:11:11 +02:00
xavi
ec29f6cb60 Add OpenAPI annotations for query params of getOrgUsersForCurrentOrg API route (#101419) 2025-02-28 13:41:58 +01:00
Will Assis
f5e5824bab fix (unified-storage): stop registering unified storage metrics in global state (#101322)
* move prometheus.register for unified storage metrics into metrics.go and do most of the plumbing to get it to work

* convert StorageApiMetrics to pointer and check for nil before using it

* rename type and variables to something more sensible

---------

Co-authored-by: Jean-Philippe Quéméner <jeanphilippe.quemener@grafana.com>
2025-02-28 07:39:39 -05:00
Sonia Aguilar
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
Alexander Akhmetov
ae2074ef55 Alerting: Fix updating Prometheus definition in the metadata (#101440)
Initially, Metadata had only the EditorSettings, and HasMetadata was used to understand if the incoming update request had metadata in the body because it could be omitted if it was empty. For example, when the rule is updated via the provisioning API or has only false values. If it was in the request, we used that; if not, we used the metadata from the existing rule from the database. If the rule was updated via the AlertRuleService, we didn't change Metadata at all if the rule already existed.

But now, Metadata also has the Prometheus rule definition, and we always need to update it with the new version of the AlertRuleService when the rule exists in the DB and has the same UID. HasMetadata is renamed to HasEditorSettings to keep the old behaviour only for EditorSettings.

Now, the provisioning API and the conversion API will overwrite everything except EditorSettings with the new data.
2025-02-28 13:11:49 +02:00
Karl Persson
d6b6a9da7b FolderAPI: Use different authorizer for multi-tenant api (#101372)
Use different authorizers depening on if we are running multi-tenant or single-tenant
2025-02-28 10:10:32 +01:00
Ryan McKinley
5652e0b835 K8s/Dashboard/SQL: Support ascending order query (#101363) 2025-02-28 11:34:09 +03:00
Ryan McKinley
806c043e45 UnifiedStorage: Rename Batch processing to Bulk (#101413) 2025-02-28 08:41:08 +03:00
Moustafa Baiou
bc4be187af Alerting: Fix evaluation of rules with no-op math expressions
When you use a math expression with out any operators, the dataFrame pointer is identical between the expression result and the input query/expression.

This was resulting in the values returned from an evaluation overshadowing each other, depending on the order of the processing of the result map.

For example:
```
A: some_metric
B: reduce of A
C: math expression -> "${B}"
D: Threshold evaluation of C -> "C > 0"
```
With a value of 1 for `some_metric`, might result in a evaluation result of one of the following (somewhat at random):
1. { B: 1, D: 1 }
2. { C: 1, D: 1}

While you would expect to see:
{ B: 1, C: 1, D: 1 }
2025-02-27 17:04:18 -05:00
Alexander Akhmetov
ef86582dfc Alerting: API paths for cortextool to import Loki rules (#101409)
Alerting: Legacy rules paths for cortextool
2025-02-27 17:20:49 +01:00
Eric Leijonmarck
843d876f16 Anon: Deprecation notice for Editor, Admin anonymous org role usage (#101411)
* deprecation notice for anonymous org role usage

* exclude viewer
2025-02-27 15:34:15 +00:00
Peter Štibraný
908f4ff357 Use enterprise imports for pro builds as well. (#101423) 2025-02-27 17:33:26 +02:00
Leonor Oliveira
f8b63c364b [CodeQL] Fix wrong type conversion (#101353)
* [CodeQL] Fix wrong type conversion

* Use AtyoI
2025-02-27 15:18:02 +01:00
Leonor Oliveira
5e61ec1258 Prevent wrong type conversion (#101349) 2025-02-27 15:17:50 +01:00
Alexander Akhmetov
d947433d19 Alerting: API to delete rule groups using mimirtool (#100687)
* Alerting: API to delete rule groups using mimirtool
2025-02-27 13:04:47 +01:00
Karl Persson
c6a78978c3 ContextHandler: unexport cfg (#101396) 2025-02-27 12:03:03 +01:00