Commit Graph

7090 Commits

Author SHA1 Message Date
Karl Persson
a2cba3d0b5
User: Add tracing (#87028)
* Inject tracer in tests

* Annotate with traces

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-04-30 13:15:56 +02:00
Arati R
ec6f59a678
Chore: Update protoc-gen-go (#87116)
Update protoc-gen-go
2024-04-30 12:14:33 +02:00
Misi
1cb3f332a1
Chore: Remove extra sql select from the Insert function of userimpl.store (#87060)
Remove getAnyUserType
2024-04-30 08:54:20 +02:00
Yuri Tseretyan
052082a927
Alerting: Refactor Alert Rule Generators (#86813) 2024-04-29 21:52:15 -04:00
William Wernert
70ff229bed
Alerting: Use expected field name for receiver in HCL export (#87065)
* Use expected field name for receiver in hcl

Terraform provider expects `contact_point` instead of `receiver` in
notification settings on a rule.
2024-04-29 18:13:29 +01:00
Santiago
36a0499128
Alerting: Implement CreateSilence in the forked Alertmanager (remote primary mode) (#85716) 2024-04-29 18:47:25 +02:00
Santiago
1af2e69625
Alerting: Implement DeleteSilence in the forked AM (remote primary) (#85721) 2024-04-29 17:23:41 +02:00
Eric Leijonmarck
8a1f43a65d
User: Remove the lowercasing in the query for login conflict (#87032)
* refactor: remove the lowercasing in the query for login conflict

* refactor: move function into the closure gs
2024-04-29 12:24:14 +01:00
Ieva
cee713e34c
Chore: Add tracing to team service (#86999)
* add tracing to team service

* another test fix

* pass in context for team creation and membership checking
2024-04-29 11:32:03 +01:00
Steve Simpson
fbaa847a3c
Alerting: Pass logger into NewRemoteLokiBackend. (#87029)
Tiny refactor to allow a logger to be passed into NewRemoteLokiBackend.
2024-04-29 12:10:23 +02:00
Karl Persson
c4cfee8d96
User: support setting org and help flags though update function (#86535)
* User: Support setting active org through update function

* User: add support to update help flags through update function
2024-04-29 08:53:05 +02:00
Hugo Kiyodi Oshiro
7783b16e47
Plugins: Make grafana-com API URL usage consistent (#86920)
Plugins: Fix grafana-com API URL usage
2024-04-26 16:47:38 +02:00
Yuri Tseretyan
dff7cb9afb
Alerting: Move alertmanager api silence code to separate files (#86947)
* Move alertmanager api silence code to separate files unchanged

* Replace with silence model instead interface

---------

Co-authored-by: Matt Jacobson <matthew.jacobson@grafana.com>
2024-04-25 15:20:37 -04:00
Matthew Jacobson
3397e8bf09
Alerting: Improve error when receiver or time interval used by rule is deleted (#86865)
* Alerting: Improve error when receiver used by rule is deleted

* Remove RuleUID from public error and data

* Improve fallback error in am config post

* Refactor to expand to time intervals

* Fix message on unchecked errors to be same as before
2024-04-25 13:36:00 -04:00
Eric Leijonmarck
e394e16073
Auth: Force lowercase login/email for users (#86359)
* [WIP]: Force lowercase login/email for user CRUD

* warn and remove use of userCaseInsensitiveLogin check

* remove log warning

* reimplementation of the caseinsensitive

* need to decide if we want the conflict check or not

* remvoved the tests for conflict user by getEmail, getLogin

* added tests for user lowercase migration

* wip: emails next

* tests for email lowercasing

* review comments

* optimized login and email lookup before migrating
2024-04-25 17:31:17 +01:00
Ieva
748b3c855c
Chore: Clean up team membership code (#86914)
remove unused code, clean up commands
2024-04-25 16:46:24 +01:00
Mihai Doarna
4bf9405ce4
SSO: add SSO settings to secrets migrator (#86913)
* add sso settings to secrets migrator

* unify SSO settings in all log lines
2024-04-25 18:30:23 +03:00
Marcus Efraimsson
ac152ca416
Chore: Upgrade grpc-ecosystem/go-grpc-middleware to v2 (#86724)
* Chore: Replace deprecated prometheus grpc middleware

* go mod tidy without enterprise

* with updated sdk branch

* sdk v0.226.0

* remove deprecated opentracing support for outgoing plugin requests

* migrate to github.com/grpc-ecosystem/go-grpc-middleware/v2

* fix
2024-04-25 17:25:48 +02:00
Mihai Doarna
28e86c3edb
Mention the migrator in the secrets service readme (#86922)
mention the migrator in the secrets service readme
2024-04-25 17:44:55 +03:00
Karl Persson
cd724d74aa
Authn: move namespace id type (#86853)
* Use RoleType from org package

* Move to identity package and re-export from authn

* Replace usage of top level functions for identity

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
2024-04-25 12:54:36 +02:00
Ieva
8028d1c3e1
Chore: Update tests to use team membership hooks (#86846)
* update tests to use team membership hooks

* linting
2024-04-24 16:55:42 +01:00
Sofia Papagiannaki
a5a3ee9fa3
SQLStore: Disable redundant create and drop unique index migrations on dashboard table (#86857)
SQLStore: Disable create and drop unique index migrations
2024-04-24 15:25:43 +01:00
Alexander Zobnin
60ed6bfc33
Search: Fix slow query when user does not have roles assigned (#86791)
* Search: Fix slow query when user does not have roles assigned

* Check all required actions and skip if not found
2024-04-24 13:23:08 +03:00
Charandas
d46b163810
Authn (jwt_auth): add tracing spans for validating newer use cases (#86812) 2024-04-24 02:40:00 -07:00
Serge Zaitsev
522a98c126
Chore: Make Cfg field private in SQLStore (#85593)
* make cfg private in sqlstore

* fix db init in tests

* fix case

* fix folder test init

* fix imports

* make another Cfg private

* remove another Cfg

* remove unused variable

* use store cfg, it has side-effects

* fix mutated cfg in tests
2024-04-24 10:38:40 +02:00
Piotr Jamróz
f6e472f879
Explore: Show a drawer with tabs for the library and query history (#86279)
* Create basic feature toggle

* Rename context to reflect it contains query history and query library

* Update icons and variants

* Rename hooks

* Update tests

* Fix mock

* Add tracking

* Turn button into a toggle

* Make dropdown active as well

This is required to have better UI and an indication of selected state in split view

* Update Query Library icon

This is to make it consistent with the toolbar button

* Hide query history button when query library is available

This is to avoid confusing UX with 2 button triggering the drawer but with slightly different behavior

* Make the drawer bigger for query library

To avoid confusion for current users and test it internally a bit more it's behind a feature toggle. Bigger drawer may obstruct the view and add more friction in the UX.

* Fix tests

The test was failing because queryLibraryAvailable was set to true for tests. This change makes it more explicit what use case is being tested

* Remove active state underline from the dropdown

* Allow closing Query Library drawer from the toolbar

* Simplify dropdown design
2024-04-24 10:32:11 +02:00
Karl Persson
0fa983ad8e
AuthN: Use typed namespace id inside authn package (#86048)
* authn: Use typed namespace id inside package
2024-04-24 09:57:34 +02:00
Kristin Laemmert
9553923eb7
Chore: Fix failing ssosettingimpl test (#86792)
Chore: Fix failing ssosetting test
2024-04-23 11:36:34 -04:00
George Robinson
2049f766c6
Remove fmt.Println of client certificate (#86773) 2024-04-23 15:15:52 +01:00
Laura Fernández
2fb38a34ac
Navigation: Add a return to previous button when navigating to different sections (#86764) 2024-04-23 15:56:04 +02:00
Mihai Doarna
bf15329492
SSO: run the validation on upsert with all secrets in settings (#86579)
* run the validation on upsert with all secrets in settings

* rename social to reloadable
2024-04-23 16:50:16 +03:00
Santiago
a6be12c037
Alerting: Implement SaveAndApplyConfig in the forked Alertmanager (remote primary) (#84659)
* Alerting: Implement SaveAndApplyConfiguration in the forked Alertmanager struct

* call SaveAndApplyConfig on the remote first, log errors for the internal

* add comments explaining why we ignore errors in the internal AM

* restore go.work.sum
2024-04-23 15:45:35 +02:00
Steve Simpson
a6ad2380bf
Alerting: Refactor api_prometheus.go request handlers. (#86639)
This splits the request handlers into two functions, one which is the actual
handler and one which is independent from the Grafana `ReqContext` object. This
is to make it easier to reuse the implementation in other code.

Part of the refactoring changes the functions which get query parameters from
the request to operate on a `url.Values` instead of the request object.

The change also makes the code consistently use `req.Form` instead of a
combination of `req.URL.Query()` and `req.Form`, though I have left
`api_ruler` as-is to avoid this PR growing too large.
2024-04-23 14:50:26 +02:00
Santiago
c77ab53819
Alerting: implement SaveAndApplyConfig in the remote Alertmanager struct (#84642)
* implement SaveAndApplyConfig in the remote Alertmanager struct

* remove ID from CreateGrafanaAlertmanagerConfig call

* decrypt, test that we decrypt, refactor

* fix duplicated declaration in test

* rephrase comment, remove unnecessary conversion to slice of bytes

* fix test
2024-04-23 14:37:10 +02:00
Santiago
8b7c2a459b
Alerting: Implement SaveAndApplyDefaultConfig in the forked Alertmanager (remote primary mode) (#85668)
* Alerting: Implement SaveAndApplyDefaultConfig in the forked Alertmanager (remote primary)

* log the error for the internal AM instead of returning it
2024-04-23 14:36:40 +02:00
Mihai Doarna
4d9e35ba57
SSO: add configurableProviders list to SSO service (#86622)
* add configurableProviders list to sso service

* address feedback
2024-04-23 10:00:43 +03:00
Alexander Weaver
c32953e52c
Alertign: Create feature toggle for recording rules (#86696)
create toggle for recording rules
2024-04-22 12:53:16 -05:00
Yuri Tseretyan
9735a8a080
Alerting: Distinguish conflict violation errors (#86634)
* update generator to set ID = 0 and do not set 0 if unique is needed
* return proper message when the constraint violation
2024-04-22 12:28:46 -04:00
Julian Siebert
14f018e3fc
Docs: Use correct description for "og_priority" (#80889) 2024-04-22 13:53:18 +00:00
Kristina
2247d6c415
Short Links: Add setting for changing expiration time (#86003)
* Add setting for changing shortlink expiration time

* Add docs, add better language

* put all the numbers in the duration 🤷

* 🙄

* update language to be correct and clear

* Add max limit and more documentation
2024-04-22 07:39:24 -05:00
Steve Simpson
54290f2ac4
Alerting: Fix TestRouteGetRuleStatuses as much as possible. (#86666)
This test has been skipped for a long time, so it doesn't work anymore. I've
fixed the test so it works again, but left some tests disabled which were
apparently flaky. If we see the other test cases flaking, we'll have to
disable it again.

Fixes:
- Use fake access control for most test cases, and real one for FGAC test cases.
- Check that "file" in API responses the full folder path, not folder title.
2024-04-22 12:36:50 +02:00
Steve Simpson
f07f48616a
Alerting: Fix panic when limit_alerts=0. (#86640)
Oversight in the TopK function meant if k=0, then we'd panic when checking
element zero in the heap, because no items are ever allowed into the heap.
2024-04-22 10:14:19 +02:00
Michael Mandrus
45a7f649fe
CMS: Create local implementation of cloud migration for dev use (#86637)
* add developer mode property to config

* create cms stub

* cleanup

* implement and wire up gcom stub

* fix errors

* don't document the flag
2024-04-20 23:51:58 -04:00
Steve Simpson
6ea97e41fb
Alerting: Consistently return Prometheus-style responses from rules APIs. (#86600)
* Alerting: Consistently return Prometheus-style responses from rules APIs.

This commit is part refactor and part fix. The /rules API occasionally returns
error responses which are inconsistent with other error responses. This fixes
that, and adds a function to map from Prometheus error type and HTTP code.

* Fix integration tests

* Linter happiness

* Make linter more happy

* Fix up one more place returning non-Prometheus responses
2024-04-19 21:03:20 +02:00
Robert Horvath
86a9533863
Chore: Replace backend platform codeownership (#86010)
* Replace backend platform codeownership

* fix go.mod with work sync

* fix go.mod

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
2024-04-19 19:12:59 +02:00
Eric Leijonmarck
ddabef9895
RBAC: Add actionsets struct and write path (#86108)
* Add actionsets struct and failing test

* update from review

* review comments

* review comments update

* refactor: create interface

* actionset service

* fix tests

* move from wireoss to wire

* Apply suggestions from code review

remove unnecessary comments

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>

* nil for the actionsetservice

* Revert "nil for the actionsetservice"

This reverts commit e3d3cc8171.

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2024-04-19 15:38:14 +01:00
Santiago
529f55cfe8
Alerting: Remove isDefault field from receivers (Alertmanager configuration) (#86605)
Alerting: Remove isDefault field from receivers in the Alertmanager configuration
2024-04-19 15:44:20 +02:00
Santiago
309a7e7684
Alerting: Implement SaveAndApplyDefaultConfig in the remote Alertmanager struct (#85005)
* Alerting: Implement SaveAndApplyDefaultConfig in the remote Alertmanager struct

* send the hash of the encrypted configuration

* tests, default config hash in AM struct

* add missing default config to test

* restore build directory

* go work file...

* fix broken test

* remove unnecessary conversion to []byte

* go work again...

* make things work again with latest main branch changes

* update error messages in tests for decrypting config
2024-04-19 15:11:07 +02:00
Santiago
a2ce8fefed
Alerting: Use a struct when sending a Grafana AM configuration to the remote Alertmanager (#86451)
* Alerting: Use a struct when sending a Grafana AM configuration to the remote Alertmanager

* remove '-distroless' from mimir image name
2024-04-19 13:04:18 +02:00
Steve Simpson
5f7612834e
Alerting: Refactoring in api_prometheus.go to allow code reuse. (#86575)
Preparing these functions to be used by some other part of the codebase,
which does not have a `contextmodel.ReqContext`, only the normal request
structure (`url.Values`, etc). This is slightly messy because of how
Grafana allows url parameters to be in the URL or in the request body,
so we need to make sure to invoke the form parsing logic in `ReqContext`.
2024-04-19 12:52:01 +02:00
Alex Khomenko
44e1bce55a
Feature toggles: Remove dashboardEmbed toggle (#86587) 2024-04-19 12:48:08 +02:00
Steve Simpson
73873f5a8a
Alerting: Optimize rule status gathering APIs when a limit is applied. (#86568)
* Alerting: Optimize rule status gathering APIs when a limit is applied.

The frontend very commonly calls the `/rules` API with `limit_alerts=16`. When
there are a very large number of alert instances present, this API is quite
slow to respond, and profiling suggests that a big part of the problem is
sorting the alerts by importance, in order to select the first 16.

This changes the application of the limit to use a more efficient heap-based
top-k algorithm. This maintains a slice of only the highest ranked items whilst
iterating the full set of alert instances, which substantially reduces the
number of comparisons needed. This is particularly effective, as the
`AlertsByImportance` comparison is quite complex.

I've included a benchmark to compare the new TopK function to the existing
Sort/limit strategy. It shows that for small limits, the new approach is
much faster, especially at high numbers of alerts, e.g.

100K alerts / limit 16: 1.91s vs 0.02s (-99%)

For situations where there is no effective limit, sorting is marginally faster,
therefore in the API implementation, if there is either a) no limit or b) no
effective limit, then we just sort the alerts as before. There is also a space
overhead using a heap which would matter for large limits.

* Remove commented test cases

* Make linter happy
2024-04-19 11:51:22 +02:00
Ryan McKinley
5a8384a245
QueryService: Add feature toggles to better support testing (#86493) 2024-04-19 12:26:21 +03:00
Will Browne
8a5c0cfdc0
Plugins: Pass cancellable context during API server creation (#86545) 2024-04-19 09:22:14 +03:00
Matthew Jacobson
a20197229e
Alerting: Prevent simplified routing zero duration GroupInterval and RepeatInterval (#86561)
Prevent zero duration GroupInterval and RepeatInterval
2024-04-18 21:08:38 -04:00
Matthew Jacobson
71445002b7
Alerting: Fix simplified routing group by override (#86552)
* Alerting: Fix simplified routing custom group by override

Custom group by overrides for simplified routing were missing required fields
GroupBy and GroupByAll normally set during upstream Route validation.

This fix ensures those missing fields are applied to the generated routes.

* Inline GroupBy and GroupByAll initialization instead of normalize after
2024-04-18 21:08:14 -04:00
ismail simsek
28a683cf28
InfluxDB: Remove influxdbSqlSupport feature toggle (#86518)
Remove influxdbSqlSupport feature toggle
2024-04-18 16:29:27 +02:00
Andres Martinez Gotor
eac02a61e1
Return plugin error when requesting settings (#86052) 2024-04-18 14:29:02 +02:00
Mihai Doarna
57848bbe23
Auth: encrypt/decrypt SAML secrets in SSO settings service (#85253)
encrypt/decrypt saml secrets in sso settings service
2024-04-18 15:16:59 +03:00
Andres Martinez Gotor
0f4a47b180
Plugin load errors: Add more well-known errors (#85960) 2024-04-18 13:04:22 +02:00
Michael Mandrus
df4c8c3cbc
CloudMigrations: Move business logic out of api layer (#86406)
* move run migration to the cloudmigrationimpl layer

* add migration run list logic down a layer

* remove useless comments

* pull cms calls into their own service
2024-04-17 15:43:09 -04:00
Aaron Godin
d409d8e860
IAM - Fix error messages for resource permissions endpoints (#85773)
* IAM: fix many error messages in access-related code to provide more information

* Remove debug statement

* Refactor resourcepermissions package to use errutil

* Replace a few more errors with errutil and wrap errors found in users and teams services

* Apply diff of openAPI spec
2024-04-17 08:53:28 -05:00
Karl Persson
1a6777cb93
User: use update function for password updates (#86419)
* Update password through Update function instead

* Remove duplicated to lower

* Refactor password code
2024-04-17 15:24:36 +02:00
Andre Pereira
93c24403b3
Explore: Move app to under explore > traces (#86436)
Move app to under explore > traces
2024-04-17 14:18:06 +01:00
Kristin Laemmert
03b795844c
SQLStore: Improve recursive CTE support detection (#86397)
sqlstore: improve recursive CTE support detection

Vitess returns a not supported error, not a parse error

Co-authored-by: Derek Perkins <derek@nozzle.io>
2024-04-17 08:37:47 -04:00
Eric Leijonmarck
9c1ef8b16e
Auth: Remove caseinsensitive check on update user (#86286)
* Removal: case insensitive check on update

* refactor and removal of test for duplicate user

* refactor to still shadow user variable
2024-04-16 17:47:17 +01:00
Matthew Jacobson
533bed6d94
Alerting: Fix simplified routes '...' groupBy creating invalid routes (#86006)
* Alerting: Fix simplified routes '...' groupBy creating invalid routes

There were a few ways to go about this fix:
1. Modifying our copy of upstream validation to allow this
2. Modify our notification settings validation to prevent this
3. Normalize group by on save
4. Normalized group by on generate

Option 4. was chosen as the others have a mix of the following cons:
- Generated routes risk being incompatible with upstream/remote AM
- Awkward FE UX when using '...'
- Rule definition changing after save and potential pitfalls with TF

With option 4. generated routes stay compatible with external/remote AMs, FE
doesn't need to change as we allow mixed '...' and custom label groupBys, and
settings we save to db are the same ones requested.

In addition, it has the slight benefit of allowing us to hide the internal
implementation details of `alertname, grafana_folder` from the user in the
future, since we don't need to send them with every FE or TF request.

* Safer use of DefaultNotificationSettingsGroupBy

* Fix missed API tests
2024-04-16 12:14:39 -04:00
Nick Richmond
d3fee607e2
Expressions: sort numeric metrics behind feature toggle (#85911)
* feat: sort numeric metrics behind feature toggle

* chore: upgrade `dataplane/sdata` to latest tag

* chore: `go work sync`
2024-04-16 10:52:47 -04:00
Ieva
036f826b87
AuthZ: Further protect admin endpoints (#86285)
* only users with Grafana Admin role can grant/revoke Grafana Admin role

* check permissions to user amdin endpoints globally

* allow checking global permissions for service accounts

* use a middleware for checking whether the caller is Grafana Admin
2024-04-16 15:48:12 +01:00
Karl Persson
0f06120b56
User: Clean up update functions (#86341)
* User: remove unused function

* User: Remove UpdatePermissions and support IsGrafanaAdmin flag in Update function instead

* User: Remove Disable function and use Update instead
2024-04-16 16:33:50 +02:00
owensmallwood
8c8885ef23
Storage Api: Adds traces (#85391)
- adds traces and improved logging to the unified storage server
- add a configurable logger to the gRPC server service
2024-04-16 08:30:51 -06:00
Karl Persson
8520892923
User: Fix GetByID (#86282)
* Auth: Remove unused lookup param

* Remove case sensitive lookup for GetByID
2024-04-16 15:24:34 +02:00
Ryan McKinley
ba510d1a7d
Playlists: Enable kubernetesPlaylists by default in OSS (#86259) 2024-04-16 09:19:35 +02:00
Brendan O'Handley
f85470d652
Prometheus: Use the frontend package in Prometheus and remove feature toggle (#86080)
* add history links for monaco completion provider folder

* add history links for monaco query field folder

* add history links for components folder

* add history links for configuration folder

* add history links for dashboard json folder

* add history links for gcopypaste folder

* add history link for variableMigration

* add history link for querybuilder/components/metrics-modal folder

* add history link for querybuilder/components/promqail folder

* add history links for querybuilder/components folder

* add history links for querybuilder/hooks folder

* add history links for querybuilder/shared folder

* add history links for querybuilder folder

* add history links for querycache folder

* add history links for src folder

* use frontend package and custom auth in module.ts

* remove files and fix import issues

* remove usePrometheusFrontendPackage

* remove extra files

* update betterer

* remove extra files after rebase

* fix betterer for rebase

* fix e2e flakiness
2024-04-15 16:45:23 -05:00
Alexander Weaver
5b1498f98f
Alerting: Return a 400 and errutil error when trying to delete a contact point that is referenced by a policy (#85481)
Return a 400 and errutil error when trying to delete a contact point that is referenced by a policy
2024-04-15 09:25:28 -05:00
linoman
51da96d94e
Auth: Add IsClientEnabled and IsEnabled for the authn.Service and authn.Client interfaces (#86034)
* Add `Service. IsClientEnabled` and `Client.IsEnabled` functions

* Implement `IsEnabled` function for authn clients

* Implement `IsClientEnabled` function for authn services
2024-04-15 10:54:50 +02:00
Giuseppe Guerra
eec9d3dbc4
Plugins: Removed feature toggle pluginsDynamicAngularDetectionPatterns (#85956)
* Plugins: Removed feature toggle pluginsDynamicAngularDetectionPatterns

* re-generate feature toggles
2024-04-15 10:37:28 +02:00
Yuri Tseretyan
12605bfed2
Alerting: Update fixed roles to include silences permissions (#85826)
* update fixed roles to include silences
* add silence actions to managed permissions
* update documentation
2024-04-12 12:37:34 -04:00
Ieva
56f4664875
RBAC: add a feature toggle for action sets (#86064)
* add a feature toggle for action sets

* update feature toggle name
2024-04-12 17:19:25 +01:00
Steve Simpson
ad7f804255
Alerting: Fix evaluation metrics to not count retries (#85873)
* Change evaluation metrics to only count once per eval, and add new metrics.

* Cosmetic: Move eval total Inc() to orginal place.
2024-04-12 16:20:46 +02:00
lean.dev
c8d185502b
Fixes CMS url for dev environment (#86056) 2024-04-12 14:19:38 +00:00
Karl Persson
73fecc8d80
Authn: Identity resolvers (#85930)
* AuthN: Add NamespaceID struct. We should replace the usage of encoded namespaceID with this one

* AuthN: Add optional interface that clients can implement to be able to resolve identity for a namespace

* Authn: Implement IdentityResolverClient for api keys

* AuthN: use idenity resolvers

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
2024-04-12 11:38:20 +02:00
Charandas
a39fe593c2
K8s: remove standalone authenticator in favor of providing one through the factory (#85901) 2024-04-11 21:30:23 +02:00
Brendan O'Handley
a25b59c6d8
Prometheus: Change feature toggle usePrometheusFrontendPackage to general availability (#85951)
change feature toggle to GA after testing
2024-04-11 14:13:30 -04:00
Ieva
58059da10b
RBAC: Fix global role deletion in hosted Grafana (#85980)
take into account the value of RBACSingleOrganization setting when determining org
2024-04-11 18:50:23 +01:00
Giuseppe Guerra
e42d8f0bd0
Plugins: Removed feature toggle enablePluginsTracingByDefault (#85953) 2024-04-11 18:40:47 +02:00
Andres Martinez Gotor
ab5a065256
Revamp plugin loading error management (#85939) 2024-04-11 16:18:04 +02:00
Bruno
69a92a7a2f
CloudMigrations: include stack id in access policy and token names (#85868)
* CloudMigrations: include stack id in access policy and token names

* CloudMigrations: include slug in the display name

* formatting
2024-04-11 09:43:46 -03:00
Marcus Efraimsson
3e385763c5
Tracing: Improve HTTP request/middleware spans and standalone apiserver (#85715)
Fixes so that auth middleware trace/span doesn't wrap the next handlers.
Allow tracing service name to be overridden in standalone apiserver.
Change k8s api tracing operation name to KubernetesAPI from 
grafana-apiserver (which is the service name)
2024-04-11 13:28:23 +02:00
Timur Olzhabayev
116088c722
Chore: Making versioncheck url rely on config instead of being hardcoded (#85855)
* Making versioncheck url rely on config instead of being hardcoded

* Update pkg/services/updatechecker/plugins.go

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>

* making the names a bit more generic and using url.url library

* fixing tests

* fixing linting

---------

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2024-04-11 12:04:53 +02:00
Bogdan Matei
62c512662c
Dashboard: Allow auto refresh option when saving a dashboard (#85581)
Fix saving auto refresh option
2024-04-11 12:31:47 +03:00
Karl Persson
895222725c
Session: set authID and authenticatedBy (#85806)
* Authn: Resolve authenticate by and auth id when fethcing signed in user

* Change logout client interface to only take Requester interface

* Session: Fetch external auth info when authenticating sessions

* Use authenticated by from identity

* Move call to get auth-info into session client and use GetAuthenticatedBy in various places
2024-04-11 10:25:29 +02:00
Alexander Zobnin
3127566a20
Access control: Use ResolveIdentity() for authorizing in org (#85549)
* Access control: Use ResolveIdentity() for authorizing in org

* Fix tests

* Fix middleware tests

* Use ResolveIdentity in HasGlobalAccess() function

* remove makeTmpUser

* Cleanup

* Fix linter errors

* Fix test build

* Remove GetUserPermissionsInOrg()
2024-04-10 12:42:13 +02:00
Karl Persson
ebb4bb859e
Authn: allow ResolveIdentity to authenticate in "global" scope (#85835)
* Authn: allow ResolveIdentity to authenticate in "global" scope

* Use constant
2024-04-10 11:53:45 +02:00
Karl Persson
fd870702c7
Chore: Remove unused function TryRotateToken (#85836)
* Chore: Remove unused function

* remove unused function
2024-04-10 11:15:43 +02:00
Darren Janeczek
66c0fd4dcc
chore: update datatrails feature flag and enable (#85508)
* chore: update datatrails feature flag and enable

* fix: rename `datatrails` feature flag to `exploreMetrics`
2024-04-09 14:15:18 -04:00
Matthew Jacobson
f79dd7c7f9
Alerting: Persist silence state immediately on Create/Delete (#84705)
* Alerting: Persist silence state immediately on Create/Delete

Persists the silence state to the kvstore immediately instead of waiting for the
 next maintenance run. This is used after Create/Delete to prevent silences from
 being lost when a new Alertmanager is started before the state has persisted.
 This can happen, for example, in a rolling deployment scenario.

* Fix test that requires real data

* Don't error if silence state persist fails, maintenance will correct
2024-04-09 13:39:34 -04:00
Todd Treece
72472e5eb7
K8s: Add slog wrapper (#84680) 2024-04-09 18:39:25 +03:00
idafurjes
5c4a2de59b
Add FolderUID for library elements (#83819)
* Revert "Revert "Add FolderUID for library elements" (#83776)"

This reverts commit 0dfdb2ae47.

* Fix bug, dashboard id and library element fodler_id are the corresponding values
Dashboard table hold both dahboards and tables
2024-04-09 12:27:43 +02:00
Santiago
2e7cc68394
Alerting: Remove CleanUp method from the Alertmanager (#85650)
Alerting: Remove Cleanup method from the Alertmanager
2024-04-09 12:13:27 +02:00
Misi
4c12d77b98
Util: Support parsing and splitting strings enclosed in quotes in util.SplitString (#85735)
* Support parsing string enclosed in quotation marks in util.SplitString

* Support mixed formats of string list
2024-04-09 10:35:57 +02:00
Yuri Tseretyan
509691b416
Alerting: Introduce authorization logic for operations on silences (#85418)
* extract genericService from RuleService just to reuse it later
* implement silence service

---------

Co-authored-by: William Wernert <william.wernert@grafana.com>
Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
2024-04-08 18:02:28 -04:00
Dan Cech
5dfe4cf407
Storage: Watch tests (#85496)
* basic watch tests working

* refactor to read previous event within poller

* add watch test files

* cleanup

* watch tests passing

* debug cleanup

* special handling for canceled context

* cleanup

* fix wire

* fix sqlite_sequence cleanup issue

* move watch tests to integration, wait for provisioned dashboards

* handle context deadline exceeded and eof errors

* add comment about sleep
2024-04-08 11:42:12 -04:00
owensmallwood
37d39de36d
Storage Api: Add metrics (#85316)
* Storage server runs own instrumentation server if its the sole target. Starts adding some sample metrics for now.

* adds metric for failed optimistic locks

* refactors metrics registration to own method on service for testability. Adds tests.

* Register sql storage server metrics from within the service

* fixes test

* troubleshooting drone test failures. Maybe timing when starting instrumentation server?

* Waits until instrumentation server has started. Updates tests.

* defer wont get called unless theres an error. removing.

* wait for instrumentation server to be running

* linter - close res body

* use port 3000 for metrics and removes test metric inc() call

* fixes test - updates port

* refactors module server to provide an instrumentation server module when there is no ALL or CORE target provided and running as single target

* make instrumentation server a dependency of all modules that do not run their own http server

* adds module server test

* adds tests for instrumentation service and removes old tests that aren't needed

* ignore error in test

* uses helper to start and run service

* when running wait on ctx done or http server err

* wait for http server

* removes println

* updates module server test to be integration test

* require no error in goroutine

* skips integration test when GRAFANA_TEST_DB not defined

* move http server start into start, verify returned content

* make test error when run fails

* try waiting longer and see if drone tests pass

* update integration test mysql creds to match drone

* go back to only waiting half second

* debug log drone mysql connection string

* use same db connection config as drone

* try using same hostname as drone

* cant use localhost as mysql hostname in drone tests. Need to parse it from the cfg db connection string

---------

Co-authored-by: Dan Cech <dcech@grafana.com>
2024-04-08 08:35:01 -06:00
Dan Cech
9c46e71d5a
Storage: Support continue at specified resource version (#84868)
* support continue at specified resource version

* detect whether list continue pages need to use entity_history, remove BatchRead, expand selectQuery helper

* refactor continue token handling

* fix tests, increase history chunk size

* lint fix
2024-04-08 09:57:02 -04:00
Santiago
6a75a8f354
Alerting: Update grafana/alerting and use Upsert for creating silences (#85676)
* Alerting: Update grafana/alerting and use Upsert for creating silences

* go.work.sum

* change error message in tests for silences (save -> upsert)
2024-04-08 11:46:14 +02:00
Mikel Vuka
724517dc40
Provisioning: datasources auto deletion (#83034) 2024-04-08 11:45:39 +02:00
Karl Persson
46ee87a0fc
Authn: Ignore context.Canceled errors when logging auth errors (#85707)
Ignore context.Canceled errors when logging auth errors
2024-04-08 10:25:24 +02:00
Leonard Gram
1332d8ba24
Cloudmigration: Sets the runID correctly when saving (#85661)
Sets the runID correctly instead of setting it to the same as the migration id.
2024-04-05 18:03:45 +02:00
Isabella Siu
58f32150c2
CloudWatch: Improve metric label parsing (#84835) 2024-04-05 11:57:56 -04:00
Alexander Weaver
03114e7602
Alerting: Return better error for invalid time range on alert queries (#85611)
* Return better error for invalid time range

* drop comment
2024-04-05 09:20:21 -05:00
Misi
8796d2d307
Auth: Convert SetDefaultOrgHook to PostLoginHook (#85649)
* Convert SetDefaultOrgHook to PostLoginHook
2024-04-05 16:03:51 +02:00
Alexander Weaver
734d0111cb
Alerting: Export pure function to convert query results to alert results (#85393)
Exported pure function to convert query results to alert results
2024-04-05 08:57:31 -05:00
Karl Persson
b1fc0861f1
AuthN: reset email verified on email change (#85643)
* AuthN: reset email verified on email change

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
2024-04-05 14:19:12 +02:00
Santiago
c7573bb0f7
Alerting: Make retention period configurable for the notification log (#85605)
* Alerting: Make retention period configurable for the notification log

* update sample.ini

* fix outdated comment (on disk -> kvstore)

* skip checking cyclomatic complexity for ReadUnifiedAlertingSettings
2024-04-05 12:25:43 +02:00
Karl Persson
ba41954854
Email: trigger email verification flow (#85587)
* Add email and email_verified to id token if identity is a user

* Add endpoint to trigger email verification for user

* Add function to clear stored id tokens and use it when email verification is completed
2024-04-05 12:05:46 +02:00
kay delaney
6a53864f7a
LibraryPanelRBAC: Fix issue with importing dashboards containing library panels (#83980) 2024-04-05 10:11:02 +01:00
Josh Hunt
5ce8b60878
E2C: Resources table refactor (#85585)
* E2C: Resources table refactor

* update swagger spec with enums

* use native resource item type, rather than our mock type

* unit tests for resources table

* update spec
2024-04-05 10:08:42 +01:00
Nick Richmond
559fab9dc6
Prometheus: Fuzzy search for metric names in Code Mode (#85396)
* perf: limit metric names in Code Mode suggestions

* feat: configurable metric names limit

* feat: code mode autocomplete info/disclaimer

* chore: put new functionality behind new feature toggle

* refactor: avoid type assertions

* refactor: avoid explicit `any`

refactor: type guards

* refactor: type guards

* chore: add testdata results

* fix: add missing feature toggle guard

* perf: prefer array access to `Array.prototype.at`

* test: add missing config override

* test: refactor for brevity & clarity

* perf: avoid unnecessary mapping

* chore: undo testdata changes

* fix: use correct limit; perf optimizations

* refactor: avoid unnecessary `async`s

* types: simplify

* test: add missing tests

* fix: avoid hardcoding

* test: update mock path

* docs: fix typo

style: remove formatting artifact

style: remove formatting artifact

style: remove formatting artifact

* fix: event scope regression

* style: refactor for clarity

* refactor: prefer `useCallback` to in-effect handler

* refactor: simplify & broaden `filter`

* refactor: rename file to keep with conventions

* chore: mirror Prometheus package changes in app

* refactor: prefer no `@ts-ignore`

* chore: update betterer results

* docs: use type in TSDoc `@link` without `@ts-ignore`

* test: add missing provider

* test: fix jest mock path

* fix: display disclaimer in empty input case
2024-04-04 23:38:23 +03:00
Alexander Weaver
623ee3a2be
Alerting: Only append /alertmanager when sending alerts to mimir targets if not already present (#85543)
Don't append alertmanager if not present
2024-04-04 11:58:41 -05:00
Dave Henderson
5687243d0b
Feature Flags: use FeatureToggles interface where possible (#85131)
* Feature Flags: use FeatureToggles interface where possible

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* Replace TestFeatureToggles with existing WithFeatures

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
2024-04-04 12:22:31 -04:00
Serge Zaitsev
faa1244518
Chore: Replace sqlstore with db interface (#85366)
* replace sqlstore with db interface in a few packages

* remove from stats

* remove sqlstore in admin test

* remove sqlstore from api plugin tests

* fix another createUser

* remove sqlstore in publicdashboards

* remove sqlstore from orgs

* clean up orguser test

* more clean up in sso

* clean up service accounts

* further cleanup

* more cleanup in accesscontrol

* last cleanup in accesscontrol

* clean up teams

* more removals

* split cfg from db in testenv

* few remaining fixes

* fix test with bus

* pass cfg for testing inside db as an option

* set query retries when no opts provided

* revert golden test data

* rebase and rollback
2024-04-04 15:04:47 +02:00
Dominik Prokop
32b6ef9d15
Feature toggle to add filter and group by variables to all new dashboards by default (#85531)
* Add feature toggle

* Add filters and group by variables by default to all new dashboards

* Nits

* Tests

* Rename feature toggle to newDashboardWithFiltersAndGroupBy
2024-04-04 13:25:21 +02:00
Karl Persson
504870f10a
Auth: Decouple client and hook registration (#85084) 2024-04-04 09:33:00 +02:00
Todd Treece
c01531dc79
K8s: Use tracing handler from component-base (#85560) 2024-04-04 00:39:09 +03:00
Michael Mandrus
ddf5fbe591
CMS: Update permissions required to use endpoints (#85555)
* try different perms

* fix compile issue

* remove ac dependency

* remove dependency
2024-04-03 22:43:48 +03:00
Josh Hunt
aad79c9400
E2C: Start connecting on-prem to real apis (#85527)
* E2C: Start connecting on-prem to real apis

* actually run the migration

* show resources

* basic dashboards resources

* show dashboard title

* remove console logs

* cleanup 1

* i18n

* disconnect

* i18n

* restore type

* use fixed format

* fix
2024-04-03 13:47:02 -04:00
William Wernert
cad8190a91
Alerting/Annotations: Return nothing from historian store if filtering by tags and matchAny is false (#85488)
* Return nothing from historian store if filtering by tag
2024-04-03 13:01:13 -04:00
Leonard Gram
a457ab3192
Cloudmigration: decode json data (#85548)
* decode get

* decode bytes

* response

* .

* linter

* quick fixes

---------

Co-authored-by: Michael Mandrus <michael.mandrus@grafana.com>
2024-04-03 18:47:49 +02:00
Jean-Philippe Quéméner
7cfd470c91
fix(alerting): only expose metrics if executing alerts (#85512) 2024-04-03 17:18:02 +02:00
Josh Hunt
e08b5bd456
E2C: Fix Swagger spec for createMigration post body (#85525)
* E2C: Fix Swagger spec for CreateCloudMigration post body

* actually, don't rename that type
2024-04-03 11:59:50 +00:00
idafurjes
b885da09da
CloudMigrations: Implement migrations API (#85348)
* Implement run migration endpoint

* Refactor RunMigration method into separate methods

* Save migration runs fix lint

* Minor changes

* Refactor how to use cms endpoint

* fix interface

* complete merge

* add individual items

* adds tracing to getMigration

* linter

* updated swagger definition with the latest changes

* CloudMigrations: Implement core API handlers for cloud migrations and migration runs (#85407)

* implement delete

* add auth token encryption

* implement token validation

* call token validation during migration creation

* implement get migration status

* implement list migration runs

* fix bug

* finish parse domain func

* fix urls

* fix typo

* fix encoding and decoding

* remove double decryption

* add missing slash

* fix id returned by create function

* inject missing services

* finish implementing (as far as I can tell right now) data migration and response handling

* comment out broken test, needs a rewrite

* add a few final touches

* get dashboard migration to work properly

* changed runMigration to a POST

* swagger

* swagger

* swagger

---------

Co-authored-by: Michael Mandrus <michael.mandrus@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
Co-authored-by: Michael Mandrus <41969079+mmandrus@users.noreply.github.com>
2024-04-03 13:36:13 +02:00
Ieva
beb15d938b
RBAC: Fix access checks for interactions with RBAC roles in hosted Grafana (#85485)
* don't check global permissions for cloud instances

* linting
2024-04-03 11:44:16 +01:00
Andres Martinez Gotor
9c7237891c
Plugins: Expose ExternalService in request config (#85187) 2024-04-03 09:22:34 +02:00
Leon Sorokin
1522499c4a
VizTooltips: Remove remaining old bits (#85500)
Co-authored-by: Adela Almasan <adela.almasan@grafana.com>
2024-04-02 19:32:01 -05:00
Jo
5340a6e548
Auth: Extended JWT client for OBO and Service Authentication (#83814)
* reenable ext-jwt-client

* fixup settings struct

* add user and service auth

* lint up

* add user auth to grafana ext

* fixes

* Populate token permissions

Co-authored-by: jguer <joao.guerreiro@grafana.com>

* fix tests

* fix lint

* small prealloc

* small prealloc

* use special namespace for access policies

* fix access policy auth

* fix tests

* fix uncalled settings expander

* add feature toggle

* small feedback fixes

* rename entitlements to permissions

* add authlibn

* allow viewing the signed in user info for non user namespace

* fix invalid namespacedID

* use authlib as verifier for tokens

* Update pkg/services/authn/clients/ext_jwt.go

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

* Update pkg/services/authn/clients/ext_jwt_test.go

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

* fix parameter names

* change asserts to normal package

* add rule for assert

* fix ownerships

* Local diff

* test and lint

* Fix test

* Fix ac test

* Fix pluginproxy test

* Revert testdata changes

* Force revert on test data

---------

Co-authored-by: gamab <gabriel.mabille@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-04-02 17:45:15 +02:00
Will Browne
257cc98062
Datasources: Remove unused functions (#85473)
* cleanup unused funcs

* remove more stuff
2024-04-02 16:19:52 +02:00
linoman
147154d2ea
Remove AuthConfigUIAdminAccess (#85452)
* Remove AuthConfigUIAdminAccess
2024-04-02 15:02:28 +02:00
Leonard Gram
4e89267603
Cloudmigration: swagger for the cloudmigration api (#85255)
* swagger for create token

* tried to fix errors

* update swagger annotations

* update swagger annotations

* update api GetMigrationList to return the *Response directly

* clean up previous commit

---------

Co-authored-by: joshhunt <josh@trtr.co>
2024-04-02 13:57:42 +02:00
Andres Martinez Gotor
d2ca95d304
Update plugin SDK to v0.219.0 (#85438) 2024-04-02 10:22:24 +02:00
Will Browne
22fe7b067c
Plugins: Set correct PDC config values for proxy requests (#85412)
pass appropriate values
2024-03-29 20:17:05 +02:00
Leonard Gram
383ebb2bc4
Cloudmigration: create migration (#85386)
* Cloudmigration: create migration

* fix drone build

* lint fix

* fix unit test

---------

Co-authored-by: Michael Mandrus <michael.mandrus@grafana.com>
2024-03-29 01:55:27 +01:00
Michael Mandrus
5a5f76ae0a
CloudMigrations: Add instance metadata to auth token (#85381)
* update how tokens are passed around

* rename structs
2024-03-28 15:02:54 -04:00
Charandas
0f1151964c
K8s: standalone authenticator that allows a type of downstream forwarding (#85130) 2024-03-28 20:52:28 +02:00
linoman
e4250a72db
JWT: Find login and email claims with JMESPATH (#85305)
* add function to static function to static service

* find email and login claims with jmespath

* rename configuration files

* Replace JWTClaims struct for map

* check for subclaims error
2024-03-28 17:25:26 +01:00
Karl Persson
73e426b081
User: email verification completion (#85259)
* TempUser: Include InvitedById in TempUserDTO

* Extract email verfication completion flow to service
2024-03-28 16:05:33 +01:00
lean.dev
5b147d0847
CloudMigration: Add service to list all migrations (#85308) 2024-03-28 08:50:31 -03:00
Karl Persson
5dd98a0fd5
RBAC: handle partially resolved scopes (#85323)
* RBAC: handle partially resolved scopes

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-03-28 10:08:07 +01:00
Will Browne
1a0ac381eb
Plugins: Send PDC file paths and contents for backwards compatibility (#85287)
* send paths and contents

* go work sync
2024-03-27 18:19:11 +01:00
Dan Cech
ef26fe95dc
Storage: GuaranteedUpdate fix & other improvements (#85206)
make GuaranteedUpdate work when ignoring not found errors, increase poll frequency, fix Delete
2024-03-27 10:38:49 -04:00