Commit Graph

3712 Commits

Author SHA1 Message Date
Joan López de la Franca Beltran
e43879e55d
Encryption: Add support for multiple data keys per day (#47765)
* Add database migrations

* Use short uids as data key ids

* Add support for manual data key rotation

* Fix duplicated mutex unlocks

* Fix migration

* Manage current data keys per name

* Adjust key re-encryption and test

* Modify rename column migration for MySQL compatibility

* Refactor secrets manager and data keys cache

* Multiple o11y adjustments

* Fix stats query

* Apply suggestions from code review

Co-authored-by: Tania <yalyna.ts@gmail.com>

* Fix linter

* Docs: Rotate data encryption keys API endpoint

Co-authored-by: Tania <yalyna.ts@gmail.com>
2022-05-23 13:13:55 +02:00
Joe Blubaugh
1cc034d960
Alerting: Add a "Reason" to Alert Instances to show underlying cause of state. (#49259)
This change adds a field to state.State and models.AlertInstance
that indicate the "Reason" that an instance has its current state. This
helps us account for cases where the state is "Normal" but the
underlying evaluation returned "NoData" or "Error", for example.

Fixes #42606

Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
2022-05-23 16:49:49 +08:00
Joe Blubaugh
26a206cce2
Alerting: Attach image URL to alerts in Webhook notifier format. (#49378)
Attaches an imageURL field to any alert messages that have a screenshot
token whose URL we can successfully read from disk.
2022-05-23 16:44:19 +08:00
Joe Blubaugh
11a908cc91
Alerting: Add Screenshot URLs to Pagerduty Notifier (#49377)
PagerDuty takes an "images" array of link objects in it's request body.
2022-05-23 16:40:58 +08:00
Joe Blubaugh
12c25759da
Alerting: Attach screenshot data to Slack notifications. (#49374)
This change extracts screenshot data from alert messages via a private annotation `__alertScreenshotToken__` and attaches a URL to a Slack message or uploads the data to an image upload endpoint if needed.

This change also implements a few foundational functions for use in other notifiers.
2022-05-23 14:24:20 +08:00
Joe Blubaugh
1d724810de
Alerting: State Manager takes screenshots. (#49338)
The State Manager will now take screenshots when an alert instance
switches to an Alerting or Resolved state.

Signed-off-by: Joe Blubaugh joe.blubaugh@grafana.com
2022-05-23 10:53:41 +08:00
Joe Blubaugh
687e79538b
Alerting: Add a general screenshot service and alerting-specific image service. (#49293)
This commit adds a pkg/services/screenshot package for taking and uploading screenshots of Grafana dashboards. It supports taking screenshots of both dashboards and individual panels within a dashboard, using the rendering service.

The screenshot package has the following services, most of which can be composed:

BrowserScreenshotService (Takes screenshots with headless Chrome)
CachableScreenshotService (Caches screenshots taken with another service such as BrowserScreenshotService)
NoopScreenshotService (A no-op screenshot service for tests)
SingleFlightScreenshotService (Prevents duplicate screenshots when taking screenshots of the same dashboard or panel in parallel)
ScreenshotUnavailableService (A screenshot service that returns ErrScreenshotsUnavailable)
UploadingScreenshotService (A screenshot service that uploads taken screenshots)

The screenshot package does not support wire dependency injection yet. ngalert constructs its own version of the service. See https://github.com/grafana/grafana/issues/49296

This PR also adds an ImageScreenshotService to ngAlert. This is used to take screenshots with a screenshotservice and then store their location reference for use by alert instances and notifiers.
2022-05-22 22:33:49 +08:00
sam boyer
a3402641d6
api: Validate dashboards on save via coremodels, behind feature toggle (#48252)
* Add coremodelValidation feature flag

* coremodels: use stubs when feature flag is off

* api: validate dashboards on save

* Need pointer receiver for FeatureManager

* Update dashboard Go model

* Align doc comments

* Include CoremodelRegistry in test

* Wedge coremodel in on all test cases, ugh

* Ugh fix comment again

* Update pkg/framework/coremodel/staticregistry/provide.go

Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>

* Update Thema (and its deps) for better errs

* omg whitespace

Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>
2022-05-22 02:44:12 +02:00
Artur Wierzbicki
03fe1435a0
Storage: store uploaded files in SQL rather than on the disk (#49034)
* #48259: set up storages per org id

* #48259: migrate to storage_sql
2022-05-21 16:55:11 -07:00
Gábor Farkas
313d203a87
loki: enable by default backend mode (#49326) 2022-05-21 17:01:57 +02:00
sh0rez
3d5d8c785b
pkg/web: restrict handler types (#48495)
Makes `pkg/web` only accept handles from the following set:

```go
	handlerStd       = func(http.ResponseWriter, *http.Request)
	handlerStdCtx    = func(http.ResponseWriter, *http.Request, *web.Context)
	handlerStdReqCtx = func(http.ResponseWriter, *http.Request, *models.ReqContext)
	handlerReqCtx    = func(*models.ReqContext)
	handlerReqCtxRes = func(*models.ReqContext) Response
	handlerCtx       = func(*web.Context)
```

This is a first step to reducing above set to only `http.Handler`.

---

Due to a cyclic import situation between `pkg/models` and `pkg/web`, parts of this PR were put into `pkg/api/response`, even though they definitely do not belong there. This however is _temporary_ until we untangle `models.ReqContext`.
2022-05-20 12:45:18 -04:00
Joan López de la Franca Beltran
15605b6c80
Encryption: Add support for decrypting ciphertexts with algorithm metadata (#49312) 2022-05-20 17:11:51 +02:00
Yuriy Tseretyan
258b3ab18b
Alerting: Fix RBAC actions for notification policies (#49185)
* squash actions "alert.notifications:update", "alert.notifications:create", "alert.notifications:delete" to "alert.notifications:write"
* add migration
* update UI to use the write action
* update docs
* changelog
2022-05-20 10:55:07 -04:00
Karl Persson
f5ec4bcbd2
remove action to manage plugin that is not used or documented (#49309) 2022-05-20 11:52:29 +02:00
Karl Persson
4a61f4111f
Remove unused error from evaluator Evaluate (#49305) 2022-05-20 10:26:57 +02:00
Alexander Weaver
e8b498fe8b
Parse template when validating it (#49282) 2022-05-19 16:05:34 -05:00
Ryan McKinley
26e98a6f1b
Search: add query to extender interface (#49281) 2022-05-19 20:30:13 +02:00
Todd Treece
f0f33733a5
Search: Add DashboardIndexExtender interface (#49045)
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-05-19 12:46:18 -04:00
Alexander Emelin
444c585c99
Search: limit max size of batches during indexing (#49187) 2022-05-19 18:57:26 +03:00
Ryan McKinley
8a87db2743
Search: use ngram filter rather than prefix query (#49130) 2022-05-19 08:23:31 -07:00
Kristin Laemmert
33359aee6c
backend/sqlstore: move GetDashboards to Dashboard Service (#49175)
I also did some mild file renaming to try and get the dashboards package closer in line with the sqlstore split design doc.
2022-05-19 10:59:12 -04:00
Kristin Laemmert
2b8909a9c6
move GetDashboardUIDById out of sqlstore and into dashboard service (#49170)
* sqlstore: move GetDashboardUIDById to dashboard service
* winding change through the rest of the codebase
2022-05-19 10:13:02 -04:00
Yuriy Tseretyan
f7f2253072
Alerting: Fix anonymous access to alerting (#49203)
* introduce a fallback handler that checks that role is Viewer.
* update UI nav links to allow alerting tabs for anonymous user
* update rule api to check for Viewer role instead of SignedIn when RBAC is disabled
2022-05-19 09:22:26 -04:00
ying-jeanne
e2ea064584
integrat star service into APIs (#49220) 2022-05-19 14:32:10 +02:00
Jguer
86962dc9bd
Login: Fix mismatching label on auth_module in user list (#49177)
* Login: Fix mismatching label on user auth_module

* Login: ensure previous auth was set to differing

* Login: ensure only one entry of auth is updated

* compare both entries

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

* remove noop

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-05-19 12:03:04 +02:00
Gabriel MABILLE
5b6d20fbce
Access Control: Remove built-in role assignment by default (#49058)
* Remove FF-bultins

* Add a param to test br-simplifying
2022-05-19 09:29:36 +02:00
Yuriy Tseretyan
d87fdc1037
Alerting: Update migration to migrate only alerts that belong to existing org\dashboard (#49192)
* Update migration to migrate only alerts that belong to existing org\dashboard
2022-05-18 16:00:08 -04:00
Alexander Weaver
25da759bf2
Indicate whether templates are provisioned (#49025) 2022-05-18 13:52:30 -05:00
Matthew Jacobson
5c32a6b6f6
Alerting: Fix flaky migration test (#48595)
* Fix flaky migration test
2022-05-18 13:23:13 -04:00
Josh Hunt
71e1305364
LibraryPanels: Fix library panels not connecting properly in imported dashboards (#49161)
* Use saved dashboard model to create library panel connections when importing

* Rename variables in dashboard import for clarity
2022-05-18 16:50:24 +02:00
Kristin Laemmert
8169dcd9a2
remove unused GetDashboardSlugById function (#49116) 2022-05-18 14:17:17 +02:00
George Robinson
43358c7248
Alerting: Keep private annotations across evaluations (#49080) 2022-05-18 11:21:18 +02:00
Gilles De Mey
1d18b5ccd3
Alerting: inject dashboardService in to AlertNG (#49139) 2022-05-18 11:04:17 +02:00
Karl Persson
5c4ebb6f34
fetch permissions by uid (#49100) 2022-05-18 09:13:41 +02:00
Ryan McKinley
9bbe951ec6
Usage: add gauge for panel/datasource/transformer types (#48991) 2022-05-18 00:25:28 +02:00
Jeff Levin
c7f8c2cc73
add isPublic to dashboard (#48012)
adds toggle to make a dashboard public

* config struct for public dashboard config
* api endpoints for public dashboard configuration
* ui for toggling public dashboard on and off
* load public dashboard config on share modal

Co-authored-by: Owen Smallwood <owen.smallwood@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-05-17 14:11:55 -08:00
Kristin Laemmert
1df340ff28
backend/services: Move GetDashboard from sqlstore to dashboard service (#48971)
* rename folder to match package name
* backend/sqlstore: move GetDashboard into DashboardService

This is a stepping-stone commit which copies the GetDashboard function - which lets us remove the sqlstore from the interfaces in dashboards - without changing any other callers.
* checkpoint: moving GetDashboard calls into dashboard service
* finish refactoring api tests for dashboardService.GetDashboard
2022-05-17 14:52:22 -04:00
Alexander Weaver
9af30f6570
Alerting: Provisioning GET routes for mute timings (#49044)
* Define GET routes and run codegen

* Wire up forked and non-generated API

* Implement and wire

* Tests, authorization

* Fix linter error
2022-05-17 13:42:48 -05:00
Karl Persson
34be8f28b9
AccessControl: Add metadata to search result (#48879)
* Add access control metadata to search hits if access control query string is passed
2022-05-17 15:51:44 +02:00
Gabriel MABILLE
7cb7290a3e
AccessControl: Enforce user check when enterprise accesscontrol is on (#49003)
* AccessControl: Enforce user check when enterprise accesscontrol is on

* Update the test not to fail enterprise build

* Adding a log as suggested by Kalle

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

* Update log message

Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
2022-05-17 09:47:31 -04:00
Sofia Papagiannaki
925784f514
Alerting: Modify endpoint for testing a datasource rule using the UID (#48070)
* Modify testing endpoint to expect the datasource UID

* Update docs
2022-05-17 14:10:20 +03:00
Selene
43e34f3086
Dashboards: Allow to retrieve dashboards by uid (#48522)
* Add the possibility to get the dashboards by uid

* Fix
2022-05-17 09:37:44 +02:00
Artur Wierzbicki
7a05941ea0
Previews: improve logging, add time measurements to the crawler (#49043)
* #44449: log times taken for various things in previews service / crawler

* #44449: remove stale log
2022-05-16 18:09:46 -07:00
Alexander Emelin
baa50c58d0
Search: use only bluge-based search (#48968) 2022-05-16 16:22:45 -07:00
Jeff Levin
2691872c7a
remove validatedQueries feature toggle (#48381)
* remove validatedQueries feature toggle
2022-05-16 13:17:05 -08:00
Yuriy Tseretyan
952cb4fc0b
Alerting: introduce AlertRuleGroupKey and use it in API handlers (#48945)
* create AlertGroupKey structure
* update PrometheusSrv.
  - extract creation of RuleGroup to a separate method. Use group key for grouping
* update RuleSrv 
 - update calculateChanges to use groupKey
 - authorize to use groupkey
2022-05-16 15:45:45 -04:00
Artur Wierzbicki
5c321599c8
Storage: enable SQL backend (#48095)
* #45498: add String util to ListResponse for better UX

* #45498: refactor db_filestorage FS API backend - use path_hash in DB schema

* #45498: enable DB backend fs api tests

* #45498: add comment

* #45498: enable Storage feature flag during integration tests

* remove fmt.println

* #45498: reduce sizes of hash columns

* separate conditions

* #45498: make it easy to ignore backends when running fs api integration tests

* #45498: quote `key` column name

* #45498: reduce path_hash size

* #45498: verify `/{orgId}/{storageName}/` prefix convention in integration tests

* #45498: add etag to the sql table

* #45498: add etag to the sql table

* remove feature flag check (storage isn't dev-mode only)

* add cacheControl and content disposition

* add comments

* add path_hash comment

* explicitly set `path` column collation in `file` table for postgres
2022-05-16 10:26:40 -07:00
ying-jeanne
2d4065600c
star sqlstore split (#45851)
* start for stars split

* some updates
2022-05-16 22:42:02 +08:00
Ieva
f256f625d8
AccessControl: Enable RBAC by default (#48813)
* Add RBAC section to settings

* Default to RBAC enabled settings to true

* Update tests to respect RBAC

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2022-05-16 12:45:41 +02:00
Todd Treece
87e8521591
Prometheus: Implement Streaming JSON Parser (#48477)
use `prometheusStreamingJSONParser` feature toggle to enable
2022-05-13 20:28:54 +02:00
Yuriy Tseretyan
e528f2e430
Alerting: Use UID scope for folders authorization (#48970) 2022-05-13 18:05:25 +02:00
Yuriy Tseretyan
00ef1acb93
Alerting: Create folder for alerting when start from the scratch (#48866)
* create folderHelper struct
2022-05-13 11:49:04 -04:00
Karl Persson
60bc3e4e5c
AccessControl: Let users with data source create permissions list non-core plugins (#48897)
* Only require create and permissions for new data source page

* Let users with permissions to create data sources list non-core plugins

* Keep the admin check as fallback when using rbac as well
2022-05-13 10:30:26 +02:00
Eric Leijonmarck
555867135b
Access control: Using RBAC to filter users in list view that you have read access to (#47963)
* Add SQL filter for global user search

* Remove scope requirements from endpoints

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2022-05-13 09:26:34 +02:00
Karl Persson
1c679e814b
AccessControl: Only return action and scope for user permissions and make them unique (#48939)
* Only return action and scope for user permissions and make them unique
2022-05-12 17:15:18 +02:00
Yuriy Tseretyan
186ba26b59
Alerting: refactor rule API to create rule group in a single place (#48915)
* extract method toGettableRuleGroupConfig
2022-05-12 10:42:31 -04:00
Yuriy Tseretyan
369fcc5e9a
Alerting: scheduler to use short version of model for alert rule (#48916)
* scheduler to use a short version of alert rule model
2022-05-12 09:55:05 -04:00
Karl Persson
58fa119270
sort user permissions by scope (#48928) 2022-05-12 11:46:56 +02:00
Gabriel MABILLE
d31d300ce1
Accesscontrol: Rename scope permissions:delegate (#48898) 2022-05-11 17:22:43 +02:00
Yuriy Tseretyan
99156b40bd
Alerting: Move alertRuleRegistry to its own file (#48890)
* move alertRuleRegistry to its own file
* move tests to separate file
2022-05-11 10:04:50 -04:00
Yuriy Tseretyan
dc33e09b24
simplify getting a slice of keys (#48889) 2022-05-11 09:44:31 -04:00
Karl Persson
61772a66b6
AccessControl: Create own interface and impl for each permission service (#48871)
* Create own interfaces for team, folder, dashboard and data source permissions services
* Remove service container and inject them individually
2022-05-10 15:48:47 +02:00
George Robinson
897db011eb
Add error options for rendering to return errors on failure (#48864) 2022-05-09 19:11:24 +01:00
Ieva
6923b4c6c6
Dashboard: Fix dashboard update permission check (#48746)
* Change dash permission check for dashboards that are moved to a different folder
2022-05-09 12:01:03 +02:00
Ryan McKinley
d6d358ef26
Search: create bluge based index (#48606) 2022-05-09 01:00:09 -07:00
Alexander Weaver
99eaa0fc20
Put identifier in path (#48831) 2022-05-06 16:06:30 -05:00
Alexander Weaver
809aa38103
POST routes to PUT routes (#48828) 2022-05-06 14:33:30 -05:00
Sofia Papagiannaki
bb66c03f9a
Alerting: modify prometheus endpoints for proxying using the datasource UID (#48052)
* Modify prometheus endpoints to expect the data source UID

* Update frontend
2022-05-06 15:05:02 -04:00
Jean-Philippe Quéméner
30d9cc81ec
Alerting: check provenance of alert rules in current API (#48694) 2022-05-06 20:55:27 +02:00
Emil Tullstedt
51ff2b8c58
Logging: Unify logging fakes (#48822) 2022-05-06 17:44:22 +02:00
Krzysztof Dąbrowski
5be23b40b6
LDAP: allow Grafana Admin mapping without org_role field (#37189) 2022-05-06 12:12:42 +02:00
Will Browne
f135a5c8a4
Plugins: Refactor plugin resource call with and without data source (#48754)
* refactor plugin resource call with/without ds

* check err

* fix imports

* only validate req on ds path

* Update warn log

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

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-05-06 10:58:02 +02:00
Ieva
3c78196d0b
fix a bug (#48782) 2022-05-06 09:36:11 +01:00
Karl Persson
817cf52744
Access control: Allow users with permission to update team, dashboard and folder permissions to list users in OSS (#48275)
* Remove banner when missing permissions to list users

* For OSS allow users to list other users if they have permissions to
write either team, dashboard or folder permissions
2022-05-06 10:31:53 +02:00
Joan López de la Franca Beltran
9826a694a8
Encryption: Add Prometheus metrics (#48603) 2022-05-06 10:21:55 +02:00
Connor Lindsey
c1b5ea3e54
Tracing: Add trace to metrics config behind feature toggle (#46298)
* Add trace to metrics behind feature flag
2022-05-05 14:46:18 -06:00
Alexander Weaver
0f56462fbe
Alerting: Provisioning message templates (#48665)
* Generate API for writing templates

* Persist templates app logic layer

* Validate templates

* Extract logic, make set and delete methods

* Drop post route for templates

* Fix response details, wire up remainder of API

* Authorize routes

* Mirror some existing tests on new APIs

* Generate mock for prov store

* Wire up prov store mock, add tests using it

* Cover cases for both storage paths

* Add happy path tests and fix bugs if file contains no template section

* Normalize template content with define statement

* Tests for deletion

* Fix linter error

* Move provenance field to DTO

* empty commit

* ID to name

* Fix in auth too
2022-05-05 15:21:42 -05:00
Ieva
a5672758d8
Access control: further reduce access control feature toggle checks (#48171)
* reduce the usage of access control flag further by removing it from SQL store methods

* fixing tests

* fix another test

* linting

* remove AC feature toggle use from API keys

* remove unneeded function
2022-05-05 17:31:14 +02:00
Sofia Papagiannaki
610247d52a
Alerting: modify ruler endpoints for proxying using the datasource UID (#48046)
* Modify ruler endpoints to expect the data source UID

* Update frontend

* Apply suggestion from code review
2022-05-05 14:58:32 +03:00
ying-jeanne
0d14c27eb9
Chore: add Folderuid into panel-library API (#48577)
* add folderuid into interface

* panellibrary id/uid things

* modify doc

* update doc

* correct some comments
2022-05-05 10:04:54 +02:00
gotjosh
7313310080
Alerting: Fix & Cut the changelog (#48714) 2022-05-04 16:05:48 +01:00
Karl Persson
2738d1c557
Access Control: Move dashboard actions and create scope provider (#48618)
* Move dashboard actions and create scope provider
2022-05-04 16:12:09 +02:00
Adam Simpson
b2644de6c8
AzureMonitor: add feature toggle azureMonitorExperimentalUI for migrating to experimental UI (#48658)
* feat: add feature toggle azureMonitorExperimentalUI

Add QueryHeader which adds an experimental header to AzureMonitor. This work is documented in #44432.
2022-05-04 13:54:09 +00:00
Yuriy Tseretyan
f85e758972
unhide alert rule's data sources during migraiton (#48559) 2022-05-04 09:31:05 -04:00
Krzysztof Dąbrowski
c41397a6e7
LDAP: validate organization role during parsing (#37188)
* LDAP: validate organization role during parsing

* Trigger a new build

* Check if grafana_admin is present
2022-05-04 09:35:10 +02:00
Jeff Levin
38fc0c68e4
Update documentation to explicitly state we should not be putting migrations behind feature flags (#48663) 2022-05-03 15:10:59 -08:00
Jeff Levin
b88644cb83
public dashboards: add public dashboard table (#48470)
* add public dashboard table migration
2022-05-03 15:08:40 -08:00
Will Browne
4ecd57f49c
Plugins: Introduce HTTP 207 Multi Status response to api/ds/query (#48550)
* feature toggles

* return HTTP 207 from ds/query

* add ft check

* add API test

* add 207 check for qr

* change to OR

* revert check

* add explicit toggle check for cloudwatch

* remove unused import

* remove from defaults.ini

* add status codes to md and update swagger

* new fangled http api tests pattern

* update swagger

* Update docs/sources/http_api/data_source.md

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

* add missing word and reformat

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2022-05-03 18:02:20 +02:00
Ivana Huckova
4661c9ca47
Query history: Cleanup (#48303)
* Query history: Clean up stale history after 14 days

* Add unstarring sleanup

* Add wraapping

* Update sql for mysql database

* Update

* Remove fmt.Print

* Refactor and simplify solution

* Update pkg/services/queryhistory/database.go

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Adjust SQL to limit number of deleted queries

* Add limit enforcmenet to cleanup

* Change limit

* Update

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-05-03 14:49:58 +02:00
Jguer
6a303bb6b8
AccessControl: Rename builtin role roles to basic roles (#48519)
* AccessControl: Rename grafana:builtins roles to basic

* AccessControl: rename macro references to basic

Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-05-03 13:59:16 +02:00
Andreas Gerstmayr
21034e31de
chore: remove executable permissions of source files and docs (#46303) 2022-05-03 12:08:14 +02:00
Artur Wierzbicki
de75dd6aad
Search: remove dev-mode from the feature flag 2022-05-02 23:01:29 +04:00
Ryan McKinley
a8f3b17262
SaveDashboard: remove feature flag for save drawer (#48462) 2022-05-02 09:29:22 -07:00
Guilherme Caulada
2533f21015
DataSource: Fix secure json data reset on datasource update (#48557)
* Fix secure json data reset on datasource update

* Update fillWithSecureJSONData to use DecryptedValues

* Remove unecessary conversion

* Move fillWithSecureJsonData logic to datasource service

* Add sanity check for nil secure json data
2022-05-02 11:29:13 -03:00
ying-jeanne
bde368be55
Chore : Replace dashboardid with dashboardUID in annotation API (#48481)
* replace dashboardid with dashboardUID in annotation API

* add some tests

* modify some docs and add uid into get endpoint

* rebase with main

* add map for avoiding too much retrieve on dashboards
2022-05-02 11:35:36 +02:00
Jean-Philippe Quéméner
0a87ef06af
Alerting: add safeguard for migrations that might cause dataloss (#48526)
* Alerting: add safeguard for migrations that might cause dataloss

* add test for panic

* add documentation
2022-05-02 10:38:42 +02:00
Jack Westbrook
39ee365b82
Swagger: Add integrity attributes (#48396) 2022-05-02 09:49:49 +02:00
Karl Persson
de50f39c12
Access Control: Refactor scope resolvers with support to resolve into several scopes (#48202)
* Refactor Scope resolver to support resolving into several scopes

* Change permission evaluator to match at least one of passed scopes
2022-05-02 09:29:30 +02:00
Karl Persson
9622e7457e
Fix permission query for postgres (#48543) 2022-05-02 09:25:23 +02:00
Alexander Emelin
87ae3e0644
Search: handle a couple of corner cases when parsing dashboard data (#48521) 2022-04-29 08:49:38 -07:00
Gabriel MABILLE
2cc276567d
AccessControl: Hide basic roles (#48549)
Co-authored-by: Jguer <joao.guerreiro@grafana.com>

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-29 17:35:41 +02:00
Karl Persson
6c6137f45a
Access control: Pass access control metadata for api keys (#48445)
* Move ApiKeyDTO to dtos package

* Add access control filter to api keys

* pass user in GetApiKeysQuery

* Add api key metadata to DTO

* Remove scope all requirement from get api keys endpoint

* Handle api key access control metadata in frondend
2022-04-29 15:30:24 +02:00
ying-jeanne
1667a7c0da
Chore: Modify patch and update of preference to take homedashboarduid than h… (#48281)
* modify patch and update of preference to take homedashboarduid than homedashboardid

* to be tested

* use getdashboard

* update doc
2022-04-29 14:37:33 +02:00
Jean-Philippe Quéméner
9e3a01a1be
Alerting: skip flaky test (#48500) 2022-04-29 12:32:30 +02:00
Shirley
7bb4f5cd9b
CloudWatch: Add dynamic labels feature toggle (#48498) 2022-04-29 11:43:04 +02:00
Karl Persson
c207ea30eb
Access Control: Remove unused option (#48317)
* Remove unused option
2022-04-29 11:05:51 +02:00
Ivana Huckova
b92fe0e0f5
Query history: Add from and to parameters (#48212)
* Query history: Add from and to parameters

* 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>

* Update docs/sources/http_api/query_history.md

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

* Implement Grafana relative time range

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-04-29 09:55:33 +02:00
Sofia Papagiannaki
3e752a0db1
Alerting: modify alertmanager endpoints for proxying using the datasource UID (#47978)
* Alerting: enable proxying alertmanager calls using the datasource UID

* Remove use of datasource ID from the API

* Update frontend
2022-04-29 10:25:22 +03:00
Jean-Philippe Quéméner
9e21e4d1c1
Alerting: indicate whether an alertrule is provisioned (#48458) 2022-04-28 21:27:34 +02:00
Santiago
d9de621d20
Fix Discord notifications not being sent due to templating issues (#48208)
* empty URLs fixed

* move comment

* test cases
2022-04-28 15:58:07 -03:00
Alexander Weaver
735822e48a
Alerting: Add provisioning GET routes for message templates (#48367)
* Template service

* Add GET routes and implement them

* Generate mock for persist layer

* Unit tests for reading templates

* Set up composition root and get integration tests working

* Fix prealloc issue

* Extract setup boilerplate

* Update AuthorizationTest

* Rebase and resolve

* Fix linter error
2022-04-28 13:51:57 -05:00
Artur Wierzbicki
d4616cfe26
Search: support auth filter based on access control/rbac (#48350)
* #45498: add rbac support in searchv2

* to revert: fix dependency cycle

* Revert "to revert: fix dependency cycle"

This reverts commit 1ffbee73ec.

* added a TODO for caching user permissions

* add orgId to `getDashboardReadFilter`

* use orgId from signedInUser

* goimport
2022-04-28 22:16:23 +04:00
Alexander Emelin
4551f05994
Search: fix missing dashboards due to empty uid, log errors (#48361) 2022-04-28 19:29:09 +03:00
gotjosh
d451d02628
Alerting Changelog: Cut & Fix (#48402) 2022-04-28 11:20:35 +01:00
Artur Wierzbicki
736be74128
Chore: Add Usage stats providers registry (#48357)
* add usage stats providers

* migrate thumbnails service to `registry.ProvidesUsageStats`

* snake -> camel

* lint fix

* migrate accesscontrol to `registry.ProvidesUsageStats`

* add accesscontrol to usage stats providers registry

* fix test

* added a note about errors
2022-04-28 13:06:49 +04:00
Karl Persson
e9a93ebfc9
Access Control: Move access control middlewares to domain package (#48322)
* Move access control middleware to domain package
2022-04-28 10:46:18 +02:00
Alexander Weaver
60ec10566f
Extract Route validation from serialization methods so it can be re-used (#47649)
* Extract validation and reject invalid policies

* Validation in dedicated file

* Tests for validation

* Extract root route validation

* Update call and drop TODO

* empty commit to kick actions

* Normalization should be idempotent

* Cleaner representation of validation errors, chain errors properly

* Make internal validate unexported

* Fix missed rename

* Genericize error message

* Improve method names

* Rebase, fix

* Update asserts
2022-04-27 15:15:41 -05:00
An
900d9bf9a1
FileStorage: Add upload form (#46749)
* move upload to http

* use storage from grafanads

* rever gomod changes

* fix test

* wip

* add upload func

* update upload func

* writing to uploads

* edit response from service

* use dropzone for UI

* modify response struct in service

* better read file

* set content type for svg

* restrict file types upload

* add test and clean up errors

* pass test

* fix backend lint errors

* limit type of files on FE

* add TODO for after merge

* rebase with storage changes

* comment out unused function

* update UI to not have 2 uploads

* only call upload on select

* use utils function to find * in path

* show preview on drag over

* not allowing upload of svg

* add preview to upload tab

* no console.log

* resolve conflicts

* refactor log line

* fix failing BE test

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Artur Wierzbicki <artur.wierzbicki@grafana.com>
2022-04-27 15:12:48 -04:00
Yuriy Tseretyan
4b417c8f3e
use NaN if condition value is nil (#48370) 2022-04-27 15:59:13 -03:00
Jean-Philippe Quéméner
a3256bafa7
Alerting: indicate whether contact point is provisioned (#48323) 2022-04-27 20:53:36 +02:00
cianooooo
e8f4b58a8b
Alerting: Add additional customisation to ngalert MS Teams notifier (#46372)
Makes the Title and Section Title of the Teams message customisable.
Closes #46366
2022-04-27 13:03:15 -04:00
Artur Wierzbicki
25e153e4e7
Search: in-memory index (#47709)
* #45498: add entity events table

* #45498: add entity events service

* #45498: hook up entity events service to http server

* #45498: use `dashboards.id` rather than `uid` and `org_id` in grn

* Update pkg/services/entityevents/service.go

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

* #45498: move entityeventsservice to services/store

* #45498: add null check

* #45498: rename

* #45498: fix comment

* #45498: switch grn back to uid

* Search: listen for updates (#47719)

* #45498: wire entity event service with searchv2

* load last event id before building index for org 1

* fix service init in integration tests

* depend on required subset of event store methods

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

Co-authored-by: Alexander Emelin <frvzmb@gmail.com>

* #45498: pointer receiver

* #45498: mockery!

* #45498: add entity events service to background services

* dashboard query pagination, allow queries while re-indexing

* log level cleanups, use rlock, add comments

* fix lint, check feature toggle in search v2 service

* use unix time for event created column

* add missing changes for created column

* fix integration tests init

* log re-index execution times on info level

* #45498: fix entityEventsService tests

* #45498: save events on dashboard delete

* use camel case for log labels

* formatting

* #45498: rename grn to entityid

* #45498: add `IsDisabled` to entityEventsService

* #45498: remove feature flag from migration

* better context usage, fix capacity, comments/cleanups

* replace print with logger

* Revert "#45498: remove feature flag from migration"

This reverts commit ed23968898.

* revert:revert:revert conditional feature flag

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-04-27 12:29:39 +04:00
Joe Blubaugh
103087a1a5
Unified Alerting: Validate PostableSilence API. (#46892)
Invalid PostableSilences could be passed to the Alerting API - if they
are passed all the way down into the alertmanager data layer, they can
cause a panic. This change adds validation to avoid a panic in the
alertmanager.
2022-04-27 15:55:47 +08:00
Alexander Weaver
078a578803
Drop ProvenanceOrgAdapter and build into store API instead (#48137) 2022-04-26 10:30:57 -05:00
Matthew Jacobson
0301d956da
Alerting: Create fewer contact points on migration (#47291)
* Alerting: Create fewer contact points on migration

Previously a new contact point was created for every unique combination
of channels attached to any legacy alert. This was very hard to maintain,
requiring modifications in every generated contact point.

This change deduplicates the generated contact points to a more
reasonable state. There should now only be one contact point per legacy
channel, and we attached multiple contact points to a route by nesting
them. The sole exception to this is if there were multiple default
legacy channels, in which case we create a redundant contact point
containing all of them used only in the root policy. This allows for a
much simpler notification policy structure.

Co-authored-by: gotjosh <josue.abreu@gmail.com>
2022-04-26 16:17:30 +02:00
kay delaney
3b4d237ade
Notifications: Hide display of trace ID behind feature flag (#48057)
* Notifications: Hide display of trace ID behind feature flag
2022-04-26 14:31:27 +01:00
Ashley Harrison
e420252d45
move saved items feature behind separate feature toggle (#48117) 2022-04-26 11:27:01 +01:00
Emil Tullstedt
fc0346fe5b
Dashboards: Use home dashboard from org again (#48244)
* Dashboards: Use home dashboard from org again

* Set homeDashboardID

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-04-26 11:46:26 +02:00
Ryan McKinley
e0aeb83786
Export: introduce export plumbing (behind dev feature flag) (#48091) 2022-04-25 16:59:18 -07:00
Guilherme Caulada
53e9bf47db
Secrets: Implement tests and debug log improvements on unified secrets (#48213)
* Add test for decrypted values on datasource service

* Add debug log when fail to parse secure json fields

* Fix minor import issue

* Refactor encJson to json and simplejson to sjson on tests
2022-04-25 15:12:44 -03:00
Kat Yang
098563179b
Chore: Remove final x from sqlstore (#48086)
* Chore: Remove final x from everywhere

* Fix errors

* Fix: fix lint and nil pointer err

* Remove x from the sqlstore 🎉
2022-04-25 13:07:11 -04:00
Guilherme Caulada
a367ad730c
Secrets: Implement basic unified secret store service (#45804)
* wip: Implement kvstore for secrets

* wip: Refactor kvstore for secrets

* wip: Add format key function to secrets kvstore sql

* wip: Add migration for secrets kvstore

* Remove unused Key field from secrets kvstore

* Remove secret values from debug logs

* Integrate unified secrets with datasources

* Fix minor issues and tests for kvstore

* Create test service helper for secret store

* Remove encryption tests from datasources

* Move secret operations after datasources

* Fix datasource proxy tests

* Fix legacy data tests

* Add Name to all delete data source commands

* Implement decryption cache on sql secret store

* Fix minor issue with cache and tests

* Use secret type on secret store datasource operations

* Add comments to make create and update clear

* Rename itemFound variable to isFound

* Improve secret deletion and cache management

* Add base64 encoding to sql secret store

* Move secret retrieval to decrypted values function

* Refactor decrypt secure json data functions

* Fix expr tests

* Fix datasource tests

* Fix plugin proxy tests

* Fix query tests

* Fix metrics api tests

* Remove unused fake secrets service from query tests

* Add rename function to secret store

* Add check for error renaming secret

* Remove bus from tests to fix merge conflicts

* Add background secrets migration to datasources

* Get datasource secure json fields from secrets

* Move migration to secret store

* Revert "Move migration to secret store"

This reverts commit 7c3f872072.

* Add secret service to datasource service on tests

* Fix datasource tests

* Remove merge conflict on wire

* Add ctx to data source http transport on prometheus stats collector

* Add ctx to data source http transport on stats collector test
2022-04-25 13:57:45 -03:00
gotjosh
25c07ff85e
Alerting: Wrap legacy alerting metrics with legacy_ (#48190)
* Alerting: Wrap legacy alerting metrics with `legacy_`
2022-04-25 17:19:36 +02:00
George Robinson
c5547123bc
Remove redundant queries in GetAlertRules and GetOrgAlertRules and replace with ListAlertRules (#48108) 2022-04-25 11:42:42 +01:00
Ieva
68ca5b2e05
Access control: refactor RBAC checks (#48107)
* refactor RBAC checks

* fix a test

* another test fix

* and another
2022-04-25 10:42:09 +02:00
Artur Wierzbicki
2e599643f6
Previews: refactor (#47728)
* #44449: return standard thumb service even if auth setup fails

* #44449: remove dashboardPreviewsScheduler feature flag

* #44449: externalize dashboardPreviews config

* #44449: disable previews by default

* #44449: rename logger

* #44449: dashboardPreviewsAdmin feature requires dev mode

* #44449: retrigger CII
2022-04-25 01:55:10 +04:00
Torkel Ödegaard
70a7b73839
Preferences: Fixes broken preferences after recent merge (#48157)
* Preferences: Fixes broken preferences after recent merge

* Added check

* Shorter syntax

* Fixed test

* Remove error, and remove duplicate call
2022-04-24 17:50:10 +02:00
Yuriy Tseretyan
75ba4e98c6
Alerting: Remove unused features from ticker + metric + tests (#47828)
* remove not used code:
  - remove offset in ticket because it is not used
  - remove unused ticker and scheduler methods

* use duration for interval
* add metrics grafana_alerting_ticker_last_consumed_tick_timestamp_seconds, grafana_alerting_ticker_next_tick_timestamp_seconds, grafana_alerting_ticker_interval_seconds
2022-04-22 15:09:47 -04:00
Alexander Weaver
8310789ef1
Indicate whether routes are provisioned when GETting Alertmanager configuration (#47857)
* Test composition simplification from last PR

* Policies use proper API model everywhere

* Expose policy provenance in API, miss some dep injection

* Complete injection

* fix args

* Tests for provenance value

* Extract test helpers so tests are very readable

* Single source adapter struct that was copied in 3 places

* Drop redundant test

* Resolve merge conflicts on changelog
2022-04-22 11:57:56 -05:00
Gabriel MABILLE
94fd03f44f
LDAP: Fix debug view to display the actual computed mapping in ldap.go (#48103)
* LDAP debug fix with Org role inheritance

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

* ldap debug coherent with ldap.go

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

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-22 15:45:54 +02:00
Artur Wierzbicki
87dc1bfc88
Chore: enforce feature naming convention (#48053)
* enforce feature naming convention

* fix link

* add comment

* fix lint

* move the feature name check test to toggles_gen_test
2022-04-22 08:23:30 +04:00
Kristina
3e7db088ac
Command Palette Scaffolding + Explore (#47445)
* Add feature flag and scaffodling

* start adding actions

* WIP

* move action files

* Start adding styles

* Fix implementation based on feedback

* Add more hackathon code back to command palette

* Cleanup

* Cleanup unused service files for simple MVP pass

* Move type def to library

* WIP

* Move provider to proper place to pick up other routes’ actions

* Build actions off navbar, add explore actions

* Work around undefined typescript stuff

* Fix based on feedback

* close palette on ESC

* Fix based on PR feedback pt 1

* Move styles to classes

* Move another inline style to a class

* Enable command palette by default

* change around async hook structure

* Add simple feature tracking

* Code cleanup, and be sure the command is accurate

* Change to only render if there are actions, and only add actions once past login
2022-04-21 16:50:34 -05:00
Artur Wierzbicki
9f0b6a5754
Storage: refactor filtering, improve performance (#47403)
* Storage: refactor filtering, improve performance

* added a comment to `newpathfilter`

* after merge fixes
2022-04-21 23:27:43 +04:00
Yuriy Tseretyan
53a6c0210d
Alerting: tests for ticker (#47986) 2022-04-21 19:58:05 +01:00
Kat Yang
8e606dd751
Chore: Remove x from session (#48074) 2022-04-21 13:20:18 -04:00
George Robinson
d66fc6ed1a
Alerting: Add GetRuleGroups to RuleStore (#48036)
This commit adds a new method GetRuleGroups to RuleStore which returns the set of rule groups across all organizations.
2022-04-21 17:59:22 +01:00
idafurjes
dbcaedac6c
Implement preference service (#47870)
* Implement preference service

* Adjust wire.go

* Fix integration test user

* Fix api pref tests

* Fix a11y error

Co-authored-by: Alexandra Vargas <alexa1866@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-04-21 15:03:17 +02:00
Vardan Torosyan
a0553de8dd
Rename FGAC to RBAC in the codebase (#48051) 2022-04-21 14:31:02 +02:00
Kat Yang
eb05f6ead8
Chore: Remove x from dashboard snapshots (#48001) 2022-04-21 08:20:47 -04:00
Gabriel MABILLE
9ed7e48454
AccessControl: Modify provisioning to prevent built-in role assignment (#48031)
* Add basic and managed prefixes to avoid magic strings
For now let's stick with grafana_builtins
add function isBasic to RoleDTO
add function isBasic to Role

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

* Add team store to wire

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

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-21 14:14:45 +02:00