Commit Graph

6209 Commits

Author SHA1 Message Date
Santiago
73776f37eb
Alerting: Send state to the remote Alertmanager (#78538)
* Alerting: Introduce a Mimir client as part of the Remote Alertmanager

Mimir client that understands the new APIs developed for mimir. Very much a WIP still.

* more wip

* appease the linter

* more linting

* add more code

* get state from kvstore, encode, send

* send state to the remote Alertmanager, extract fullstate logic into its own function

* pass kvstore to remote.NewAlertmanager()

* refactor

* add fake kvstore to tests

* tests

* use FileStore to get state

* always log 'completed state upload'

* refactor compareRemoteConfig

* base64-encode the state in the file store

* export silences and nflog filenames, refactor

* log 'completed state/config upload...' regardless of outcome

* add values to the state store in tests

* address code review comments

* log error from filestore

---------

Co-authored-by: gotjosh <josue.abreu@gmail.com>
2023-11-29 12:49:39 +01:00
Gabriel MABILLE
72d32eed27
ExtSvcAuth: Assign roles locally (#78669)
* ExtSvcAuth: Assign roles locally

* Fix test

* HandlePluginStateChanged in the OrgID

* Remove Global from command

* Use AssignmentOrgID instead of OrgID

* Remove unecessary test case
2023-11-29 12:12:30 +01:00
Ieva
791881f910
RBAC: Change annotation filter to use dashboard based annotation scopes (#78635)
change annotation filter to use dash based annotation scopes
2023-11-29 05:34:44 -05:00
Gabriel MABILLE
059ba25973
AuthN: Check API Key is not trying to access another organization (#78749)
* AuthN: Check API Key is not trying to access another organization

* Revert local change

* Add test

* Discussed with Kalle we should set r.OrgID

* Syntax sugar

* Suggestion org-mismatch
2023-11-29 10:25:46 +01:00
Matthew Jacobson
ce90a1f2be
Alerting: Apply query optimization to eval endpoints (#78566)
* Alerting: Apply query optimization to eval endpoints

Previously, query optimization was applied to alert queries when scheduled but
not when ran through `api/v1/eval` or `/api/v1/rule/test/grafana`. This could
lead to discrepancies between preview and scheduled alert results.
2023-11-28 19:44:28 -05:00
Santiago
01d274852c
Alerting: Add GetFullState method to FileStore (#78701)
* Alerting: Add GetFullState method to FileStore

* make tests compile, create stateStore in NewAlertmanager

* return errors instead of logging, accept an arbitrary number of strings

* make NewAlertmanager() accept a stateStore
2023-11-28 15:34:45 +01:00
Todd Treece
529271d7a8
Perf: Disable core kind registry (#78568)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2023-11-28 09:09:54 +01:00
William Wernert
f7bf818527
Alerting: Make alert state history Loki http client public (#78291)
* Make state history Loki client public

* Make historian metrics subsystem configurable
2023-11-27 09:20:50 -05:00
Karl Persson
1c270b1dc2
RBAC: Adjust filter for acl list to check for permissions on service accounts (#78681)
Adjust filter to check for permissions on service accounts
2023-11-27 13:37:31 +01:00
Xavi Lacasa
29853f624e
Lock when cleaning-up external services (#78589) 2023-11-24 17:44:14 +01:00
Matthew Jacobson
4b439b7f52
Alerting: In migration, fallback to '1s' for malformed min interval (#78614)
* Alerting: In migration, fallback to '1s' for malformed min interval

During legacy migration, when we encounter an alert datasource query 
with a min interval (interval field in the query model) that is not 
parseable, instead of failing the migration we fallback to a min interval 
of 1s and continue.

The reason for this is a bug in legacy alerting (existing for a few major 
versions) which allows arbitrary dashboard variables to be used as the 
min interval, even though those variables do not work and will cause 
the legacy alert to fail with `interval calculation failed: time: invalid 
duration`.
2023-11-24 11:27:44 -05:00
Oscar Kilhed
ab982e7bd3
Transformations: Add regression analysis transformation (#78457)
* regression analysis first dragt

* Swap to better regression libraries

* fix name

* Interpolate x points instead of using source x points

* clean up ui and add feature toggle

* fix merge error

* change to loop for finding min max, rename resolution

* Add docs

* add docs and tests

* change name to regression analysis

* update docs

* Fix editor labels

* add regression images

* fix docs
2023-11-24 15:49:16 +01:00
Oscar Kilhed
7a46d6a1b3
Transformations: Move transformation variables to public preview (#78148)
move transformation variables to public preview
2023-11-24 13:22:54 +01:00
gotjosh
8120306fea
Remote Alertmanager(refactor): Only parse the URL once (#78631)
* Remote Alertmanager(refactor): Only parse the URL once

Exactly what it says in the tin.

Signed-off-by: gotjosh <josue.abreu@gmail.com>

* use the existing tests

Signed-off-by: gotjosh <josue.abreu@gmail.com>

---------

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2023-11-24 11:05:13 +00:00
Mihai Doarna
27d8b68c9c
Auth: Add more tests for the SSO settings upsert function (#78544)
* add more tests for the SSO settings upsert function

* fix client id to match provider

* use time now in tests
2023-11-24 12:02:05 +02:00
Jo
7d559bc69a
AuthProxy: Do not allow sessions to be assigned with other methods (#78602)
do not allow login token with other methods
2023-11-24 11:00:53 +01:00
Jean-Philippe Quéméner
11d4f604f5
fix(alerting): proper handling for queries with multiple conditions in migration (#78591)
fix(alerting): proper handling for queries with multiple conditions
2023-11-23 18:05:44 +01:00
gotjosh
23fe8f4e9c
Alerting: Introduce a Mimir client as part of the Remote Alertmanager (#78357)
* Alerting: Introduce a Mimir client as part of the Remote Alertmanager

This is our first attempt at making Grafana communicate use Mimir as a backend - it uses a new set of APIs that we've developed on the Mimir side to upload the grafana configuration and alertmanager state so that it can then be ported over.

Codewise, we've introduced a couple of things:

A client to isolate in its own package all the communication that happens with Mimir
A few changes to the remote/alertmanager to include uploading the configuration and state when it starts
A few refactors that align a bit better with the design approach that we're thinking
An integration tests again these newly developed APIs using a custom image

---------

Signed-off-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2023-11-23 16:59:36 +00:00
Misi
7128415529
Auth: Add more context to logs around token rotation, revocation (#78600)
Add more context to logs around token rotation, revocation

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2023-11-23 16:48:54 +01:00
Joey
4f46fb412c
Tempo: Embed flame graph in span details (#77537)
* Embed flame graph

* Update test

* Update test

* Use toggle

* Update test

* Add tests

* Use const

* Cleanup

* Update profile tag

* Move flame graph out of tags, remove request and other cleanup + tests

* Update test

* Set flame graph by profile id and simplify logic

* Cleanup and redrawListView

* Create/use feature toggle
2023-11-23 13:36:53 +00:00
Gabriel MABILLE
91a5c3803c
RBAC: GrafanaAdmin users are admins of the Global Organization (#78559) 2023-11-23 12:17:28 +01:00
Kevin Wang
8bdfb7e1cf
chore(authn.service): fix typo in log statement (#76205) 2023-11-23 09:06:19 +01:00
Todd Treece
4203a83538
K8s: Prevent user impersonation (#78555) 2023-11-22 15:55:37 -05:00
Ashley Harrison
4290ed3d86
Chore: Remove newBrowseDashboards feature toggle (#78190)
* remove all the things

* fix OldFolderPicker tests

* i18n

* remove more unused code

* remove mutation of error object since it's now frozen in the redux state

* fix error handling
2023-11-22 15:22:00 +00:00
Jo
40c8e2fc75
Live: Move empty orgRole safety valve (#78531)
move empty orgRole safety valve
2023-11-22 15:51:11 +01:00
Mihai Doarna
f0d3e27ea7
Add unit tests for the removeSSOSettings API method (#78476)
add unit tests for the removeSSOSettings api method
2023-11-22 15:57:12 +02:00
Jo
0de66a8099
Authz: Remove use of SignedInUser copy for permission evaluation (#78448)
* remove use of SignedInUserCopies

* add extra safety to not cross assign permissions

unwind circular dependency

dashboardacl->dashboardaccess

fix missing import

* correctly set teams for permissions

* fix missing inits

* nit: check err

* exit early for api keys
2023-11-22 14:20:22 +01:00
Ieva
9a3b2937aa
Data sources: Refactor logic for naming new data sources (#78479)
* move the name finding logic for new data sources from frontend to backend

* cleanup and fix test

* linting

* change the way the number after the ds type is incremented - keep incrementing it without adding more hyphens

* enterprise spec updates (unrelated to the PR)
2023-11-22 09:57:26 +00:00
Xavi Lacasa
72759be6ec
AuthN: Support HA setups with External Service Account management (#78425)
* Lock when creating external service

* Add local lock back

* Improve function signature

* Define lockName separately to make it more explicit

* Update pkg/infra/serverlock/serverlock.go

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

* Update pkg/infra/serverlock/serverlock.go

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

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2023-11-22 10:15:13 +01:00
Tania
39754ba2d6
Nested Folders: Wrap create/update operations with transactions (#78000)
* Nested Folders: Add transaction to create and update methods

* Update tests

* Make IncreaseVersionForAllRulesInNamespace synchronous

* Resolve merge conflicts
2023-11-21 23:06:20 +02:00
Juan Cabanas
9c5daed336
PublicDashboards: Middleware creation (#77941) 2023-11-21 17:56:36 -03:00
Misi
3607a00692
Auth: Use camelCase in SSO Settings API (#78480)
Return/accept camelCase fields in sso setting api
2023-11-21 17:41:47 +01:00
Julien Duchesne
5acb981680
Swagger: Rename API Key AddCommand (#78491)
As a global definition, `AddAPIKeyCommand` is clearer
2023-11-21 11:25:21 -05:00
Gabriel MABILLE
b6b86bb0b3
RBAC: Check plugins:install globally (#78438)
* RBAC: Check plugins:install globally

* Add disclamer to the RBACSingleOrganization config option
2023-11-21 15:09:43 +01:00
Karl Persson
1eb19befaa
Login: refactor auth info package (#78459)
* Remove unused stats and metrics

* No longer collect metrics

* Remove unused dependency

* Move database from sub package
2023-11-21 14:47:23 +01:00
Andres Martinez Gotor
20f3a87bf5
Bug: Fix loading behavior with FlagExternalCorePlugins (#78388) 2023-11-21 11:51:13 +01:00
Karl Persson
d42201dbf4
Login: remove unused function (#78442)
* Move test to the db so we test the queries and not just testing the mock

* Remove unused function and dependencies

* Remove unused functions from the database

* Add some integration tests
2023-11-21 11:44:13 +01:00
Mihai Doarna
875ea092df
Add more unit tests for removeSSOSettings method (#78329)
* add more unit tests for remove sso settings

* add unit tests for the service method
2023-11-21 10:11:52 +02:00
Kat Yang
2f2ce3edbb
Chore: Deprecate ID from Folder (#78281)
* Chore: Deprecate ID from Folder

* chore: add more linter comments

* chore: add missing lint comment
2023-11-20 15:44:51 -05:00
Jo
259ecb1793
AuthZ: Improve team ID fetching for signedInUser (#78378)
* improve team ID fetching for signedInUser

* remove inner join

* rename func

* nit: remove extra params

* nit: spacing and wrapping
2023-11-20 16:23:13 +01:00
Misi
53f53a44e3
Auth: Make clientTokenRotation enabled by default (#78384)
Make clientTokenRotation enabled by default
2023-11-20 15:28:33 +01:00
Ieva
87c3703a0d
Data sources: show data source menu to users who only have access to create a data source (#78347)
* show data source menu to users who only have access to create a data source

* return early if missing permissions
2023-11-20 13:59:02 +00:00
Karl Persson
72db9739c7
UserAuth: clean-up auth entries on update (#78377)
* UserAuth: clean-up auth entries on update

* Update pkg/services/login/authinfoservice/database/database.go

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

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2023-11-20 14:58:32 +01:00
Misi
437ae8e8c5
Auth: Refactor OAuth connectors' initialization (#77919)
* Refactor AzureAD to init itself

* Use mapstructure to convert data to OAuthInfo

* Update

* Align tests

* Remove unused functions

* Add owner to mapstructure

* Clean up, lint

* Refactor Okta init, Align tests

* Address review comments, fix name in newSocialBase

* Update newSocialBase first param

* Refactor GitLab init, align tests

* Update pkg/login/social/common.go

Co-authored-by: Karl Persson <kalle.persson@grafana.com>

* Use ini conversion to map

* Leftovers

* Refactor GitHub connector initialization, align tests

* Refactor Google connector init, align tests

* Refactor grafana_com connector, align tests

* Refactor generic_oauth connector init, align tests

* cleanup

* Remove util.go

* Add tests for custom field init

* Change OAuthInfo's Extra type

* Fix

* Replace interface{} with any

* clean up

---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2023-11-20 09:45:40 +01:00
Ryan McKinley
49fc8214a0
K8s: Add etcd tests for dual write (local) (#78161) 2023-11-17 14:20:54 -05:00
Ivan Ortega Alba
ddfe4e1bdd
FeatureToggle: Disable dashgpt by default and mark it as preview (#78348) 2023-11-17 18:51:51 +02:00
Matthew Jacobson
893839d27b
Alerting: Move general alert rule validation from db-layer to model (#78325)
Alerting: Move general alert rule validation to model
2023-11-17 11:20:50 -05:00
Karl Persson
a929e3f2cf
Auth: Remove unused function (#78332)
Remove unused function
2023-11-17 17:07:39 +01:00
Karl Persson
140b5b4a61
AuthN: Add debug logs and check error during oauth token sync (#78323)
Add some debug logs and handle error
2023-11-17 16:03:25 +01:00
Giuseppe Guerra
027a157898
Plugins: Allow disabling "skip host environment variables" per-plugin (#78266)
* Plugins: Allow disabling skipping host environment variables per-plugin

* Renamed SkipEnvVarsDecorateFunc to SkipHostEnvVarsDecorateFunc

* PR review feedback

* fix tests
2023-11-17 16:12:05 +02:00