Commit Graph

7479 Commits

Author SHA1 Message Date
Ryan McKinley
1554bffcb8
Search: apply security in before returning results (#45430)
Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>
2022-02-16 09:47:41 -08:00
Will Browne
a2b391912a
Plugins: Add ability to enable debug logging per plugin (#45481) (#45485)
* use plugin ID in logger name

* retrigger

(cherry picked from commit bd0ff79e28)
2022-02-16 18:22:10 +01:00
Dan Cech
51cd6f3cc5
Configuration: Add ability to customize okta login button name and icon (#44079)
* add ability to customize okta login button name and icon

* update configs, add basic frontend test

* add icon to oauth settings type

* trigger tests

* fix typecheck
2022-02-16 11:35:00 -05:00
Torkel Ödegaard
2b9e46d1f8
Angular: Option to disable angular support and isolate angular dependencies (#45421)
* Angular: Initial setting that disables angular, load angular support in separate chunk

* Load angular panels on demand

* Load alerting in separate chunk only when angularSupportEnabled

* progress, do not export core_module if angular disabled

* Progress

* Update public/app/features/plugins/built_in_plugins.ts

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>

* Removing remaining usage of angular from outside angular app (not counting plugins)

* Update config and docs

* Fix sample.ini

* Update public/app/features/alerting/AlertTab.tsx

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Fixing prettier issue

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
2022-02-16 17:14:33 +01:00
Selene
d5b98772ed
Dashboards: Refactor service to make it injectable by wire (#44588)
* Add providers to folder and dashboard services

* Refactor folder and dashboard services

* Move store implementation to its own file due wire cannot allow us to cast to SQLStore

* Add store in some places and more missing dependencies

* Bad merge fix

* Remove old functions from tests and few fixes

* Fix provisioning

* Remove store from http server and some test fixes

* Test fixes

* Fix dashboard and folder tests

* Fix library tests

* Fix provisioning tests

* Fix plugins manager tests

* Fix alert and org users tests

* Refactor service package and more test fixes

* Fix dashboard_test tets

* Fix api tests

* Some lint fixes

* Fix lint

* More lint :/

* Move dashboard integration tests to dashboards service and fix dependencies

* Lint + tests

* More integration tests fixes

* Lint

* Lint again

* Fix tests again and again anda again

* Update searchstore_test

* Fix goimports

* More go imports

* More imports fixes

* Fix lint

* Move UnprovisionDashboard function into dashboard service and remove bus

* Use search service instead of bus

* Fix test

* Fix go imports

* Use nil in tests
2022-02-16 14:15:44 +01:00
Torkel Ödegaard
cfa24a3cfb
Prometheus: Auto legend handling (#45367)
* Legend editor is working

* It's working

* Progress on auto legend mode

* Fixes

* added unit tests

* Added go tests

* Fixing tests

* Fix issue with timing and internal state

* Update public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryCodeEditor.tsx

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2022-02-16 14:06:33 +01:00
Joey Tawadrous
b4dd3138ce
InfluxDB: metricFindQuery migration to backend (#44546)
* Send metricFindQuery to backend

* Added feature toggle

* Changed flag name

* metricFindQuery backend

* Added test for metricFindQuery backend parse

* Added test for show tag values

* Test for metricFindQueries

* Updated tests

* Put back comment

* Case insensitive in transformRows

* Check length ov value pair

* Sep tests

* Updated valuePair index
2022-02-16 09:16:22 +00:00
Sofia Papagiannaki
6a38ce2307
Resolve depedency cycle (#45427) 2022-02-16 10:59:34 +02:00
Yuriy Tseretyan
02f8e99ca1
Alerting: move fake stores to store package (#45428)
* make fake storage public
* move fake storages to store package
2022-02-15 17:24:39 -05:00
Ryan McKinley
d665306ad1
Search: add feature flag and basic service (#45112)
Co-authored-by: Artur Wierzbicki <artur@arturwierzbicki.com>
2022-02-15 10:26:03 -08:00
Ieva
11433cba97
Team access changes for editors when editorsCanAdmin is enabled (#45405)
* filter teams for editors to only show the teams that they are members of

* frontend changes to only allow clicking on teams that the user can edit

* update frontend test snapshots

* extend docs

* reword

* remove the comment for now

* Update backend tests

* reword the warning, and add it back in

* docs feedback

Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-02-15 17:09:03 +00:00
Sofia Papagiannaki
d718ee1918
SQLStore: Prevent concurrent migrations (#44101)
* SQLStore: Prevent concurrent migrations

* Hide behind a feature toggle

* Configurable locking attempt timeout

* Update docs/sources/administration/configuration.md

Co-authored-by: Igor Suleymanov <radiohead@users.noreply.github.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-02-15 18:54:27 +02:00
Ivana Huckova
636a45f065
Query history: Create API to patch comment of query in query history (#44981)
* Query history: Patch comment

* Update docs/sources/http_api/query_history.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update docs/sources/http_api/query_history.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Remove redundant check

* Use WithTransactionalDbSession to update comment

* Fix status code in test

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-02-15 15:43:17 +01:00
Torkel Ödegaard
a757a57c6e
Prometheus: Show executed query in inspector (#45362)
* Prometheus: Show executed query in inspector

* Loki: Improving test
2022-02-15 15:02:03 +01:00
Serge Zaitsev
b9e5bae51f
Chore: Remove bus.Dispatch from cleanup service (#45401) 2022-02-15 14:56:19 +01:00
Shirley
1c1a45a880
CloudWatch: Add tests to annotations query (#45337) 2022-02-15 12:45:50 +01:00
Gábor Farkas
a612087c63
loki: remove fullRangeLogsVolume feature flag (#45286) 2022-02-15 09:05:03 +01:00
Yuriy Tseretyan
095ea44e97
Alerting: Move BaseInterval and MinInterval to UnifiedAlerting config (#45107)
* use base interval if legacy value is less than the base interval
2022-02-11 16:13:49 -05:00
Ezequiel Victorero
4f815e3d8e
Access control: adding FGAC to annotation GET endpoints and fixed roles (#45102)
* Access control: adding FGAC to annotation GET endpoints and fixed roles

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-02-11 15:43:29 -03:00
Gabriel MABILLE
6fbf346747
AccessControl: Add endpoint to get user permissions (#45309)
* AccessControl: Add endpoint to get user permissions

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>

* Fix SA tests

* Linter is wrong :p

* Wait I was wrong

* Adding the route for teams:creator too

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
2022-02-11 17:40:43 +01:00
gotjosh
8bf2e642aa
Alerting: Fix updating notification channels in legacy (#45302)
The problem here is that without the orgID we ignore the lookup of the existing notification channel just before updating and end up failing the update because there is no channel available.
2022-02-11 16:13:51 +00:00
Marcus Efraimsson
6a776c78d4
Datasource: Fixes storing of secureJSONData when creating/updating datasource (#45290)
Fixes an issue introduced by #44987 where bus dispatch was replaced by calling sqlstore 
directly instead of the datasource service.

Fixes #45273
2022-02-11 15:52:14 +01:00
idafurjes
d8a56d08ba
Remove bus from usage stats (#45275) 2022-02-11 14:04:15 +01:00
Gábor Farkas
4a7cc3e0f0
loki: enable-by-default the full-range-logs-volume feature (try2) (#45246)
* loki: enable-by-default the full-range-logs-volume feature

* add explanation comment

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>

* fixed invalid code

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2022-02-11 11:28:27 +01:00
Ieva
6fb3aac2e1
Access control: team UI improvements with FGAC (#45255)
* show teams page for user who can't list teams but can create teams

* Fixing buttons and routes

* Small refactor

Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-02-11 09:58:37 +00:00
Yuriy Tseretyan
d4ac1f0ce1
Update quota service to accept context (#45186) 2022-02-10 22:17:50 +01:00
Yuriy Tseretyan
c59567a236
Alerting: support ok state in alert migration (#45264) 2022-02-10 21:57:43 +01:00
Artur Wierzbicki
0276b029fc
Previews: crawler as a background service (#44891)
* add SQL migrations

* dashboard previews from sql: poc

* added todos

* refactor: use the same enums where possible

* use useEffect, always return json

* added todo

* refactor + delete files after use

* refactor + fix manual thumbnail upload

* refactor: move all interactions with sqlStore to thumbnail repo

* refactor: remove file operations in thumb crawler/service

* refactor: fix dashboard_thumbs sql store

* refactor: extracted thumbnail fetching/updating to a hook

* refactor: store thumbnails in redux store

* refactor: store thumbnails in redux store

* refactor: private'd repo methods

* removed redux storage, saving images as blobs

* allow for configurable rendering timeouts

* added 1) query for dashboards with stale thumbnails, 2) command for marking thumbnails as stale

* use sql-based queue in crawler

* ui for marking thumbnails as stale

* replaced `stale` boolean prop with `state` enum

* introduce rendering session

* compilation errors

* fix crawler stop button

* rename thumbnail state frozen to locked

* #44449: fix merge conflicts

* #44449: remove thumb methods from `Store` interface

* #44449: clean filepath, defer file closing

* #44449: fix rendering.Theme cyclic import

* #44449: linting

* #44449: linting

* #44449: mutex'd crawlerStatus access

* #44449: added integration tests for `sqlstore.dashboard_thumbs`

* #44449: added comments to explain the `ThumbnailState` enum

* #44449: use os.ReadFile rather then os.Open

* #44449: always enable dashboardPreviews feature during integration tests

* #44449: remove sleep time, adjust number of threads

* #44449: review fix: add `orgId` to `DashboardThumbnailMeta`

* #44449: review fix: automatic parsing of thumbnailState

* #44449: lint fixes

* #44449: crawler as a background service v0.1

* #44449: use ServerLockService

* #44449: use ServerLockService

* #44449: review fix: prefer `WithDbSession` over `WithTransactionalDbSession`

* #44449: review fix: add a comment explaining source of the filepath

* #44449: review fix: added filepath validation

* #44449: fix FindDashboardsWithStaleThumbnails to include `theme` and `kind` in search params

* #44449: fix FindDashboardsWithStaleThumbnails to include `theme` and `kind` in search params

* #44449: create function for crawler on demand

* #44449: improve crawler logging

* #44449: fix wire

* #44449: uncomment dummy thumb service, fix ticker interval

* #44449: prevent race condition

* #44449: improve logging

* #44449: fix theme

* #44449: review fixes https://github.com/grafana/grafana/pull/45063/files @fzambia

* #44449: add missing unlock

* #44449: merge

* #44449: review fix - logger @fzambia https://github.com/grafana/grafana/pull/45063/files

* #44449: formatting

* #44449: merge conflict fix

* #44449: merge conflict fix

* #44449: merge conflict fix

* #44449: naming fix

* #44449: update authOpts

* #44449: change authOpts.role back to admin

* #44449: fix `walk` signature, move ctx to a first argument

* #44449: add `dashboardPreviewsScheduler` feature flag

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-02-10 22:45:00 +04:00
Karl Persson
d2b9da9dde
Access control: Support uids for resource permissions (#45226)
* add middleware to solve uid -> id for requests
2022-02-10 17:47:48 +01:00
Shirley
89a0c0fc37
Cloudwatch: Remove unused parameters (#45237)
* Remove unused parameters

* Remove unused context

* Make plugin context first parameter
2022-02-10 17:15:11 +01:00
Ieva
9fafbfc87e
add the permission to read org users to team creator (#45224) 2022-02-10 14:51:05 +00:00
Gábor Farkas
96ae44ee2c
loki: alerting: do not round timestamps to seconds (#45057) 2022-02-10 12:53:46 +01:00
Marcus Efraimsson
ca311bf94f
Logging: Fix server hangs when using log.WithSuffix (#45213)
Fixes a problem where server hangs if setting 
GF_DATABASE_LOG_QUERIES=true.

Ref #44925
2022-02-10 12:51:51 +01:00
idafurjes
923b62ecab
Chore: Remove bus from quota (#45143)
* Remove bus from quota

* workaround

* Change ExpectedOrg ot *models.Org
2022-02-10 12:42:06 +01:00
Shirley
5edcc2e795
Cloudwatch: Use generic null-insertion mechanism (#43507)
* Cloudwatch: Fix nil values for a period gap in metrics

* Use fields periods for intervals
2022-02-10 10:17:45 +01:00
ying-jeanne
5ded070aab
dashdiff bus removal (#45175) 2022-02-10 16:58:52 +08:00
Marcus Efraimsson
2082eeb72f
Logging: Fix so that filters can contain commented lines (#45159)
Fixes log filters that contains comments should not be enabled
2022-02-10 09:52:37 +01:00
idafurjes
88cf2da12e
Remove bus from sqlstore (#45199) 2022-02-10 09:21:41 +01:00
Kat Yang
7abd372e68
Chore: Remove bus from commands service (#45177) 2022-02-09 16:17:21 -05:00
Joey Tawadrous
10232c7857
InfluxDB: backend migration (run query in explore) (#43352)
* InfluxDB backend migration

* Multiple queries and more

* Added types

* Updated preferredVisualisationType

* Updated model parser test to include limit,slimit,orderByTime

* Added test for building query with limit, slimit

* Added test for building query with limit, slimit, orderByTime and puts them in the correct order

* Add test: Influxdb response parser should parse two responses with different refIDs

* Moved methods to responds parser

* Add test to ensure ExecutedQueryString is populated

* Move functions out of response parser class

* Test for getSelectedParams

* Merge cases

* Change to const

* Test get table columns correctly

* Removed unecessary fields

* Test get table rows correctly

* Removed getSeries function

* Added test for preferredVisualisationType

* Added test for executedQueryString

* Modified response parser

* Removed test

* Improvements

* Tests

* Review changes

* Feature flag rename and code gen
2022-02-09 18:26:16 +00:00
Gabriel MABILLE
78fc0258b1
AccessControl: Implement SQL filters for team members filtering (#44898)
* AccessControl: Filter team members

* Modify GetTeamMembersByUser comment

* Fix postgres failing test due to quoting

* Rename GetTeamMembersByUser to GetUserTeamMemberships

* Update TeamStore interface
2022-02-09 17:46:37 +01:00
Will Browne
3fbe4801b7
Plugins: Update collect metrics handler to latest signature (#45166)
* use updated collect metrics handler

* use proto helper
2022-02-09 17:36:53 +01:00
ying-jeanne
78eb06ec02
remove bus from login (#44995)
* remove bus from login

* remove comments and format correctly

* remove the downcast
2022-02-09 17:17:09 +01:00
Gabriel MABILLE
01b88adb3a
AccessControl: SQL filters for team search (#44557)
* AccessControl: SQL filters for team search

Set test config

* Remove userIdFilter when FGAC is on
2022-02-09 16:17:31 +01:00
idafurjes
df282a42cb
Remove bus from datasource api (#44987)
* Remove bus from datasource api

* Add DatasourcePermissionService and use it in api

* Fix wire and rename

* Fix import in wire

* Fix bug

* Rename Service to OSS service

* Roll back fix
2022-02-09 14:01:32 +01:00
Dimitris Sotirakis
605d056136
Security: Sync security changes on main (#45083)
* * Teams: Appropriately apply user id filter in /api/teams/:id and /api/teams/search
* Teams: Ensure that users searching for teams are only able see teams they have access to
* Teams: Require teamGuardian admin privileges to list team members
* Teams: Prevent org viewers from administering teams
* Teams: Add org_id condition to team count query
* Teams: clarify permission requirements in teams api docs
* Teams: expand scenarios for team search tests
* Teams: mock teamGuardian in tests

Co-authored-by: Dan Cech <dcech@grafana.com>

* remove duplicate WHERE statement

* Fix for CVE-2022-21702

(cherry picked from commit 202d7c190082c094bc1dc13f7fe9464746c37f9e)

* Lint and test fixes

(cherry picked from commit 3e6b67d5504abf4a1d7b8d621f04d062c048e981)

* check content type properly

(cherry picked from commit 70b4458892bf2f776302720c10d24c9ff34edd98)

* basic csrf origin check

(cherry picked from commit 3adaa5ff39832364f6390881fb5b42ad47df92e1)

* compare origin to host

(cherry picked from commit 5443892699e8ed42836bb2b9a44744ff3e970f42)

* simplify url parsing

(cherry picked from commit b2ffbc9513fed75468628370a48b929d30af2b1d)

* check csrf for GET requests, only compare origin

(cherry picked from commit 8b81dc12d8f8a1f07852809c5b4d44f0f0b1d709)

* parse content type properly

(cherry picked from commit 16f76f4902e6f2188bea9606c68b551af186bdc0)

* mentioned get in the comment

(cherry picked from commit a7e61811ef8ae558ce721e2e3fed04ce7a5a5345)

* add content-type: application/json to test HTTP requests

* fix pluginproxy test

* Fix linter when comparing errors

Co-authored-by: Kevin Minehart <kmineh0151@gmail.com>
Co-authored-by: Dan Cech <dcech@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
Co-authored-by: Vardan Torosyan <vardants@gmail.com>
2022-02-09 13:44:38 +01:00
maicon
8e03541228
Provisioning: Ensure that the default value for orgID is set when provisioning datasources to be deleted (#44244)
Fixes #44243

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2022-02-09 12:38:13 +01:00
ying-jeanne
ef11e783f1
ldap debug bus removal (#45014)
* ldap debug bus removal

* linter
2022-02-09 11:45:31 +01:00
Jean-Philippe Quéméner
4fef791c7c
Alerting: enable e2e tests to run in production mode (#45073)
* Alerting: run e2e tests in production mode

* adapt expected messages

* switch expected and actual to have the right order
2022-02-09 10:26:06 +01:00
Artur Wierzbicki
a025109647
Dash previews: populate crawler queue from SQL query (#44083)
* add SQL migrations

* dashboard previews from sql: poc

* added todos

* refactor: use the same enums where possible

* use useEffect, always return json

* added todo

* refactor + delete files after use

* refactor + fix manual thumbnail upload

* refactor: move all interactions with sqlStore to thumbnail repo

* refactor: remove file operations in thumb crawler/service

* refactor: fix dashboard_thumbs sql store

* refactor: extracted thumbnail fetching/updating to a hook

* refactor: store thumbnails in redux store

* refactor: store thumbnails in redux store

* refactor: private'd repo methods

* removed redux storage, saving images as blobs

* allow for configurable rendering timeouts

* added 1) query for dashboards with stale thumbnails, 2) command for marking thumbnails as stale

* use sql-based queue in crawler

* ui for marking thumbnails as stale

* replaced `stale` boolean prop with `state` enum

* introduce rendering session

* compilation errors

* fix crawler stop button

* rename thumbnail state frozen to locked

* #44449: fix merge conflicts

* #44449: remove thumb methods from `Store` interface

* #44449: clean filepath, defer file closing

* #44449: fix rendering.Theme cyclic import

* #44449: linting

* #44449: linting

* #44449: mutex'd crawlerStatus access

* #44449: added integration tests for `sqlstore.dashboard_thumbs`

* #44449: added comments to explain the `ThumbnailState` enum

* #44449: use os.ReadFile rather then os.Open

* #44449: always enable dashboardPreviews feature during integration tests

* #44449: remove sleep time, adjust number of threads

* #44449: review fix: add `orgId` to `DashboardThumbnailMeta`

* #44449: review fix: automatic parsing of thumbnailState

* #44449: lint fixes

* #44449: review fix: prefer `WithDbSession` over `WithTransactionalDbSession`

* #44449: review fix: add a comment explaining source of the filepath

* #44449: review fix: added filepath validation

* #44449: review fixes https://github.com/grafana/grafana/pull/45063/files @fzambia

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-02-09 13:23:32 +04:00
George Robinson
4e3a72fc2a
Add context.Context to AlertingStore (#45069) 2022-02-09 09:22:09 +00:00
sam boyer
6a2255abe7
pkg/web: X-Forwarded-For multi-IP handling (#45098)
It is conventionally common for the X-Forwarded-For header to contain a
comma-separated list of IP addresses, with each intermediate proxy
adding an additional item as a request passes through it. This change
makes the web framework handle this case appropriately, always selecting
the first item in the list.
2022-02-08 14:37:19 -05:00
J Guerreiro
2cf421dfe3
ServiceAccounts: Add access control metadata to service accounts (#45096)
* add role to DTO

* add access control metadata
2022-02-08 19:19:22 +00:00
ying-jeanne
38f93d675b
dashboard snapshot bus removal (#44956) 2022-02-08 17:57:59 +01:00
Ieva
4f4b1cb5ea
Access control: hide team role picker if user doesn't have access to it (#45068)
* hide team role column

* hide or disable the role picker as needed

* add SWL filtering for role listing
2022-02-08 16:38:13 +00:00
Yuriy Tseretyan
ea236c276e
add missing option to swagger spec (#45070) 2022-02-08 10:09:37 -05:00
Yuriy Tseretyan
6a7a486c6f
Reuse opened session in the context (#44939) 2022-02-08 09:02:23 -05:00
George Robinson
67a3e1d6fd
Add context.Context to InstanceStore (#45049) 2022-02-08 13:49:04 +00:00
Will Browne
fc42dfe396
Auth: Guarantee consistency of signed SigV4 headers (#45054)
* use latest sigv4 changes

* update configuration docs

* lint

* reformat lint ignore

* specific version for docs
2022-02-08 14:48:17 +01:00
Eric Leijonmarck
79340c087f
Add number of tokens to the service accounts view (#44919)
* feat: add serviceaccountDTO

* WIP

* feat: listing number of tokens for a given service account

* nit: removed fmt

* Update pkg/services/serviceaccounts/database/database.go

* Update public/app/features/serviceaccounts/ServiceAccountsListPage.tsx

* fixes

* align DTOProfile data to the frontend

* reviewed myself fixes

* fix: tests fix
2022-02-08 14:31:34 +01:00
Eric Leijonmarck
e04169de1a
fix: scoping for service accoutns (#44993)
* fix: scoping for service accoutns

* fix: scoping for service accoutns

* Update pkg/services/serviceaccounts/api/api.go

Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>

Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
2022-02-08 12:44:27 +00:00
Sofia Papagiannaki
35fe58de37
API: Extract OpenAPI specification from source code using go-swagger (#40528)
* API: Using go-swagger for extracting OpenAPI specification from source code

* Merge Grafana Alerting spec

* Include enterprise endpoints (if enabled)

* Serve SwaggerUI under feature flag

* Fix building dev docker images

* Configure swaggerUI

* Add missing json tags

Co-authored-by: Ying WANG <ying.wang@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-02-08 13:38:43 +01:00
Will Browne
88ea9aef8d
remove unused config (#45056) 2022-02-08 12:42:14 +01:00
J Guerreiro
8c49e96439
ServiceAccounts: Add token view for Service Accounts (#45013)
* fix SA creation scope

* add writer action to SA fixed role

* ServiceAccounts: Add token table to SA detail page

* ServiceAccounts: Allow deletion of tokens from token table

* refactor service account page

* avoid using store for delete
2022-02-08 11:35:15 +00:00
George Robinson
a9399ab3cd
Alerting: Add context.Context to RuleStore (#45004)
Alerting: Add context.Context to RuleStore
2022-02-08 08:52:03 +00:00
Karl Persson
01d961c824
update mock (#45010) 2022-02-07 18:44:56 +01:00
Karl Persson
922b9465ec
Access Control: Add function to set several permissions on a resource in one transaction (#44768) 2022-02-07 17:04:32 +01:00
Gabriel MABILLE
178193c84b
AccessControl: Use an SQLFilter struct (#44887) 2022-02-07 16:18:52 +01:00
Marcus Efraimsson
05ea825c76
Chore: Logging improvements (#44925)
Fixing a couple bugs, adds some tests and hopefully decrease 
lock contention when logging.
Switching from using sync.RWMutex to go-kit SwapLogger.
Fixes bug when creating a new logger from an existing one that 
screwed up the keyvals and/or lost the logger name. 

Ref #44681
2022-02-07 16:00:08 +01:00
J Guerreiro
94820e1f29
Add/Delete API keys to Service accounts (#44871)
* ServiceAccounts: move token handlers to specific file

* ServiceAccounts: move Add API key to Service account

* APIKeys: api keys can still be used even when service accounts are enabled

* APIKeys: legacy endpoint can't be used to add SA tokens

* ServiceAccount: add tests for creation with nil and non-nil service account ids

* ServiceAccounts: fix unnasigned cfg and AC typo

* Test: test service account token adding

* fix linting error

* ServiceAccounts: Handle Token deletion

* rename token funcs

* rename token funcs and api wrapping

* add token deletion tests

* review

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>

* remove bus

* Update pkg/api/apikey.go

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>
2022-02-07 14:51:54 +01:00
ying-jeanne
016fa77460
remove bus from loginservice (#44907) 2022-02-07 14:36:15 +01:00
ying-jeanne
69c764897e
remove dispatch from apikey (#44955) 2022-02-07 21:14:54 +08:00
Eric Leijonmarck
334c29eebf
feat: creation of service account (#44913)
* feat: creation of service account

* added back button for the details page

* refactor: remove unused file, renamed fields

* oppps
2022-02-07 14:12:39 +01:00
Gábor Farkas
d9d1f8520e
loki: backend-queries: set interval-value in dataframe (#44965)
* loki: backend-queries: set interval-value in dataframe

* fixed unit test

* added interval-specific unit test
2022-02-07 13:02:04 +01:00
idafurjes
caa5f356be
Remove bus from dashboard api (#44923)
* Remove bus from dashboard api

* Polish api dashboard tests

* Remove Delete Slug method

* Fix sqlstore dashboard test

* Remove bus from dashboard permission

* Remove GetDashboardsBySlug from sqlstore
2022-02-07 12:43:43 +01:00
Gábor Farkas
560c773905
loki: run some queries through the backend (#44729) 2022-02-07 08:43:48 +01:00
Alexander Weaver
935059a376
Alerting: Create basic storage layer for provisioning (#44679)
* Simplistic store API for provenance lookups on arbitrary types

* Add a few notes in comments

* Improved type safety for provisioned objects

* Clean-up TODOs for future PRs

* Clean up provisioning model

* Clean up tests

* Restrict allowable types in interface

* Fix linter error

* Move AlertRule domain methods to same file as AlertRule definition

* Update pkg/services/ngalert/models/provisioning.go

Co-authored-by: George Robinson <george.robinson@grafana.com>

* Complete interface rename

* Pass context through store API

* More idiomatic method names

* Better error description

* Improve code-docs

* Use ORM language instead of raw sql

* Add support for records in different orgs

* ResourceTypeID -> ResourceType since it's not an ID

Co-authored-by: George Robinson <george.robinson@grafana.com>
2022-02-04 13:23:19 -06:00
Kat Yang
7105bb3be7
Chore: Remove bus from admin users (#44869)
* Chore: Remove bus from admin users

* Mock authinfoservice

* Update user id

* attempt to fix the tests in admin users api

* fix type cast

* revert skipped tests

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
2022-02-04 13:45:42 -05:00
Yuriy Tseretyan
ddfe2dce74
Alerting: Split grafana and lotex routes (#44742)
* split Lotex and Grafana routes
* update template to use authorize function for every route
2022-02-04 12:42:04 -05:00
Will Browne
126ed461b1
remove grafana specific config from package (#44866) 2022-02-04 18:14:53 +01:00
Kat Yang
5c87044aa2
Chore: Remove bus from frontend settings (#44921) 2022-02-04 17:55:50 +01:00
Kat Yang
0e6300fb49
Chore: Remove bus from admin (#44920)
* Chore: Remove bus from admin

* fix test

Co-authored-by: Ying WANG <ying.wang@grafana.com>
2022-02-04 17:53:58 +01:00
Serge Zaitsev
9d654bb6b8
Chore: Remove bus from plugin proxy api (#44899)
* remove bus from plugin proxy api

* fixing the tests
2022-02-04 17:35:00 +01:00
idafurjes
7a23700e1a
Remove unused GetDashboard method (#44890)
* Remove unused GetDashboard method

* Uncomment test

* Fix dashboard service integration test

* Remove comment
2022-02-04 17:21:06 +01:00
Ivana Huckova
0f362f8dfc
Query history: Create API to delete query from query history (#44653)
* Query history: Add delete and refactor

* Update docs/sources/http_api/query_history.md

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
2022-02-04 16:14:36 +01:00
George Robinson
9df43abbb5
Fix evaluation of alert rules for datasources with custom headers (#44862)
* Fix evaluation of alert rules for datasources with custom headers

* Fix unit tests

* Fix integration tests

* Evaluator fields should be package private
2022-02-04 14:56:37 +01:00
Serge Zaitsev
61533a3cb4
Chore: Remove bus from health api (#44897)
* remove bus from health api

* fix health api tests

* use db health query as a method

* use pointer in sqlstore mock
2022-02-04 14:33:35 +01:00
Serge Zaitsev
058e3ffc21
Chore: Remove bus from Alerting API (#44894)
* assign handlers to httpserver

* turn sqlstore mock in to a pointer

* add search service interface

* fix tests for alerting and other apis

* once again, make linter happy
2022-02-04 13:41:15 +01:00
Jeremy Price
525d9d97a8
Fix crash on no service accounts (#44389)
* Fix crash on no service accounts

* Fix tests

* Update org_users.go

* Update org_users.go

* linter, again

* Update build.go

* Update pkg/services/serviceaccounts/tests/common.go

* fix: big D

Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
2022-02-04 11:06:30 +00:00
ying-jeanne
c5211f848d
remove bus from search service (#44825) 2022-02-03 18:46:38 +01:00
Selene
3ce0730558
AuthService: Move database logic to its own class and package (#44835)
* Move database logic to its own class and package

* Fix lint
2022-02-03 18:23:45 +01:00
Kat Yang
9b3cb4a306
Chore: Remove bus from index (#44851) 2022-02-03 18:22:21 +01:00
bolshoytoster
7f2d3055d8
Logging: Fix don't return an error trying to initialize the file logger (#42952)
Fixes #42897

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-02-03 18:17:25 +01:00
Gabriel MABILLE
8217d6d206
AccessControl: Change teams permissions page when accesscontrol is enabled (#43971)
* AccessControl: Change teams permissions page when frontend is hit

* Implement frontend changes for group sync

* Changing the org/teams/edit permissions

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

* Fixing routes

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

* Use props straight away no need to go through the state

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Update public/app/features/teams/TeamPages.tsx

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2022-02-03 17:49:39 +01:00
Sergey Kostrukov
85ea1a5d64
Prometheus: Fix Azure authentication support (#44407)
Re-adding back Azure authentication support to Prometheus datasource 
after the datasource query logic was rewritten from plugin.json routes to 
Go backend.

Ref #35857
2022-02-03 17:06:31 +01:00
Ieva
602d62ebcc
Access control: FGAC for team sync endpoints (#44673)
* add actions for team group sync

* extend the hook to allow specifying whether the user is external

* move user struct to type package

* interface for permission service to allow mocking it

* reuse existing permissions

* test fix

* refactor

* linting
2022-02-03 15:27:05 +00:00
Marcus Efraimsson
bc7e55d99b
Chore: Fix log filters (#44681) 2022-02-03 23:20:02 +08:00
Todd Treece
c8bb4c733e
Prometheus: Set interval on time field (#44802) 2022-02-03 08:15:55 -05:00
Serge Zaitsev
43b15b92ad
Chore: Remove bus from the alerting service (#44496)
* propagate notificationservice down to the notifiers

* replace dispatch in result handler

* remove dispatch from the rule reader

* remove dispatch from eval context

* remove dispatch from alerting usage

* remove dispatch from alerting usage

* remove dispatch from notifier

* attempt to fix tests in alerting

* hello linter, my old friend; also disable some tests for now

* use mocks to fix the tests

* resolving wire providers

* make linter happy

* remove yet another bus.dispatch

* fix tests using store mock
2022-02-03 13:26:05 +01:00
Alex Khomenko
a79c048344
Feature Highlights: move setting to a feature toggle (#44780)
* Add toggle

* Use the toggle

* Cleanup
2022-02-03 13:53:23 +02:00
Kat Yang
f582e6c86a
Chore: Remove bus from password (#44482)
* Chore: Remove bus from password

* Refactor: Remove bus from password.go and adjust tests

* remove sqlstore dependency from notifications

* Chore: Remove bus from password

* Refactor: Remove bus from password.go and adjust tests

* remove sqlstore dependency (again)

* remove fmt printf

* fix dependencies in http server

* fix renamed method in tests

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
2022-02-03 10:33:46 +01:00
Vardan Torosyan
f38f10416a
Revert fixed roles and service accounts (#44778)
* Revert fixed roles and service accounts

* Leave the fixed role for service accounts
2022-02-03 09:59:26 +01:00
idafurjes
1b286e6bb5
Remove bus from quota, preferences, plugins, user_token (#44762)
* Remove bus from quota, preferences, plugins, user_token

* Bind sqlstore.Store to *sqlstore.SQLStore

* Fix test

* Fix sqlstore wire injection, dependency
2022-02-03 09:20:20 +01:00
Joan López de la Franca Beltran
b2655750e8
Encryption: Add support for data keys re-encryption (#43548)
* Encryption: Add support for data keys re-encryption

* Add tests for data keys re-encryption

* Update code after refactorings

Co-authored-by: Leonard Gram <leo@xlson.com>
2022-02-03 09:15:38 +01:00
Joan López de la Franca Beltran
f8105efff3
Encryption: CLI rollback command (#43935)
* Encryption: CLI rollback command

* Update flag reference to 'featuremgmt' pkg

* Update feature toggles usage

* Clean up data keys table after envelope encryption rollback
2022-02-03 07:19:18 +01:00
Yuriy Tseretyan
984c95de63
Do not store EvaluationString in Evaluation. (#44606)
* do not store evaluation string in Evaluation.
* reduce number of buckets to store for a single state
2022-02-02 19:18:20 +01:00
Marcus Efraimsson
0092d10764
Instrumentation: Fix HTTP request instrumentation of authentication failures (#44234)
Moves the request tracing middleware earlier in the chain, just after the tracing middleware 
and before the log middleware. With these changes we'll be able to track 
authentication/authorization status failures that currently exits early and don't execute the 
request tracing middleware. In addition, there might be some other routes now being tracked 
with this that we didn't do before.

Fixes #39590
2022-02-02 18:48:46 +01:00
Eric Leijonmarck
1dd2579528
fix: remove migrated, and /org endpoint (#44788)
* fix: remove migrated, and /org endpoint

* Update pkg/api/index.go
2022-02-02 16:32:37 +01:00
Ieva
9247848a7b
increment fixed role version (#44779) 2022-02-02 15:24:16 +00:00
Kyle Brandt
040ce40113
SSE: Mode to drop NaN/Inf/Null in Reduction operations (#43583)
Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2022-02-02 14:50:44 +01:00
George Robinson
924deda589
Fix Discord Webhook URL for invalid template (#44763)
This commit fixes an issue where an invalid template for Discord would change the Webhook URL to "" and cause "unsupported protocol scheme" errors.
2022-02-02 14:28:41 +01:00
Joan López de la Franca Beltran
3b4e812449
Encryption: Keep legacy default provider id on providers map (#44721)
* Encryption: Keep legacy default provider id on providers map

* Minor fixes

* Refactor
2022-02-02 12:10:46 +01:00
Konrad Lalik
69e4796504
Alerting: Split legacy and unified routing configuration (#44641)
* Disable add alert menu entry for legacy alerting

* Split legacy and unified routing configuration

* Fix fallback routes configuration
2022-02-02 10:57:43 +01:00
Ryan McKinley
ac90c8d68d
Geomap: initialization fixes (#44745) 2022-02-01 22:08:07 -08:00
Santiago
04d93751b8
Alerting: send alerts to external, internal, or both alertmanagers (#40341)
* (WIP) send alerts to external, internal, or both alertmanagers

* Modify admin configuration endpoint, update swagger docs

* Integration test for admin config updated

* Code review changes

* Fix alertmanagers choice not changing bug, add unit test

* Add AlertmanagersChoice as enum in swagger, code review changes

* Fix API and tests errors

* Change enum from int to string, use 'SendAlertsTo' instead of 'AlertmanagerChoice' where necessary

* Fix tests to reflect last changes

* Keep senders running when alerts are handled just internally

* Check if any external AM has been discovered before sending alerts, update tests

* remove duplicate data from logs

* update comment

* represent alertmanagers choice as an int instead of a string

* default alertmanagers choice to all alertmanagers, test cases

* update definitions and generate spec
2022-02-01 20:36:55 -03:00
Ryan McKinley
7ee38af95a
FeatureToggls: remove IsFeatureToggleEnabled from SettingsProvider (#44574) 2022-02-01 10:24:59 -08:00
Gabriel MABILLE
f81b9c8150
AccessControl: Read team permissions from db (#44727) 2022-02-01 18:35:31 +01:00
Ryan McKinley
3749695594
TestData: support dropping points from random walk data and send interval (#44683) 2022-02-01 17:27:52 +01:00
Karl Persson
e93e1bdd2b
Access control: Enable data source view for partial permissions (#44695)
* Return correct value

* Remove scope all requirement

* Only add dashboard sub nav if user is admin
2022-02-01 15:00:05 +01:00
Gabriel MABILLE
bc24fdcf8d
AccessControl: Team membership migration (#44065)
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-02-01 14:57:26 +01:00
idafurjes
dca3dddafd
Add store interface (#44694)
* Add store interface

* Fix lint
2022-02-01 14:51:22 +01:00
Gábor Farkas
3873c5e7b5
loki: alerting: better error-handling (#44700) 2022-02-01 13:34:03 +01:00
Selene
875e0736ec
LDAP: Use an interface instead of a bus to get group teams (#42165)
* Remove bus for GetTeams for LDAP

* Fix lint
2022-02-01 12:03:21 +01:00
Ryan McKinley
6a72d97265
TestData: support raw results in the raw frames editor (#44609) 2022-01-31 15:40:58 -08:00
Isabella Siu
cbbf451b36
CloudWatch: small logs refactors (#44677) 2022-01-31 17:30:16 -05:00
Ivana Huckova
780591cc12
Prometheus: Fix some of the alerting queries that use reduce/math operation (#44380)
* Prometheus: Dont fill response with nulls for alerting queries

* Refactor based on reviews
2022-01-31 18:14:30 +01:00
George Robinson
5e2280ceee
Add metrics to ngalert scheduler (#44602)
This pull request adds metrics to the ngalert scheduler so we can see how long it takes to evaluate a tick.
2022-01-31 16:56:43 +00:00
idafurjes
12420260ef
Remove bus from org invite api (#44530)
* Remove bus from org invite api

* Fix lint

* Remove comment
2022-01-31 17:24:52 +01:00
Santiago
7ed82ac049
Check for empty URLs when creating/updating a data source (#42837)
* checks for empty URLs added

* check for TimeSeriesTypeNot to fix InfluxDB alerts

* log a warning when a data frame is ignored

* fix: add brittle Prometheus URL input selector

needs a proper aria-label or test-data-id selector

* test: add URL input aria-label

needs to use the grafana/e2e-selectors package

* test: run ci

* add URL validation for specific data sources, e2e tests

* Update pkg/api/datasource/validation.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* delete duplicated logs

* delete unnecessary leading newline

Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-01-31 12:39:55 -03:00
Karl Persson
5ca9d2895b
Add viewer grant to fixed:datasources:reader if viewers_can_edit is set to true (#44657) 2022-01-31 16:33:41 +01:00
Will Browne
76603b93d6
Plugins: Refactor Grafana and Plugin version update checkers (#44529)
* refactor

* rework plugin update checking

* make smarter

* simplify

* fix linter issue

* make use of mutex

* apply feedback to simplify

* format imports

* fix tests
2022-01-31 16:06:16 +01:00
Will Browne
bf8694e709
Plugins: Amend plugins loader log statements (#44652)
* adjust log statements

* Update pkg/plugins/manager/loader/loader.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* add errs to logs

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-01-31 14:24:51 +00:00
Karl Persson
16e62965f5
handle case when scope is wildcard (#44654) 2022-01-31 14:44:20 +01:00
Marcus Efraimsson
333de57999
Plugins: Fix scanning plugins when permission for directories is lacking (#44587)
Fixes so that errors (directory not exists, no permission) when scanning plugins are logged as 
errors rather than with debug level. In addition, before the scanning would halt in case of 
referenced errors, but with these changes the scanning will continue. If any other error 
than the referenced error happens the scanning for specific directory would halt and return 
the error, e.g. stop Grafana from starting.

Fixes #43012
2022-01-31 14:07:10 +01:00
Josh Hunt
c6ce629fd8
I18n: Translate navigation items (#44131)
* I18n: Translate navigation items

* improve comment, remove console.log

* update mock macros

* Mark up all phrases for translation

* added deprecate text comment, moved translations to a seperate file

* use TestProvider in NavBarItem

* use TestProvider in nav tests

* remove text deprecation comment

* update translations
2022-01-31 03:41:58 +01:00
Artur Wierzbicki
254c59725e
Rendering: add capabilities check (#44470)
* #44449: add feature check to rendering service

* #44449: formatting

* #44449: rename feature -> capability (https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities, https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities)

* #44449: refactor

* #44449: remove commented code

* Update pkg/services/rendering/capabilities.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* #44449: review fixes

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2022-01-28 21:24:15 +04:00
Ivana Huckova
4e37a53a1c
Query history: Create API to add query to query history (#44479)
* Create config to enable/disable query history

* Create add to query history functionality

* Add documentation

* Add test

* Refactor

* Add test

* Fix built errors and linting errors

* Refactor

* Remove old tests

* Refactor, adjust based on feedback, add new test

* Update default value
2022-01-28 17:55:09 +01:00
Tania B
ca24b95b49
Encryption: Handle encryption key provider being a background service (#44007)
* Encryption: Handle encryption key provider being a background service

* Sort imports

* Cleanup accidental changes

* Add proper error handling

* Apply review feedback
2022-01-28 17:17:40 +02:00
Karl Persson
e844b263c7
Access control: Load permissions from memory and database (#42080)
* Load permission from both in memory and from database
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-01-28 16:11:18 +01:00
Marcus Efraimsson
919c451156
Chore: Remove unused sqlstore dependency (#44583)
Removes unused sqlstore dependency from plugin management.

Ref #44260
2022-01-28 06:38:19 -05:00
J Guerreiro
312dd9e315
AccessControl: Add AC to team preferences (#44554)
* AccessControl: Add AC to team preferences

* Apply suggestions from code review

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

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-01-28 12:17:54 +01:00
J Guerreiro
2894f07f05
AccessControl: improve denied message (#44551)
* AccessControl: improve denied message

* AccessControl: tweak permission denied
2022-01-28 12:17:24 +01:00
Marcus Efraimsson
94edd7a762
Plugins: Refactor plugin dashboards (#44315)
Moves/refactor Grafana specific functionality related to plugin dashboards 
out to specific services for importing dashboards and keep app plugin dashboards
up-to-date.

Fixes #44257
2022-01-28 10:28:33 +01:00
Gábor Farkas
6e071d030f
loki: added benchmark for metric-response processing (#44539) 2022-01-28 09:44:57 +01:00
Alex Vandiver
844b194f5b
Middleware: Don't require HTTPS for HSTS headers to be emitted (#35147)
Grafana itself may not be serving content over HTTPS, but it may be
behind a transparent proxy which does.

Fixes #26770.  Based on #26868.
2022-01-28 07:23:28 +01:00
Marcus Efraimsson
a23900c4ba
CodeQL: Ignore go/log-injection for terminal logger (#44481) 2022-01-27 19:01:59 +01:00
Will Browne
b5dd4842d0
Plugins: Make manager more easily composable (#44467)
* make more easily composable

* fix build
2022-01-27 18:06:38 +01:00
Todd Treece
4d1f3a3f6c
Recorded Queries: Enable by default (#44397) 2022-01-27 11:09:39 -05:00
J Guerreiro
153b231521
AccessControl: Refine interface for AC store (#44536)
* AccessControl: Refine interface for AC store

* Update pkg/services/accesscontrol/database/resource_permissions.go
2022-01-27 16:47:24 +01:00
J Guerreiro
cb6e5ae8ce
AccessControl: Add access control actions and scopes to team update and delete
* AccessControl: Add access control actions and scopes to team update and delete

* AccessControl: Add tests for AC guards in update/delete

* AccessControl: add fixed role for team writer

* AccessControl: ensure team related AC is deleted with team

* Update pkg/api/team_test.go
2022-01-27 16:16:44 +01:00