Commit Graph

4150 Commits

Author SHA1 Message Date
Alexander Weaver
b8d1474609
Fix incorrect propagation of org ID in rule endpionts (#54603) 2022-09-06 14:51:54 -05:00
Guilherme Caulada
20589f76f4
Secrets: Convert secret migration to a background service (#54676)
* Convert secret migration to a background service

* Fix merge conflicts

* Return concrete type for secret migration provider
2022-09-06 16:21:25 -03:00
Ilya Galimyanov
b593d371ef
Alerting: Telegram: truncate long messages (#54339)
Truncate messages longer than 4096 characters
2022-09-06 16:47:04 +01:00
George Robinson
77e53f9986
Alerting: Fix boolean comparison on PostgreSQL (#54730) 2022-09-06 08:28:42 +01:00
George Robinson
c4d32dd687
Fix nil logger in SqlStore (#54726) 2022-09-05 18:24:19 +01:00
Karl Persson
ff35e35ce0
RBAC: Move service and evaluator to acimpl package (#54714)
* RBAC: Move access control evaluator to acimpl package

* RBAC: Move service to acimpl package
2022-09-05 18:15:47 +02:00
Kevin Yu
34fe7a1119
Plugins: Add feature toggles for long running queries (#54349)
* Add feature toggles for long running queries

* update feature flag name

* make feature toggle frontend only
2022-09-05 08:39:45 -07:00
Ezequiel Victorero
bfa35ff8d8
PublicDashboards: Add RBAC to secured endpoints (#54544) 2022-09-05 12:22:39 -03:00
kay delaney
65c3ad6721
LibraryElements: Fix inability to delete library panels under MySQL (#54600)
Closes #53456
2022-09-05 14:28:32 +01:00
Carl Bergquist
78978048c3
Instrumentation: log the total number of db queries per request (#54647)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
2022-09-05 07:39:22 +02:00
linoman
d2bb72fb3c
Login: Remove single admin team restriction (#54534)
* Remove single member team restriction

* Add label when permissions list is empty

* Fix unit tests

* Add co-author.

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-09-02 18:16:39 +02:00
Guilherme Caulada
f4a35a4645
Secrets: Implement secrets manager plugin fallback store (#54496)
* Refactor fallback to be isolated to plugin secret store

* Check for error value on replace fallback test helper

* Move ResetPlugin from test_helpers.go to plugin.go

* Add check to GetUnwrappedStoreFromCache

* Add fallback GetAll query to WithFallbackEnabled

* Add mutex lock to WithFallbackEnabled

* Add cache to fallback store

* Fix linter issues

* Fix linter issues

* Fix linter issues
2022-09-02 12:39:18 -03:00
Ieva
de6584b976
Auth: Extend auth token errors with user ID (#54633)
* add user ID to user token errors

* remove colon

* move user ID to debug log, so it wouldn't accidentally be added in response
2022-09-02 14:38:25 +01:00
Will Browne
ecdcafb258
manager exposes renderer + secrets manager (#54629) 2022-09-02 14:20:10 +02:00
Joe Blubaugh
5e4fd94413
Alerting: Write and Delete multiple alert instances. (#54072)
Prior to this change, all alert instance writes and deletes happened
individually, in their own database transaction. This change batches up
writes or deletes for a given rule's evaluation loop into a single
transaction before applying it.

Before:
```
goos: darwin
goarch: arm64
pkg: github.com/grafana/grafana/pkg/services/ngalert/store
BenchmarkAlertInstanceOperations-8           398           2991381 ns/op         1133537 B/op      27703 allocs/op
--- BENCH: BenchmarkAlertInstanceOperations-8
    util.go:127: alert definition: {orgID: 1, UID: FovKXiRVzm} with title: "an alert definition FTvFXmRVkz" interval: 60 created
    util.go:127: alert definition: {orgID: 1, UID: foDFXmRVkm} with title: "an alert definition fovFXmRVkz" interval: 60 created
    util.go:127: alert definition: {orgID: 1, UID: VQvFuigVkm} with title: "an alert definition VwDKXmR4kz" interval: 60 created
PASS
ok      github.com/grafana/grafana/pkg/services/ngalert/store   1.619s
```

After:
```
goos: darwin
goarch: arm64
pkg: github.com/grafana/grafana/pkg/services/ngalert/store
BenchmarkAlertInstanceOperations-8          1440            816484 ns/op          352297 B/op       6529 allocs/op
--- BENCH: BenchmarkAlertInstanceOperations-8
    util.go:127: alert definition: {orgID: 1, UID: 302r_igVzm} with title: "an alert definition q0h9lmR4zz" interval: 60 created
    util.go:127: alert definition: {orgID: 1, UID: 71hrlmR4km} with title: "an alert definition nJ29_mR4zz" interval: 60 created
    util.go:127: alert definition: {orgID: 1, UID: Cahr_mR4zm} with title: "an alert definition ja2rlmg4zz" interval: 60 created
PASS
ok      github.com/grafana/grafana/pkg/services/ngalert/store   1.383s
```

So we cut time by about 75% and memory allocations by about 60% when
storing and deleting 100 instances.

This change also updates some of our tests so that they run successfully against postgreSQL - we were using random Int64s, but postgres integers, which our tables use, max out at 2^31-1
2022-09-02 11:17:20 +08:00
Michael Mandrus
39c31416a4
improve log in plugin check (#54599) 2022-09-01 13:47:37 -04:00
Timur Olzhabayev
b5b41988cf
Docs: Deprecating packages_api and removing it from our pipelines (#54473) 2022-09-01 18:15:44 +02:00
Serge Zaitsev
927ddf9376
Chore: Move login attempt methods to separate service (#54479)
* Chore: Move login attempt methods to separate service

* attempt to fix tests

* fix syntax

* better time mocking

* initialise now func
2022-09-01 18:08:42 +02:00
Karl Persson
be6b8d91eb
Correlations: Use correct fallback handlers (#54511)
* Correlations: Use correct fallback handlers

* Add signed in middleware to all routes
2022-09-01 12:29:44 +02:00
Kat Yang
58449d42ed
Chore: Add dashboard thumbnails service (#54500)
* Chore: Add dashboard thumbnails service

* Fix errors in dashboard thumbs impl

* Inject dashboardThumbsService into wire
2022-08-31 16:45:41 -04:00
owensmallwood
f4bbce15a0
Public Dashboards: Add Expressions Support (#54336)
Adds support for expressions with public dashboards
2022-08-31 09:11:10 -06:00
Yuriy Tseretyan
76ea0b15ae
Alerting: Scheduler to fetch folders along with rules (#52842)
* Update GetAlertRulesForScheduling to query for folders (if needed)
* Update scheduler's alertRulesRegistry to cache folder titles along with rules
* Update rule eval loop to take folder title from the
* Extract interface RuleStore 
* Pre-fetch the rule keys with the version to detect changes, and query the full table only if there are changes.
2022-08-31 11:08:19 -04:00
Kristina
38c1f3d054
Explore: Add Mixed Datasource (#53429)
* Toggle on the mixed mode option

* Ensure switching to mixed gives existing query prev datasource

* WIP - Populate datasource when switching between mixed and not

* WIP - handle change from mixed

* Remove preimport filter, refine filter to work for queries

* WIP debugging datasource transition

* Ensure creating a new query gets target data source if switching with no matches between

* Add mixed datasource to rich history display

* Cleanup console logs, add relevant comments

* Add feature toggle for mixed datasource

* Fix Wrapper tests

* Fix tests!

* Fix test types and add feature tracking

* Remove unnecessary default, remove explore/mixed workarounds for D2E

* Move display text logic to mixed datasource file

* Add in the default query parameters to a generated empty query

* Condense some code

* Apply suggestions from code review

Co-authored-by: Giordano Ricci <me@giordanoricci.com>

* Add more logic around mixed datasource being off for explore

* Build out logic to handle different datasource scenarios

* Add tests

* Finalize last test

* Fix mixed URL with mixed ds off, and relevant test

* Fix datasource to explore workflow

* Add datasource change function, call import queries if needed

* add logic for changing single query ds

Co-authored-by: Giordano Ricci <me@giordanoricci.com>
2022-08-31 09:24:20 -05:00
Dave Henderson
713075c494
Metrics: Fixed grafana_database_conn_* metrics, and added new go_sql_stats_* metrics as eventual replacement (#54405)
* metrics: Fix broken DBStats metrics

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

* Register the sqlstats metrics by default

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

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
2022-08-31 08:54:32 -04:00
Artur Wierzbicki
9284216880
Search: ordering tests (#54432)
* search ordering tests

* lintt
2022-08-30 18:58:19 +02:00
Will Browne
4a707e2a88
Plugins: Split plugin manager into smaller components (#54384)
* split out plugin manager

* remove whitespace

* fix tests

* split up tests

* updating naming conventions

* simplify manager

* tidy

* add more fakes

* testing time

* add query verif to int test

* renaming

* add process tests

* tidy up manager tests

* add extra case to int test

* add more coverage to store and process tests

* remove comment

* fix capatilization

* init on provide

* remove addfromsource from API
2022-08-30 17:30:43 +02:00
Artur Wierzbicki
7a340f486b
Storage: add WithContents option to storage.Get() (#53105)
* Storage: add `WithContents` option to `storage.Get()`

* fix tests

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2022-08-30 15:23:16 +02:00
Joan López de la Franca Beltran
6ec06f66b9
Rendering: Add support for renderer token (#54425)
(cherry picked from commit a4f75cc0438712c90b02d24740416f8615e3a0cb)
2022-08-30 12:09:38 +02:00
Ezequiel Victorero
722aca5c53
Public Dashboards: use intervalMs and maxDataPoints from request (#53613) 2022-08-29 18:13:06 -03:00
ying-jeanne
fe062f2eaa
Chore: Use db.DB interface instead of sqlstore (#54358)
* use db.DB interface instead of sqlstore

* make store service depends on db.DB instead of sqlstore
2022-08-26 19:07:58 -05:00
Jean-Philippe Quéméner
a932428057
Alerting: use raw query data in provisioning to bypass interpolation of macros (#54293) 2022-08-26 23:54:30 +02:00
Jean-Philippe Quéméner
49b1182f34
Alerting: add missing yaml tag to mute time struct (#54287) 2022-08-26 23:30:07 +02:00
Jeff Levin
5cb9fca990
public-dashboards: Add log statement when public dashboard enabled or disabled (#54133)
* refactor apis for consistent outputs
* add dashboardUid validation at API layer
* add check for empty dashboardUid on SavePublicDashboard
* remove public dashboard errors from models package.

Co-authored-by: Ezequiel Victorero <evictorero@gmail.com>
2022-08-26 11:28:54 -08:00
Karl Persson
9d2f5ef62f
RBAC: Add function to generate wildcards from prefix (#54275)
* RBAC: Move metadata to own file

* RBAC: Rename test files

* RBAC: Add wildcard structure and helper function to generate wildcards
from prefix

* RBAC: Refactor filter to use WildcardsFromPrefix

* RBAC: Refactor GetResourceMetadata to use WildcardsFromPrefix
2022-08-26 17:10:35 +02:00
ying-jeanne
6227528ea0
Chore: SQL Store Split of datasource (#54262)
* refectory datasource

* fix linter
2022-08-26 11:03:38 -04:00
Yuriy Tseretyan
db09a76125
update test environment to create folders (#54254) 2022-08-26 09:46:41 -04:00
Giordano Ricci
c68d7f1e35
Correlations: Add CorrelationSettings Page (#53821)
* GrafanaUI: add option to close DeleteButton on confirm click

* add datasource readOnly info to frontend settings

* move isTruthy utility type guard

* add generic non-visualization table component

* Add correlations settings page

* add missing readOnly in mock

* Fix typo

* avoid reloading correlations after add/remove

* use DeepPartial from rhf

* validate source data source

* fix validation logic

* fix navmodel test

* add missing readonly property

* remove unused styles

* handle multiple clicks on elements

* better UX for loading states

* fix remove handler

* add glue icon
2022-08-26 11:27:28 +01:00
Marcus Efraimsson
87afd9cadc
Plugins: Remove various custom headers logic (#54146)
Removes various custom headers logic sprinkled around in the backend. 
It should automatically be applied to outgoing HTTP requests via the 
CustomHeadersMiddleware.
This also removes decryption of SecureJSONData to populate custom 
headers in ngalert which seemed to have caused a ton of CPU usage.
2022-08-26 11:56:10 +02:00
Jeff Levin
681bdf1a2d
public-dashboards: refactor query method (#54119)
This PR refactors the GetPublicDashboard method so we don't need to make extra database calls. Also adds general documentation
2022-08-26 05:21:52 -04:00
Artur Wierzbicki
74158ed66b
Search: use SQL search as a fallback during bluge's initial indexing (#54095)
* Search: use SQL search as a fallback when bluge indexing is ongoing

* Search: lint

* Search: feedback fixes - return an empty frame with a special name

* Search: revert readiness check query type

* Search: remove println

* remove sleep, get coffee
2022-08-26 12:36:41 +04:00
Karl Persson
5a1b9d2283
RBAC: Remove DeclareFixedRoles wrapper on Access control and inject service (#54153)
* RBAC: Remove DeclareFixedRoles wrapper on Access control and inject service when needed
2022-08-26 09:59:34 +02:00
Guilherme Caulada
f25c7f6ddd
Chore: Refactor secrets kvstore to organize testing and migrations (#54249)
* Refactor migrations and tests for secrets kvstore

* Use fake secrets store as a shortcut on tests

* Update wire

* Use global migration logger

* Fix ds proxy tests

* Fix linting issues

* Rename data source test setup function
2022-08-25 18:04:44 -03:00
ying-jeanne
fd01161bcc
Chore: replace xorm by sqlx in dashboardversion service (#53869) 2022-08-25 16:04:16 -05:00
Michael Mandrus
8deababa50
Chore: Refactor secrets plugin unit tests code (#54231)
* refactor test setup to return struct rather than many values

* changes to code style from review

* apply diff from Leandro for logging
2022-08-25 15:15:58 -04:00
Yuriy Tseretyan
03e746d9df
Alerting: Delete state from the database on reset (#53919)
* make ResetStatesByRuleUID return states
* delete rule states when reset
* rule eval routine to clean up the state only when rule is deleted
2022-08-25 14:12:22 -04:00
Emil Tullstedt
0ffbf901d7
ContextHandler: Use stdlib format for middleware (#54219) 2022-08-25 14:35:21 +02:00
Karl Persson
552d3fec8d
RBAC: Fix resolver issue on wildcard resulting in wrong status code for endpoints (#54208)
* RBAC: Test evaluation before attaching mutator

* RBAC: Return error if no resolver is found for scope

* RBAC: Sync changes to evaluation in mock

* RBAC: Check for resolver not found error and just fail the evaluation in that case
2022-08-25 12:50:27 +02:00
Jeff Levin
6128cb60b4
cleanup unused fields (#54115)
This PR removes unused struct fields in SavePublicDashboardCommand
2022-08-24 21:29:01 -04:00
Michael Mandrus
277ea836b6
Secrets: Implement migration of secrets from plugin back to unified secrets (#53561)
* initial cut at migration from plugin

* create new migration from plugin

* only migrate to or from, not both

* remove cfg check from plugin migration itself

* update comments, clean up secret after migration

* add better error handling

* hook up REST API with migrations

* Minor fixes

* fix wire injection issue

* modify migrator to access plugin calls directly. create unit tests

* change pre-migration checks in admin api

* stop plugin after migrating from it

* fix compile issues after merge

* add comment about migration

* fix linting issue

* bleh, fix unit test

* fix another unit test

* update plugin error fatal flag after a migration from the plugin

* add extra logging to migration

* make linter happy

Co-authored-by: Leandro Deveikis <leandro.deveikis@gmail.com>
2022-08-24 16:24:50 -04:00
Yuriy Tseretyan
41bd36eb97
Alerting: Update rules delete endpoint to handle rules in group (#53790)
* update RouteDeleteAlertRules rules to update as a group
* remove expecter from scheduler mock to support variadic function
* create function to check for provisioning status + tests

Co-authored-by: Alexander Weaver <weaver.alex.d@gmail.com>
2022-08-24 15:33:33 -04:00