Commit Graph

7818 Commits

Author SHA1 Message Date
Serge Zaitsev
18e93c7077
Chore: Remove bus (#47511)
* Chore: Remove bus

* remove unused const
2022-04-08 16:15:06 +02:00
Serge Zaitsev
b31c7d3654
Chore: Remove bus from alerting rule (#47508)
* Chore: Remove bus from alerting rule

* fix alerting tests

* fix provide service
2022-04-08 14:30:25 +02:00
Serge Zaitsev
ad432108e6
Chore: Remove bus from dashboards provisioning (#47495)
* Chore: Remove bus from dashboards provisioning

* fix symlink test, make it run on darwin

* remove unused mock
2022-04-08 13:56:38 +02:00
Emil Tullstedt
3df625e9f4
UsageStats: Move stats collection to separate service (#47381)
* Remove specific stats from usage stats service

* Create statscollector service

* refactor

* Update and move tests

Mostly equivalent tests to before, but they've been divided over the two
services and removed the behavior driven legacy from GoConvey to
reduce the complexity of the tests.

* Collect featuremgmr metrics (copied over from #47407)

I removed the metrics registration from the feature manager in the merge
and re-add them in this commit. Separated to make things easier to
review.
2022-04-08 13:41:26 +02:00
Artur Wierzbicki
f1a1070d41
UsageStats: track enabled features (#47407)
* #47127: include enabled features in the usage stats reports

* #47127: convert feature names to snake cased metric names

* #47127: remove dead code

* #47127: lint fix

* #47127: convert GetUsageStats to return `map[string]interface{}`

* #47127: fix testssssssss

* #47127: fix testssssssss
2022-04-08 12:42:33 +02:00
Serge Zaitsev
2cf88cfec8
Chore: Remove bus from contexthandler (#47458)
* Chore: remove bus from contexthandler

* remove bus from orgredirect
2022-04-08 10:33:19 +02:00
Ivana Huckova
7ab910af48
Query history: Search in comments (#46761) 2022-04-08 09:35:34 +02:00
Joe Blubaugh
631dd718a2
47470: Add additional delay to silences in test. (#47482)
This test of silence cleanup was flaky because of its use of real wall
time. In CI environments with slow execution, delays could cause the
test to fail. This change mitigates the problem by increasing the end time of
silences in the test.

After Prometheus merges this PR: https://github.com/prometheus/alertmanager/pull/2867
we can make the test fully deterministic by using a fake clock.

Fixes #47470

Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
2022-04-08 14:52:08 +08:00
Jeff Levin
4a4d87dbdc
add public dashboards feature flag (#47364) 2022-04-07 10:30:19 -08:00
Alexander Weaver
c3ad36ba72
Temporarily skip intermittent test (#47471) 2022-04-07 12:52:00 -05:00
gotjosh
94f72acbb3
Alerting: Introduce an internal changelog (#47390)
* Alerting: Introduce an internal changelog

Please note that this is not intented to replace Grafana's "add to changelog" label. It is _mostly_ for internal consumption of the Alerting team that owns this part of Grafana.

* Fix markdown formatting

* Fix changelog entry
2022-04-07 15:24:26 +01:00
ying-jeanne
29b8d5d295
remove the parallele to avoid concurrency (#47447) 2022-04-07 15:45:03 +02:00
Josh Hunt
41642fd5f4
Modify the Server Error scenario to return frontend errors (#47157) 2022-04-07 10:59:49 +01:00
Giordano Ricci
ca286a238d
Explore: Add explore2Dashboard feature toggle (#47395) 2022-04-07 09:26:01 +01:00
Timur Olzhabayev
25235b3167
Removing plugin list panel (#46914)
The core plugin named plugin list panel is removed
2022-04-07 09:54:27 +02:00
Nathan Rodman
49505b9a3b
Alerting: fgac for notification policies and contact points (#46939)
* add FGAC actions for silences table

* redirect users without permissions

* add permissions checks to routes

* add fgac to notifications and contact points

* fgac for notification policies

* fix mute timing authorization

* use consistent naming for checking grafana alertmanager

* tests for fgac in contact points and notification policies

* bump up timeout on rule editor test

* use new permissions util

* break out route evaluation into util

* Remove test timeout

* Change permissions for the alert-notifiers endpoint

* Use signed in handler for alert-notifiers when unified alerting enabled

Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
2022-04-06 18:24:33 +02:00
Serge Zaitsev
d153d896c5
Chore: Remove bus from contexthandler (#47374)
* Chore: Remove bus from contexthandler

* fix tests

* try different wire binding

* maybe remove a few more dispatches

* fix tests
2022-04-06 16:31:26 +02:00
ying-jeanne
8ef5212b0e
add unit into request duration (#47356)
* add unit into request duration

* Update pkg/middleware/logger.go

Co-authored-by: Carl Bergquist <carl.bergquist@gmail.com>

Co-authored-by: Carl Bergquist <carl.bergquist@gmail.com>
2022-04-06 12:56:13 +02:00
Will Browne
aef5b29173
Plugins: Fix Default Nav URL for dashboard includes (#47143)
* Plugins: Fix Default Nav URL for dashboard includes

* update nav links

* PR comments
2022-04-06 10:50:39 +02:00
Will Browne
f3c1448b57
Analytics: Enable grafana and plugin update checks to be operated independently (#46352)
* add separate cfg for controlling plugin update checks

* https

* add specific version note to docs

* pr feedback

* fixup
2022-04-06 10:50:21 +02:00
Joan López de la Franca Beltran
2c2cf10405
Azure: Update Azure SDK dependencies (#46535)
* Azure: Update Azure SDK dependencies

* Add missing underscore imports for extensions
2022-04-06 10:19:04 +02:00
Gabriel MABILLE
f7305965a4
AccessControl: Remove package lists for roles and grants (#47141)
* AccessControl: Remove package variables for roles and grants

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

* Check for inheritance during role registration

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

* Moving back role definition to accessscontrol

* Make settings reader role public

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

* Nits

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

* Forgot to update this

* Account for declaration error

* Fixing pkg/api init ossac

* Account for error in tests

* Update test to verify inheritance

* Nits.

* Place br inheritance behind a feature toggle

* Parent -> Parents

* Nit.

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-06 09:31:14 +02:00
Serge Zaitsev
3a7fc80948
Chore: Remove last bus parts from login package (#47313)
* Chore: Remove last bus parts from login package

* fix middleware tests
2022-04-06 08:45:01 +02:00
Piotr Jamróz
8490fd77e3
Users: clean up OrgId when all user orgs are removed (#46003)
* Clean up orgId when user organization is removed

* Add a test for removing user org

* Fix linting errors

* Update comment

* Fix linting errors

* Make removing user org more explicit
2022-04-06 08:35:58 +02:00
Michael Mandrus
f9d86557cf
Dashboard: Mix initials and custom gravatars in recent viewers list (#47212)
* Use Wiring to initialize Avatar Cache Server

Create AvatarCacheServer Provider function and pass it in as an
argument to HTTPServer. Also convert CacheServer to a singleton
so that we keep all cached Avatar info in one place for easier access

* Refactor avatar cache server and add 'isCustom' check

Avatar cache server needs to perform two similar fetches
back-to-back; break up functions to allow for easy reuse.
Then add handling to see if a user has a custom avatar.

* Add additional accessors so that /recents api can easily use the cache

* Minor mods to avatar server to facilitiate unit testing

* add unit tests for avatar fetching

* add error handling in case we somehow fetch gravatars while they are disabled

* linting: read error return value in unit test

* Use http package status codes

Co-authored-by: Ezequiel Victorero <evictorero@gmail.com>

* Use http package status codes

Co-authored-by: Ezequiel Victorero <evictorero@gmail.com>

* Use http package status codes

Co-authored-by: Ezequiel Victorero <evictorero@gmail.com>

* Incorporate suggestions from PR
-avoid mutating arguments
-change error handler function to private and make name more descriptive

Co-authored-by: Ezequiel Victorero <evictorero@gmail.com>
2022-04-05 22:56:17 -04:00
Alexander Weaver
dde0b93cf1
Alerting: Provisioning API - Notification Policies (#46755)
* Base-line API for provisioning notification policies

* Wire API up, some simple tests

* Return provenance status through API

* Fix missing call

* Transactions

* Clarity in package dependencies

* Unify receivers in definitions

* Fix issue introduced by receiver change

* Drop unused internal test implementation

* FGAC hooks for provisioning routes

* Polish, swap names

* Asserting on number of exposed routes

* Don't bubble up updated object

* Integrate with new concurrency token feature in store

* Back out duplicated changes

* Remove redundant tests

* Regenerate and create unit tests for API layer

* Integration tests for auth

* Address linter errors

* Put route behind toggle

* Use alternative store API and fix feature toggle in tests

* Fixes, polish

* Fix whitespace

* Re-kick drone

* Rename services to provisioning
2022-04-05 16:48:51 -05:00
gotjosh
cb6124c921
Alerting: Accurately set value for prom-compatible APIs (#47216)
* Alerting: Accurately set value for prom-compatible APIs

Sets the value fields for the prometheus compatible API based on a combination of condition `refID` and the values extracted from the different frames.

* Fix an extra test

* Ensure a consitent ordering

* Address review comments

* address review comments
2022-04-05 19:36:42 +01:00
ying-jeanne
c525db9cd8
fallback to the v8 logging behavior (#47353) 2022-04-05 20:15:41 +02:00
Braden Snell
3fff301367
Plugins: Pass OAuth Token to CallResource Function (#47028)
* adds oauth support to call resource requests

* adds oauth docs for call resource

* fixes case where dsUID is empty

* improve datasource error handling
2022-04-05 17:40:34 +02:00
Josh Hunt
71db5115f4
User: Expose GCOM user ID as externalUserId in grafanaBootData (#47307)
* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* fix sql indtent

Co-authored-by: Joao Silva <joao.silva@grafana.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
2022-04-05 14:44:33 +01:00
Jguer
90a94eab74
Dashboard/Folder permission fix session (#47174)
* Fix inherited scopes for dashboard to use folder uid

* Add inherited evaluators

* Slight modification of the commments

* Add test for inheritance

* Nit.

* extract shared function from tests

* Nit. Extra line

* Remove unused comment

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-04-05 14:28:23 +02:00
Ezequiel Victorero
6a059dcb4d
Access Control: hiding add annotation button without permissions (#47223)
* Access Control: hiding add annotation button without permissions
2022-04-05 08:20:10 -03:00
Serge Zaitsev
bf9e0e8bc8
Chore: Remove some bus from login package (login attempts) (#47310) 2022-04-05 13:07:27 +02:00
Gábor Farkas
96987ac182
loki: add test to handle __name__ (#47298) 2022-04-05 11:56:54 +02:00
Gabriel MABILLE
e430f5021d
AccessControl: Alerting role grants folder read on all folders to viewers (#47278) 2022-04-05 07:04:02 +00:00
Ryan McKinley
110d4661d7
Converter: use streaming JSON parser to construct frames from loki/prometheus responses (#44520) 2022-04-04 17:22:14 -07:00
Serge Zaitsev
33006436cc
Chore: Remove bus.Dispatch from some login packages (#47248)
* Chore: Remove bus.Dispatch from some login packages

* remove debug log

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

* remove login.Init()

* remove unused reset function

* remove AuthenticateUserFunc global

* swap conditional branches

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

* fix formatting

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-04-04 20:36:15 +02:00
Konrad Lalik
6992d17924
Alerting: Add support to distinguish Prometheus datasource subtypes (Mimir, Cortex and Vanilla Prometheus) (#46771)
* Add basic UI for custom ruler URL

* Add build info fetching for alerting data sources

* Add keeping data sources build info in the store

* Use data source build info to construct data source urls

* Remove unused code

* Add custom ruler support in prometheus api calls

* Migrate actions

* Use thunk condition to prevent multiple data source buildinfo fetches

* Unify prom and ruler rules loading

* Upgrade RuleEditor tests

* Upgrade RuleList tests

* Upgrade PanelAlertTab tests

* Upgrade actions tests

* Build info refactoring

* Get rid of lotex ruler support action

* Add prom ruler availability checking when the buildinfo is not available

* Add rulerUrlBuilder tests

* Improve prometheus data source validation, small build info refactoring

* Change prefix based on Prometheus subtype

* Use the correct path

* Revert config routing

* Add deprecation notice for /api/prom prefix

* Add tests to the datasource subtype

* Remove custom ruler support

* Remove deprecation notice

* Prevent fetching ruler rules when ruler api is not available

* Add build info tests

* Unify naming of ruler methods

* Fix test

* Change buildinfo data source validation

* Use strings for subtype params and unveil mimir

* organise imports

* frontend changes and wordsmithing

* fix test suite

* add a nicer verbose message for prometheus datasources

* detect Mimir datasource

* fix test

* fix buildinfo test for Mimir

* shrink vectors

* add some code documentation

* DRY prepareRulesFilterQueryParams

* clarify that Prometheus does not support managing rules

* Improve buildinfo error handling

Co-authored-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2022-04-04 18:30:17 +01:00
Ezequiel Victorero
76b221e9d5
Access Control: hiding annotation edition and deletion without permissions (#46904)
* Access Control: disabling annotation edition without FGAC permissions
2022-04-04 11:57:43 -03:00
Gabriel Santos
b5bacce819
CloudWatch: Handle new error codes for MetricInsights (#47033)
* CloudWatch: Handle new error codes for MetricInsights

* Changes/test to support case where only the first GetMetricDataOutput returns errors and refactoring

* Fix Potential file inclusion via variable

* Fix gosec 304 by assigning a new variable

* fix goimports issue
2022-04-04 15:44:19 +02:00
Ieva
bc9b5325a0
update docs, simplify actions and scopes (#47067) 2022-04-04 13:53:58 +01:00
Marcus Efraimsson
659cf17e10
Logging: Fix syslog messages should be sent with correct severity (#47209) 2022-04-04 12:51:14 +02:00
Marcus Efraimsson
b4346a5613
Logging: Fixes filtering logs based on gokitlog levels (#47195) 2022-04-04 12:36:17 +02:00
Sergey Kostrukov
5675496f6b
Migrate to Grafana Azure SDK (#47232) 2022-04-04 11:23:13 +02:00
Yuriy Tseretyan
e94d0c1b96
Alerting: update rule test endpoints to respect data source permissions (#47169)
* make eval.Evaluator an interface
* inject Evaluator to TestingApiSrv
* move conditionEval to RouteTestGrafanaRuleConfig because it is the only place where it is used
* update rule test api to check data source permissions
2022-04-02 02:00:23 +02:00
Yuriy Tseretyan
51114527dc
Alerting: handle folder permissions when fine-grained access enabled (#47035)
* Use alert:create action for folder search with edit permissions. This matches the action that is used to query dashboards (the update will be addressed later)
* Update rule store to use FindDashboards instead of folder service to list folders the user has access to view alerts. Folder service does not support query type and additional filters. 
* Do not check whether the user can save to folder if FGAC is enabled because it is checked on API level.
2022-04-01 19:33:26 -04:00
Yuriy Tseretyan
8a2c368031
check that user is authorized to create\update silences (#47163) 2022-04-01 09:39:59 -04:00
Sergey Kostrukov
656ade9884
Shared Azure middleware between Azure Monitor and Prometheus datasources (#46002)
* Scopes in Azure middleware

* Enable Azure middleware without feature flag

* Use common Azure middleware in Azure Monitor

* Apply feature flag to JsonData configuration of Azure auth

* Enforce feature flag in Prometheus datasource

* Prometheus provider tests

* Datasource service tests

* Fix http client provider tests

* Pass sdkhttpclient.Options by reference

* Add middleware to httpclient.Options

* Remove dependency on Grafana settings

* Unit-tests updated

* Fix ds_proxy_test

* Fix service_test
2022-04-01 13:26:49 +02:00
Marcus Efraimsson
16db1ad46d
API: Fixes request logging middleware to include userId, orgId, uname (#47183)
Fixes #47006
2022-04-01 13:24:39 +02:00
Alexander Weaver
b8e277ee4c
Alerting: Create feature toggle for provisioning (#47167)
* Create feature flag for alerting provisioning

* Fix tabs for golint compliance
2022-04-01 08:32:00 +02:00
Santiago
4b1af6fb06
Fix empty contact point URLs when template parsing fails (#47029)
* fix empty URLs

* leave URL templating, use fallback

* better fix, new tests cases

* fix linting errors
2022-03-31 15:57:48 -03:00
Gábor Farkas
a246381879
loki: backend-mode: add stats support (#46526)
* loki: backend-mode: add stats support

* refactor: rename variable
2022-03-31 17:50:27 +02:00
Kevin Yu
1a4b1184bd
Azure Monitor: allow metrics call to use resource uri (#46858)
* Azure Monitor: allow metrics call to use resource uri

* test case when only resource uri is provided

* remove logs

* Rename json field name from resource to resourceUri

* Group legacy URL builder params test cases

* move comment to the correct position

* Add clarifications in comments

Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>

Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
2022-03-31 08:20:29 -07:00
felixdoerre
f5a790e291
Fix postgresql host-v6 literals (#46876)
Ipv6 literals in postgresql hosts previously worked and were subsequently
broken. This change fixes the parsing and adds additional test cases.
2022-03-31 11:45:49 +01:00
Gabriel MABILLE
0d87de153a
AccessControl: Add a feature flag for the builtin role simplification (#47062)
* AccessControl: Add a feature flag for the builtin role simplification

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

* Update standardDeatureFlags instead

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-03-31 11:40:57 +02:00
George Robinson
79769132c0
Alerting: Alert rule should wait For duration when execution error state is Alerting (#47052)
Alerting: Alert rule should wait For duration when execution error state is Alerting
2022-03-31 09:57:58 +01:00
Alexander Weaver
502cf8b37f
Alerting: Unify Swagger/OpenAPI generation tooling (#46928)
* Unify makefiles

* Improve documentation
2022-03-31 09:34:46 +02:00
Ryan McKinley
edf384c730
DashboardSave: use a feature flag for drawer behavior (#46972) 2022-03-30 10:07:41 -07:00
Nathan Marrs
4449439a41
Search: Implement basic improved UI (#46758) 2022-03-30 09:50:32 -07:00
Will Browne
572ca553b6
Plugins: Add deprecation notice for /api/tsdb/query endpoint (#45238)
* add deprecation notice for /api/tsdb/query

* fix linking

* regenerate after gen-go

* add newline

* add API docs for ds/query

* regenerate spec

* pr feedback

* add helpful tip

* make sub heading

* add more data

* update spec

* update wording

* mention both from/to

* add suggestions

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

* docs feedback

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-03-30 17:46:06 +02:00
Selene
8e52dbb87b
Chore: Remove bus from authproxy (#46936)
* Make authproxy injectable

* Fix import

* Provide function was in wrong place

* Fixing tests

* More imports and rollback a change

* Fix lint
2022-03-30 17:01:24 +02:00
Dirkco du Plessis
b52794601d
mssql: explicit disable encryption when its disabled (#46546) 2022-03-30 15:14:04 +01:00
Karl Persson
a5e4a533fa
Access control: use uid for dashboard and folder scopes (#46807)
* use uid:s for folder and dashboard permissions

* evaluate folder and dashboard permissions based on uids

* add dashboard.uid to accept list

* Check for exact suffix

* Check parent folder on create

* update test

* drop dashboard:create actions with dashboard scope

* fix typo

* AccessControl: test id 0 scope conversion

* AccessControl: store only parent folder UID

* AccessControl: extract general as a constant

* FolderServices: Prevent creation of a folder uid'd general

* FolderServices: Test folder creation prevention

* Update pkg/services/guardian/accesscontrol_guardian.go

* FolderServices: fix mock call expect

* FolderServices: remove uneeded mocks

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2022-03-30 15:14:26 +02:00
Will Browne
56e9c24f08
Plugins: Include decommissioned plugins when ignoring plugins during re-loading (#46958) 2022-03-30 15:05:12 +02:00
Will Browne
23dde457ef
Plugins: Don't start runner ticker for Core plugins (#46964)
* Plugins: Don't start runner ticker for Core plugins

* add test

* correct start check in test
2022-03-30 14:48:49 +02:00
Will Browne
42533dc973
Plugins: split manager.go into areas of responsibility (#46957) 2022-03-30 12:46:31 +02:00
kay delaney
f1c3177e79
Chore: Add type info for grafana boot data (#45322)
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
2022-03-30 10:48:58 +01:00
gotjosh
84e5f336fe
Alerting: Classic conditions can now display multiple values (#46971)
* Alerting: Extract classic condition values by RefID

* uncapitalise function

* update documentation

* Update pkg/services/ngalert/eval/extract_md.go

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

* Update pkg/services/ngalert/state/state.go

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

* Update pkg/services/ngalert/state/state.go

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

* Update pkg/services/ngalert/eval/extract_md.go

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

* Update docs/sources/alerting/unified-alerting/alerting-rules/alert-annotation-label.md

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

* Update pkg/services/ngalert/eval/extract_md.go

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

* Run prettier

Co-authored-by: George Robinson <george.robinson@grafana.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-03-29 20:33:03 +01:00
Cameron Waterman
8426cfe400
Profile/Help: Expose option to disable profile section and help menu (#46308)
* Expose option to disable help menu

* Expose option to disable profile menu

* Add Profile FeatureTogglePage

* Update public/app/features/profile/FeatureTogglePage.tsx

Uptake PR wording suggestion.

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

* Fix front end lint issue

* Fix back end lint issue

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-03-29 16:27:53 +01:00
Matthew Jacobson
932f43b220
Alerting: Add resolved count to notification title when both firing and resolved present (#46697)
* Alerting: Add resolved count to notification title when both firing and resolved are present

* Fix test case default_template_test.go
2022-03-29 11:22:28 -04:00
Andres Martinez Gotor
48113beeeb
AzureMonitor: Fix missing top parameter when dimensions are set (#47010) 2022-03-29 16:27:09 +02:00
Yuriy Tseretyan
c1dbe7617c
fix scope for datasource:query action (#46973) 2022-03-29 09:58:59 -04:00
Artur Wierzbicki
60984881ec
Previews: fix crawler in multi-org deployments (#46967)
* Previews: fix crawler in multi-org deployments

* Previews: fix statement ordering
2022-03-29 13:40:11 +01:00
Marcus Efraimsson
9eb2cd537d
Plugins: Make backend plugin metrics endpoints available with optional authentication (#46467)
* add new endpoint without auth+config

* add cfg check

* fit lint issue

* Add basic auth support

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

* WIP docs

* Update docs/sources/administration/view-server/internal-metrics.md

Co-authored-by: Dave Henderson <dhenderson@gmail.com>

* update instructions

Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Dave Henderson <dhenderson@gmail.com>
2022-03-29 11:18:26 +02:00
Tania B
8c622c1ef6
Datemath: Fix weekstart calculation (#46962)
* Update go-datemath version

* Remove unnecessary bits

* fixup! Remove unnecessary bits
2022-03-26 19:57:29 +01:00
Julien NOEL
f4b6c4019c
PostgreSQL: __unixEpochGroup to support arithmetic expression as argument (#46764)
* __unixEpochGroup to support arithmetic argument

Following call generates wrong expression : 
 
$__unixEpochGroupAlias(height+42,$__interval)

=> floor(height+42/60)*60 AS "time"

instead of

=> floor((height+42)/60)*60 AS "time"

* Update test of __unixEpochGroup related to issue #46764
2022-03-26 18:44:14 +01:00
Emil Tullstedt
7bc821baf2
Logger: Use specified format for file logger (#46970)
Fixes #45941
2022-03-26 11:40:08 +01:00
Kat Yang
e6726681a9
Chore: Remove x from annotation test (#46935) 2022-03-25 13:23:21 -04:00
Kat Yang
90f2233ea9
Chore: Remove global database engine variable from annotation (#46940)
* Chore: Remove global database engine variable from annotation

* 💩
2022-03-25 13:23:09 -04:00
Kat Yang
19be0b4170
Chore: Remove x from org users (#46848)
* Chore: Remove x from org users

* Chore: Remove x.Dialect() from org users
2022-03-25 17:19:01 +00:00
Yuriy Tseretyan
e20d157a9b
Alerting: rules delete API to check data source authorization (#46906)
* merge RuleSrv rule delete methods
* remove unused store methods
* implement delete by uid for fake store
* add scheduler mock
* implement tests for RouteDeleteAlertRules
2022-03-25 12:39:24 -04:00
Gabriel MABILLE
53e7f8405f
AccessControl: Permission Migrator, clean unused arguments (#46937) 2022-03-25 14:04:10 +01:00
Andres Martinez Gotor
3c5e68a349
CloudWatch: Fix metric names (#46929) 2022-03-25 09:17:15 +01:00
Yuriy Tseretyan
6610adf090
Alerting: remove UpdateRuleGroup from fake rule store (#46941)
* remove UpdateRuleGroup from fake rule store because It is not part of interface anymore
2022-03-24 19:29:19 -04:00
Yuriy Tseretyan
15e4556c2f
Alerting: update authorization logic to use proper legacy roles when fine-grained access is disabled (#46931)
* require legacy Editor for post, put, delete endpoints
* require user to be signed in on group level because handler that checks that user has role Editor does not check it is signed in
2022-03-24 17:13:47 -04:00
Yuriy Tseretyan
8868848e93
Alerting: rule group update API to ignore deletes of rules user is not authorized to access (#46905)
* verify that the user has access to all data sources used by the rule that needs to be deleted from the group
* if a user is not authorized to access the rule, the rule is removed from the list to delete
2022-03-24 16:53:00 -04:00
Yuriy Tseretyan
84001fe6be
log to console when run integration tests (#46934) 2022-03-24 13:08:12 -04:00
Gabriel MABILLE
9dc06cd21f
simplify bulkAssignRoles (#46891) 2022-03-24 18:06:44 +01:00
Kat Yang
39f14a2ec2
Chore: Remove x from login attempt (#46853) 2022-03-24 17:00:41 +00:00
kay delaney
8329cd59f6
LibraryPanels: Increase max description length to 2048 chars (#46601) 2022-03-24 12:14:56 +00:00
Karl Persson
cac6936015
Access control: Change data source permissions to be based on UID (#46741)
* Add ResourceAttribute

* Add ResourceAttribute option

* Set ResourceAttribute option

* Change resolvers to return uid based scopes

* update swagger to correct scope

* use ResourceAttribute for endpoint scope

* bump role version

* Add support for different attributes for access control metadata

* evaluate data source metadata based on uid

* Fix test

* uncomment benchmarks

* Use resourceID

* use evaluator for access control metadata

* update comment

* Set default permissions based on uid

* Add attribute to accesscontrol filter

* validate that scopes has correct attribute

* lint

* Update comment

* remove attribute parameter and extend prefix

* refactor to use scope prefix

* Get metadata with prefix

* fix test

* fix comparision

* remove unused type

* fix attribute index

* fix typo

* restructure logic

* Get metadata by uid

* fix imports

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2022-03-24 12:21:26 +01:00
Gabriel MABILLE
3440e7c8f7
AccessControl: Fix locked role picker in orgs/edit page (#46539)
* AccessControl: Fix locked role picker in orgs/edit page

* Use correct org when computing metadata
2022-03-24 08:58:10 +01:00
Santiago
a9b55f7905
Fix InfluxDB tag variables parsing (#46862)
* regex bug fixed

* remove unnecessary test
2022-03-23 21:13:17 -06:00
Ezequiel Victorero
c5f295b5b3
Access Control: adding FGAC validation to mass delete annotation endpoint (#46846)
* Access Control: adding FGAC validation to mass delete annotation endpoint
2022-03-23 18:39:00 -03:00
Yuriy Tseretyan
60d4cd80bf
Alerting: update DeleteAlertRuleByUID to accept many UID (#46890) 2022-03-23 16:09:53 -04:00
Selene
d57c94fb6a
Chore: Remove bus from folder service (#46840)
* Remove bus from folder service

* Fix tests
2022-03-23 19:40:22 +01:00
Yuriy Tseretyan
4ee48c2e77
Alerting: Update GetRuleGroupAlertRules to accept optional rule group (#46889)
* rename GetRuleGroupAlertRules to GetAlertRules
* make rule group optional in GetAlertRulesQuery
* simplify FakeStore. the current structure did not support optional rule group
2022-03-23 17:36:25 +00:00
Yuriy Tseretyan
acd7be1cb4
Alerting: Change getEvaluatorForAlertRule to checkDatasourcePermissionsForRule (#46887)
update method getEvaluatorForAlertRule to accept permissions evaluator and exit on the first negative result, which is more effective than returning an evaluator that in fact is a bunch of slices.
2022-03-23 17:11:30 +00:00
Joe Blubaugh
481a68cbf5
Unified Alerting: Make log message follow codebase convention. (#46881)
1. Keep log lines lower case.
2. The key-value pair arguments are not format argument for the string.
3. Always use the "err" key.
2022-03-23 15:07:07 +01:00
idafurjes
77976ea810
Add fakes for db interface (#46885) 2022-03-23 15:06:47 +01:00
Will Browne
5e18293f88
Plugins: Make plugin loading from file system deterministic (#46842)
* Plugins: Make plugin loading from file system deterministic

* fix test name

* flip assertion arg order
2022-03-23 11:58:00 +01:00
Joe Blubaugh
c5b39dd3cd
Unified Alerting, Issue 41156: Clean up expired silences. (#46740)
Expired silences older than the retention period were not being cleaned up. The root problem was that notifier.Alertmanager overrides the Prometheus alert manager's silence maintenance function and was not calling Silences.GC() in the overriden function.
2022-03-23 09:49:02 +01:00
Jean-Philippe Quéméner
a80f04c949
Alerting: add collision safe update function for alertmanager configurations (#46692)
* Alerting: add collision safe update function for alertmanager configurations

* fix typo

* use bootstrap func for tests

* move hash calculation to store

* remove icons lol

* remove removed field
2022-03-23 09:31:46 +01:00
Gabriel MABILLE
ff3c1e3144
AccessControl: Handle ':' in attribute resolution (#46742)
* AccessControl: Handle ':' in attribute resolution

* Simplify based on assumption that prefixes will have maximum 2 parts
2022-03-23 08:48:32 +01:00
Kat Yang
884c2351d8
Chore: Remove x from org (#46851) 2022-03-22 21:17:53 +00:00
Jesse Weaver
560fc9812d
Expose reporting-enabled flag to frontend (#46753) 2022-03-22 14:30:45 -06:00
Karl Persson
ee9badecdf
Access Control: Add test flag to enable access control (#46780)
* Add feature flags options to test db
2022-03-22 20:48:32 +01:00
idafurjes
5db1a2e804
Add DB interface (#46832) 2022-03-22 15:43:53 +01:00
Eng Zer Jun
b56848f006
test: use T.TempDir to create temporary test directory (#44947)
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-22 15:43:29 +01:00
Marcus Efraimsson
be7bcbf94e
Chore: Add tests for plugin settings sqlstore (#46792)
Follow up of #46777 adding tests for plugin settings in sqlstore package.
2022-03-22 15:34:27 +01:00
Selene
b2af18f129
Chore: Remove bus from dashboard service (#46829)
* Move DeleteDashboard funtion into dashboards store service, remove bus and update tests

* Remove bus from folder service and update more tests

* Fix mock
2022-03-22 14:36:50 +01:00
Karl Persson
bfb03d779d
Access Control: Correctly check for id suffix (#46824)
* Correctly check for id suffix
2022-03-22 13:48:15 +01:00
Karl Persson
faf4a3f751
Access Control: Rename global users scope (#46794)
* Rename scope from global:users to global.users to match scope convention
2022-03-22 12:48:46 +01:00
ying-jeanne
adc0cbf176
remove global variable in annotation (#46746)
* remove global varaible in annotation

* remove todo

* replace intransaction with withdbtransaction

* fix typo
2022-03-22 19:20:57 +08:00
Serge Zaitsev
4ce7978cd8
Chore: Remove bus from notification service (#46813)
* Chore: Remove bus from notification service

* fix signature

* fix function signature in tests
2022-03-22 09:04:30 +01:00
Yuriy Tseretyan
2ade8b56dd
Alerting: support fine-grained access control in ruler update API (#45749)
* require Editor if FGAC is disabled. Otherwise, check `alert.rule:*` + `datasource:query` permissions when user changes rules.
2022-03-21 19:20:35 -04:00
Serge Zaitsev
9315ddd57c
Chore: Remove bus from oauthtoken (#46811) 2022-03-21 21:13:57 +01:00
Serge Zaitsev
cce46a6349
Chore: Remove bus from live package (#46803) 2022-03-21 20:34:19 +01:00
Shirley
499445a5f9
Azure Monitor: Bump core plugin version (#46776)
* Azure Monitor: Bump core plugin version

* Remove updated, update learn more link
2022-03-21 19:01:26 +01:00
Ezequiel Victorero
c717320942
Adding FGAC annotations validation for creation and deletion (#46736)
Access Control: Adding FGAC annotations validation for creation and deletion
Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com>
2022-03-21 14:28:39 -03:00
Karl Persson
7ab1ef8d6e
Access Control: Support other attributes than id for resource permissions (#46727)
* Add option to set ResourceAttribute for a permissions service
* Use prefix in access control sql filter to parse scopes
* Use prefix in access control metadata to check access
2022-03-21 17:58:18 +01:00
Emil Tullstedt
0e5ac29763
Data sources: Grant creator edit permissions to data source by default (#46168)
* Data sources: Sent user ID when creating data source

* Data sources: Grant a data source creator edit permissions

* Use edit permisison and only append if user id is in command

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2022-03-21 17:16:05 +01:00
ying-jeanne
0d5a6c2194
remove bus from search and avoid import cycle (#46789)
* fix the import cicle

* fix some unittest

* fix removal bus from search
2022-03-21 23:54:30 +08:00
Marcus Efraimsson
1044585b50
Plugins: Fix problematic query (#46777)
Fixes mysql error "sql: expected 0 arguments, got 1" introduced via #46283
2022-03-21 15:42:05 +01:00
Serge Zaitsev
df465ccad3
Chore: Remove bus from thumbs service (#46772) 2022-03-21 14:15:31 +01:00
Ashley Harrison
5f67d78219
Use bookmark icon for Saved Items, add support for solid bookmark icon (#46775)
* Use bookmark icon for Saved Items, add support for solid bookmark icon

* Add some unit tests

* Refactor utils into own file

* Update test title

* Fix import

* consistent function style
2022-03-21 13:01:43 +00:00
Serge Zaitsev
fec634a091
Chore: Remove bus.Dispatch from guardian package (#46711)
* replace bus in guardian with sqlstore

* fix a couple of tests

* replace bus in the rest of the tests

* allow init guardian from other packages

* make linter happy

* init guardian in library elements

* fix another test in libraryelements

* fix more tests

* move guardian mock one level deeper

* fix more tests

* rename init functions
2022-03-21 10:49:49 +01:00
Yuriy Tseretyan
2bd4c9ccde
respect query filter in FindDashboards (#46652) 2022-03-18 22:38:32 +01:00
Will Browne
bda3f860a8
Plugins: Add plugin settings DTO (#46283)
* add clearer service layer

* re-order frontend settings for clarity

* fix fetch fail

* fix API response

* fix mockstore

* in -> where
2022-03-18 20:49:13 +01:00
Yuriy Tseretyan
6967b15e76
Access Control: Update Alerting Navbar links builder to use fine-grained access control (#46743)
* remove unnecesarry grants for some alerting roles
* add permissions checks to navigation
2022-03-18 12:58:50 -04:00
Ieva
f2450575b3
Access control: FGAC for annotation updates (#46462)
* proposal

* PR feedback

* fix canSave bug

* update scope naming

* linting

* linting

Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
2022-03-18 17:33:21 +01:00
Eric Leijonmarck
c592e6606c
Filtering of service accounts by expired tokens (#46251)
* Refactor to ServiceAccounts Query

* filtering expiredtokens on backend

* WIP

* WIP

* WIP

* fix: missing that we do not cover for no service accounts

* fix: wrong link

* feat: filter able to get only service accounts with expired tokens

* refactor: naming

* Update pkg/services/serviceaccounts/models.go

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

* goimported

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

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

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-03-18 15:50:34 +01:00
Ashley Harrison
7d8af12cca
Navbar: remove visual sections + home button (#46693)
* Navbar: remove visual sections + home button

* remove padding

* Fix label
2022-03-18 10:57:55 +00:00
sivamu
6c468daabc
AzureAD OAuth: Add optional strict parsing of role_attribute_path for Azure AD (#42157)
* AzureAD OAuth: Add optional strict parsing of role_attribute_path for Azure AD

Fix casting issues

modify unit tests

Unit test fix

Add proper test args

* Return empty role when using strict attribute mode

* Raise error on empty role

* Fix UT for latest case
2022-03-18 10:34:16 +00:00
idafurjes
52bd7618dd
Remove global variable from user (#46696)
* Remove global variable from user

* Remove missed x
2022-03-18 09:15:23 +01:00
Ryan McKinley
1cfb9a4a19
Storage: add basic storage service (#46604) 2022-03-17 10:19:23 -07:00
Karl Persson
4df7bf5ab2
Access control: Display inherited folder permissions in dashboards (#46421) 2022-03-17 17:08:51 +01:00
Ashley Harrison
586272e5f0
Navigation: Introduce a preferences table to store Navbar preferences (#44914)
* First attempt at creating new navbar_preferences table in db

* Apply to every nav item instead of just home

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* Chore: introduce initTestDB options for features

* fix unit tests

* Add another unit test and some logic for detecting if a preference already exists

* tidy up

* Only override IsFeatureToggleEnabled if it's defined

* Extract setNavPreferences out into it's own function, initialise features correctly

* Make the linter happy

* Use new structure

* user essentials mob! 🔱

* user essentials mob! 🔱

* Split NavbarPreferences from Preferences

* user essentials mob! 🔱

* user essentials mob! 🔱

* Fix lint error

* Start adding tests

* Change internal db structure to be a generic json object

* GetJsonData -> GetPreferencesJsonData

* Stop using simplejson + add some more unit tests

* Update pkg/api/preferences.go

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

* Updates following review comments

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* Change patch to upsert, add a unit test

* remove commented out code

* introduce patch user/org preferences methods

* Return Navbar preferences in the get call

* Fix integration test by instantiating JsonData

* Address review comments

* Rename HideFromNavbar -> Hide

* add swagger:model comment

* Add patch to the preferences documentation

* Add openapi annotations

* Add a short description

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* Update unit tests

* remove unneeded url

* remove outdated comment

* Update integration tests

* update generated swagger

Co-authored-by: Alexandra Vargas <alexa1866@gmail.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-03-17 12:07:20 +00:00
Yuriy Tseretyan
7df22c1573
Access Control: Fix Filter to correctly handle duplicated scopes (#46667) 2022-03-16 16:59:19 -04:00
Joan López de la Franca Beltran
2081f37e95
Encryption: Make DEKs cache TTL & cleanup interval configurable (#46042)
* Make DEKs cache TTL & cleanup interval configurable

* Improve 'data_keys_cache_ttl' setting description

* Fix test
2022-03-16 20:05:13 +01:00
gotjosh
a338c78ca8
Alerting: Remove internal labels from prometheus compatible API responses (#46548)
* Alerting: Remove internal labels from prometheus compatible API responses

* Appease the linter

* Fix integration tests

* Fix API documentation & linter

* move removal of internal labels to the models
2022-03-16 16:04:19 +00:00
Jguer
d5883c1b27
Service Accounts: Implement basic usage stats (#46619)
* Stats: do not count SAs as users

* Stats: implement basic service account metrics

* Stats: do not count service account tokens as api keys

* Stats: fix metric names

* Stats: add SA stats test

* rename user to sa
2022-03-16 16:54:34 +01:00
Karl Persson
943a8508a6
Handle case where there are no matching ids for all actions passed to (#46646) 2022-03-16 16:31:33 +01:00
Karl Persson
2727e2503f
Use corrct variable names (#46647) 2022-03-16 16:18:45 +01:00
Eric Leijonmarck
f4bed21cee
remove /upgradeall apiendpoint (#46638) 2022-03-16 15:33:13 +01:00
Karl Persson
d27ff42376
Access control: Move data source actions and scopes to datasource package (#46594)
* Add permission actions and id scope

* Remove scope and actions variable prefix

* Move page evaluators and rename them
2022-03-16 15:11:03 +01:00
Yuriy Tseretyan
ea815d640f
Search Service to support search for folders available for alerting (#46483)
* support new query type "alert-folder"
* move action calculation to the constructor of the filter
* update filter to support query type `dash-folder-alerting` and empty dashboard actions
* require folders:read to access alert rules
2022-03-16 14:07:04 +00:00
Karl Persson
7192b7caee
Access control: Move licensing actions to licensing package (#46588)
* Move licensing actions to licensing package
2022-03-16 14:37:19 +01:00
Yuriy Tseretyan
c42d2e6f5d
Alerting: Add support for fine-grained access to alerting APIs (#46561) 2022-03-16 09:36:58 -04:00
Karl Persson
8261e781d5
Access control: Delete user permissions when a user is deleted (#46021)
* Remove access control related to user on deletion
2022-03-16 10:43:44 +01:00
Andres Martinez Gotor
727204ed5e
CloudMonitoring: Improve error message (#46599) 2022-03-16 09:37:48 +01:00
Yuriy Tseretyan
468def0c00
Alerting: fixed roles for fine-grained access control (#46553)
* move alerting actions to accesscontrol to avoid cycledeps
* define new actions and fixed roles for alerting
* add folder permission to alert reader role
2022-03-15 14:30:32 -04:00
Artur Wierzbicki
b8fba41d74
Storage: unify List queries (#46572)
* silence errors

* s3 fix - don't retrieve files with path equal to the root

* Storage: unify list queries

* Storage: add `IsFolder` method to file obj

* Storage: API consistency - always refer `File` as a pointer rather than a value
2022-03-15 21:21:22 +04:00
Alexander Weaver
92716cb602
Alerting: Create abstraction for launching transactions and refactor existing transaction management to use it (#46216)
* Remove InTransaction from RuleStore and make it its own interface

* Ensure that ctx-based is clear from name

* Resolve merge conflicts

* Refactor tests to work in terms of the introduced abstraction rather than concrete dbstore
2022-03-15 11:48:42 -05:00
Jguer
04267a66ec
Service Accounts: Refactor login service to use sqlstore methods (#46585)
* refactor login service to use sqlstore methods

* trailing newline
2022-03-15 16:57:21 +01:00
Yuriy Tseretyan
e62e9904ee
Folder UID scope resolver (#46426) 2022-03-15 15:37:16 +01:00
Leonard Gram
f46038ed3a
Search: sort results correctly when using postgres (#46466)
* Search: sort results correctly when using postgres

postgresql puts nulls first while both mysql and sqlite puts them last

* linting
2022-03-15 15:08:40 +01:00
Ieva
510c69ec91
Access control: allow hiding roles (#46358)
* allow hiding roles

* extend docs

* docs feedback

* extend provisioning docs

* formatting

Co-authored-by: Leonard Gram <leo@xlson.com>
2022-03-15 13:17:45 +00:00
Gabriel MABILLE
75935c75c1
ServiceAccounts: Fix role update (#46568)
* ServiceAccounts: Fix role update

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

* Fix patch missing metadata

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

* Fix patch missing metadata

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

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-03-15 10:48:10 +01:00
Jean-Philippe Quéméner
e135b8531a
Alerting: refactor receiver validation to be reusable (#46103) 2022-03-15 00:27:10 +01:00
Sarah Zinger
275f33cf37
Azure Monitor: Add feature gating for new MetricsQueryEditor with resource picker (#46124)
* Azure Monitor: Use feature toggle for dev of new UI for Metrics Queries.

* Fixes after CR
2022-03-14 15:07:45 -04:00
Jguer
ef9fe26886
Service accounts: Split user and service account database (#46442)
* ServiceAccounts: remove unused endpoint

* ServiceAccounts: remove usage of getOrgUsers from service accounts

* use dialect for boolean str true in delete

* return service account results directly

* Move Service Account Deletions to sa package

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

* Move service account methods to service accounts

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

* Service accounts should not interfere with users

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

* filter service accounts in user services

* mispell fix

* fix overextended lines

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

* fix variable

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-03-14 18:24:07 +01:00
Kevin Yu
99b4dfc27d
Dashboard: Validate refId when generating id for cloudwatch query (#46182)
* Validate refId when generating id for cloudwatch query

* add test case when refId is a valid metric data id
2022-03-14 09:44:04 -07:00
Gabriel MABILLE
74b441536d
ServiceAccount: fix writer role version (#46540) 2022-03-14 17:35:39 +01:00
Karl Persson
544b6ab736
Access control: Add logs to access control dashboard guardian (#46534)
* Add logs to access control dashboard guardian

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-03-14 17:12:09 +01:00
Karl Persson
8688073564
Access control: Support filter on several actions (#46524)
* Add support for several actions when creating a acccess control sql
filter
2022-03-14 17:11:21 +01:00
Yuriy Tseretyan
9465eb1b3a
Folder store (#46431)
* create FolderStore
* update usages to provide context
* implement methods to get folder by ID and UID
* update folder service to use store methods
2022-03-14 11:21:42 -04:00
gotjosh
a75d4fcbd8
Alerting: Display query from grafana-managed alert rules on /api/v1/rules (#45969)
* Aleting: Extract query from alerting rule model for api/v1/rules

* more changes and fixtures

* appease the linter
2022-03-14 10:39:20 +00:00
Artur Wierzbicki
5881127319
Storage: fix filestorage.Wrapper PathFiltering and non-recursive folder listing (#46469)
* fix pathFilters in wrapper - apply rootPath changes before filtering

* fix non-recursive folder listing
2022-03-11 23:16:46 +04:00
Artur Wierzbicki
ed924b3d0c
Storage: list filtering and root folder support (#46453)
* git the things: FS api internal changes

* remove filestorage/service.go

* remove filestore flag

* remove dummy fs

* readd fileblob import
2022-03-11 22:08:19 +04:00
Gabriel MABILLE
bd918927b4
Accesscontrol: fix data source name resolver and add uid name resolver (#46409)
* Fix data source scope resolver

* Adding ds UID scope resolver

* Register UID resolver

* use package full name

* even if it cannot be empty as of now and is also checked by store, better safe than sorry
2022-03-11 08:50:04 +01:00
Marcus Efraimsson
6c7d326499
Plugins: Refactor GetPluginDashboards/LoadPluginDashboard (#46316)
Refactors GetPluginDashboards/LoadPluginDashboard by moving database 
interaction from plugin management to the plugindashboards service.

Fixes #44553

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-03-10 18:38:04 +01:00
Yuriy Tseretyan
d076cabb60
Folder name scope resolver (#46380)
* move dashboard store mock to parent package to avoid cycle of dependencies
* add scope resolver for folders that resolves names to id
2022-03-10 12:19:50 -05:00
Kyle Brandt
cab509fbe8
SSE: Keep FieldConfig for data source queries (#46328)
for #46325
2022-03-10 10:03:26 -05:00
Karl Persson
52decfaebc
Access control: Move call to create default permissions into folder and dashboard service (#46186)
* Move call to create permissions into folder service

* Inject cfg, feature toggles and permissions services into dashboard
service

* Move logic to set default permissions on create dashboard from api to
service

* Move call to set default permissions on import dashboard to dashboard
service

* Set permissions for provisioned dashboard and folders in service
2022-03-10 12:58:18 +01:00
gotjosh
8d4a0a0396
Alerting: Include annotations in prometheus Alert response. (#45970)
* Alerting: Include annotations in prometheus Alert response.

* add tests

* re-order depedencies
2022-03-09 18:20:29 +00:00
gotjosh
b1e6f7126a
Logging: Helper to create NopLogger (#46376) 2022-03-09 17:03:58 +00:00
Yuriy Tseretyan
314be36a7c
Move datasource scopes and actions to access control package (#46334)
* create scope provider
* move datasource actions and scopes to datasource package + add provider
* change usages to use datasource scopes and update data source name resolver to use provider
* move folder permissions to dashboard package and update usages
2022-03-09 11:57:50 -05:00
Erik Sundell
6670257c5e
CloudWatch: Use default http client from aws-sdk-go (#46370)
* use default http client from aws-sdk-go

* temp comment out line and link to issue
2022-03-09 16:29:10 +01:00
Xiangkun Liu
5fc5de8d5f
Sync GitHub OAuth user name to Grafana if it's set (#45438) 2022-03-09 00:11:51 +08:00
Todd Treece
db5f480a8f
Prometheus: Fix timestamp truncation (#46302)
* avoid truncation to seconding by using time.Time directly

* update test coverage
2022-03-08 10:55:25 -05:00
Yuriy Tseretyan
f7894db99c
Alerting: declare authorization actions, scopes and roles for fine-grained access (#45748)
* add actions, roles and route mapping for rule permission
* add instance\notification actions
* do not declare alerting roles if no feature flag is set (temporary)
2022-03-08 09:22:16 -05:00
J Guerreiro
874ac9180b
Service Accounts: Add enabled/disabled status to list (#46259)
* ServiceAccounts: improve where condition

* ServiceAccounts: Add Enabled/Disabled status to list
2022-03-08 14:10:16 +01:00
Karl Persson
1f3f4ebe21
Support permission filter in access control search filter (#46317) 2022-03-08 12:46:49 +01:00
J Guerreiro
2aeae69a16
Service Accounts: Display name to ID (#46258)
* ServiceAccounts: modernize SA creation interface

* ServiceAccounts: improve service account ID generation

* ServiceAccounts: remove unused method

* ServiceAccounts: Make SA ID display name dependent

* ServiceAccounts: Add tests for Service Account creation

* trim trailing whitespace

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

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

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

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-03-08 12:07:58 +01:00
Jeff Levin
5d2f34d8e2
ValidatedQueries: start of validated queries API (#44731)
* adds an api endpoint for use with public dashboards that validates orgId, dashboard, and panel when running a query. This feature is in ALPHA and should not be enabled yet. Testing is based on new mock sqlstore.

Co-authored-by: Jesse Weaver <jesse.weaver@grafana.com>
Co-authored-by: Leandro Deveikis <leandro.deveikis@gmail.com>
2022-03-07 09:33:01 -09:00
Karl Persson
77393121ca
ingore permissions in json serialization (#46295) 2022-03-07 16:35:57 +01:00
J Guerreiro
c6cae8411a
APIKeys: add API key migration to ensure fk is null (#46285) 2022-03-07 15:58:20 +01:00
Karl Persson
0debf33c76
Access control: Always append all permissions to role admin in oss (#46282)
* Always append all permissions to built in role admin in oss
2022-03-07 13:28:39 +01:00
Ivana Huckova
6e96506c23
Query history: Add search functionality (#45932)
* Query history: Add search functionality

* Add more tests

* Add documentation

* Fix spell errors

* Update docs

* Update docs

* Fix lint error

* Update docs/sources/http_api/query_history.md

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

* Document limit

* Run tests with postgres and mysql

* Use CASE insted of IIF

* Use BooleanStr instead of 1

* Change LIKE to LikeStr()

* Return back integration tests

* Update SQL to use Bool() everywhere

* Create new tests for sorting

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

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

* Add page, count and limit to results

* Remove newline

* Update documentation

* Update docs

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-03-07 12:28:04 +01:00
Yuriy Tseretyan
288e8eeb15
Alerting: Do not update rule in database if it was not changed (#45980)
* do not include update if no diff
* refactor calculate changes to include diff (and log)

Co-authored-by: George Robinson <george.robinson@grafana.com>
2022-03-04 16:16:33 -05:00
J Guerreiro
7f1e8cee2b
APIKeys: Add AC controls for legacy API keys (#46255)
* APIKeys: Add AC controls for legacy API keys

* pluralize actions
2022-03-04 19:01:03 +01:00
Will Browne
6a8cbd8663
Plugins: Plugin settings refactor (#46246)
* remove bus and direct use of sqlStore

* add decryption to interface

* return nil

* rename field

* re-order fields

* rename file
2022-03-04 17:09:50 +01:00
Will Browne
7694b78456
mv and refactor (#46242) 2022-03-04 15:26:35 +01:00
Eric Leijonmarck
3d168eb34b
Searchable service accounts (#45844)
* WIP

* draft of WIP

* feat: search and filtering works 🌈

* Update pkg/models/org_user.go

* Apply suggestions from code review

* refactor: remove unsed function

* refactor: formatting

* Apply suggestions from code review

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

* WIP

* comment

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

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

* review comments

* wip

* working search and initial load of service accounts

* number of tokens working

* removed api call

* Apply suggestions from code review

* added accescontrol param

* accesscontrol prefix corrected

Co-authored-by: J Guerreiro <joao.guerreiro@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2022-03-04 12:04:07 +01:00
Shirley
438512c7ef
CloudWatch: Add tests to query input region in executeLogAlertQuery (#46212) 2022-03-04 11:15:36 +01:00
Sergey Kostrukov
1dca39fb91
Auth Proxy: encoding of non-ASCII headers (#44797)
* Decode auth proxy headers using URL encoding

* Header encoding configuration via settings file

* Rename configuration setting to headers_encoded

* Quoted-printable encoding

* Tests for AuthProxy

* Fix encoding name

* Remove authproxy init
2022-03-04 04:58:27 -05:00
Gilles De Mey
a9b1a964b0
Alerting: adds support for federated rules (#46037) 2022-03-04 10:16:13 +01:00
Gábor Farkas
c4404982dc
loki: backend-mode: add nanosecond-timestamps (#45963) 2022-03-04 09:42:18 +01:00
Karl Persson
8cea8fdaea
Access Control: Filter out hidden permissions in access control dashboard guardian (#46177)
* Implement GetHiddenACL to handle legacy api correctly
2022-03-03 18:29:39 +01:00