Commit Graph

3828 Commits

Author SHA1 Message Date
Kevin Yu
6151320020
Cloud Monitoring: add feature toggle for experimental UI (#50460)
* Cloud Monitoring: add feature toggle for experimental UI

* remove RequiresDevMode
2022-06-09 15:56:32 +02:00
Gabriel MABILLE
840a442796
RBAC: Rename alerting roles to match naming convention (#50504) 2022-06-09 14:29:27 +02:00
Karl Persson
80a030605f
change to debug logs to match non access control guardian (#50477) 2022-06-09 13:51:56 +02:00
Karl Persson
bc87edb727
only check dashboard scope in guardian and register resolver for tests (#50427) 2022-06-09 11:53:16 +02:00
George Robinson
c636685ca2
Fix metric names for screenshots (#50426) 2022-06-09 10:32:30 +01:00
Alexander Weaver
7dd78fee2c
Alerting: Fix provisioning validation status codes and panics (#50464)
* Updates to all except alert rules

* Return 400 when rules fail to validate, add testinfra

* More sane package aliases

* More package alias renames

* One more bug in contact point validation

* remove unused function

Co-authored-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>
Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
2022-06-09 10:38:46 +02:00
Marcus Efraimsson
cddab15769
Chore: Upgrade grafana-plugin-sdk-go to v0.137.0 (#50443)
Co-authored-by: Todd Treece <todd.treece@grafana.com>
2022-06-09 10:10:58 +02:00
George Robinson
0bd12ab531
Alerting: Fix force_migration when alerting is disabled (#50431)
* Alerting: Fix force_migration when alerting is disabled

This commit fixes a bug where force_migration must be set to true
when both unified and legacy alerting is disabled.

* Update comment

* Fix typo in comment

Co-authored-by: Armand Grillet <armand.grillet@outlook.com>
2022-06-09 10:10:11 +02:00
Jean-Philippe Quéméner
cf684ed38f
Alerting: bump rule version when updating rule group interval (#50295)
* Alerting: move group update to alert rule service

* rename validateAlertRuleInterval to validateRuleGroupInterval

* init baseinterval correctly

* add seconds suffix

* extract validation function for reusability

* add context to err message
2022-06-09 09:28:32 +02:00
Yuriy Tseretyan
54fa04263b
Alerting: Add RBAC actions and role for provisioning API routes (#50459)
* add alert provisioning actions and role

* linter
2022-06-09 09:18:57 +02:00
Joe Blubaugh
30f035ca34
Alerting: Improve Unified Alerting Rollback Warning (#50470)
After migrating to unified alerting, users must explicitly allow rolling
back to legacy alerting by setting force_migration = true in config.
This updates the panic message to clarify why that's required and what
the consequences of rolling back will be.

Fixes #50469
2022-06-09 13:31:49 +08:00
Joe Blubaugh
ecf080825e
Alerting: Fix image embed in email template. (#50370)
The ng_alert_notification email template did not include templating for
linked or embedded images. This change updates that.

Additionally, this change supports embedding an image for each alert in
an email batch.

Fixes #50315
2022-06-09 10:01:58 +08:00
Santiago
9dc7e752b7
Optional custom title and description for OpsGenie (#50131)
* optional custom description for OpsGenie

* custom title and message, tests

* update changelog

* check for empty / whitespace only strings

* truncate the title to 130 characters if needed

* unnecessary validation removed

* truncate title to 127 characters and add three dots
2022-06-08 17:55:31 -03:00
gotjosh
c59938b235
Alerting: Schedule Alert rules metric tracking (#50415)
* Alerting: Schedule Alert rules metric tracking

Change the record of metrics from one place to two as an attempt to have a semi-accurate record.
2022-06-08 18:37:33 +01:00
Gabriel MABILLE
2813e49842
RBAC: Fix migrations running into the wrong order (#50452)
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>

Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
2022-06-08 19:33:32 +02:00
Yuriy Tseretyan
a89d4a5be7
Alerting: Scheduler to drop ticks if a rule's evaluation is too slow (#48885)
* drop ticks if evaluation of a rule is too slow.
* add metric schedule_rule_evaluations_missed_total
2022-06-08 12:50:44 -04:00
idafurjes
e9f8d582c8
Chore: Remove dashboard version from models (#50287)
* Remove dashbpard version from models

* Fix lint

* Fix api & sqlstore tests

* Remove integration tags

* Fix lint again

* Add integration test to correct namespace

* Lont fix 2

* Change Id to ID in dashVersionMeta
2022-06-08 12:22:55 +02:00
idafurjes
a938ae1d9e
Chore: Remove integration tag (#50395) 2022-06-08 12:17:03 +02:00
Gábor Farkas
50145e1617
Loki: remove frontend mode code (#50185)
* feature-flag removed

* loki: remove frontend-mode
2022-06-08 08:14:34 +02:00
Jean-Philippe Quéméner
fd664e4beb
Alerting: replace a duplicated configuration key (#50350)
This PR renames the configuration key enabled to capture. This is needed as we already have a configuration key with the name enabled.

Fixes #50328

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
2022-06-08 11:04:51 +08:00
Alexander Weaver
28a47b56d2
Bump provisioning to admin-only in lieu of dedicated RBAC permissions (#50366) 2022-06-07 17:26:48 -05:00
gotjosh
0cde283505
Alerting: Logs should not be capitalized and the errors key should be "err" (#50333)
* Alerting: decapitalize log lines and use "err" as the key for errors

Found using (logger|log).(Warn|Debug|Info|Error)\([A-Z] and (logger|log).(Warn|Debug|Info|Error)\(.+"error"
2022-06-07 19:54:23 +02:00
George Robinson
c83f84348c
Alerting: Fix database unavailable removes rules from scheduler (#49874) 2022-06-07 16:20:06 +01:00
Dan Cech
9350ab781c
clean up duplicated user creation code (#50178)
* clean up duplicated user creation code

* remove unused duplicate getOrCreateOrg function

* fix up tests
2022-06-07 09:49:18 -04:00
Karl Persson
9fd9a2cded
RBAC: Remove workaround to check permissions on folders for dashboard actions (#50291)
* remove workaround to check permissions on folders for dashboard actions
2022-06-07 13:21:56 +02:00
Karl Persson
c4a75f9eb3
RBAC: Add scope resolvers for dashboards (#50110)
* Inject access control into dashboard service

* Add function to parse id scopes

* Add dashboard as return value

* Update mock

* Return only err to keep service interface

* Add scope resolvers for dashboard id scopes

* Add function to parse uid scopes

* Add dashboard uid scope resolver

* Register scope resolvers for dashboards

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-06-07 11:02:20 +02:00
sam boyer
8876d56495
schema: Migrate from scuemata to thema (#49805)
* Remove crufty scuemata bits

Buhbye to: cue/ dir with old definitions, CI steps for checking unnecessary
things, and the original dashboard scuemata file.

* Remove grafana-cli cue subcommand

* Remove old testdata

* Don't swallow errors from codegen

* Small nits and tweaks to cuectx package

* WIP - refactor pluggen to use Thema

Also consolidate the embed.FS in the repo root.

* Finish halfway rename

* Convert all panel models.cue to thema

* Rewrite pluggen to use Thema

* Remove pkg/schema, and trim command

* Remove schemaloader service and usages

Will be replaced by coremodel-centric hydrate/dehydrate system Soon™.

* Remove schemaloader from wire

* Remove hangover field on histogram models.cue

* Fix lint errors, some vestiges of trim service

* Remove unused cuetsify cli command
2022-06-06 17:52:44 -07:00
Kat Yang
31630edf0c
Chore: Remove Wrapf (#50128)
* Chore: Remove Wrapf

* Remove all Wrapf refs

* Remove last Wrapf ref

* Fix lint errors

* Remove Wrap and Wrapf definitions

* Remove unnecessary colon
2022-06-06 22:30:31 +02:00
Ieva
7c800421d3
RBAC: change migration logic (#50187)
* change migration logic

* linting

* linting

* fix an issue with the migration logic

* make tests runnable against other DBs

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2022-06-06 13:51:07 +02:00
Alexander Emelin
da49f907bb
SearchV2: explicit dashboard loading order and cleanups (#50210) 2022-06-05 23:46:35 +02:00
Jean-Philippe Quéméner
4b8a4449ed
Alerting: remove feature toggle for provisioning API (#50167)
* Alerting: remove feature toggle for provisioning API

* remove missed code parts

* remove unused import

* remove empty line

* mark routes as stable
2022-06-05 07:45:36 +02:00
Jean-Philippe Quéméner
4cc8c6f745
Alerting: Add provenance guard to config api (#50147)
* Alerting: add provenance guard to config api

* add tests

* only guard if config valid

* adapt error message

* simplify logic

* rename arguments

* make logic more straight forward

* rename opt to options

* remove useless maps
2022-06-04 14:55:46 +02:00
Tania
4f8111e24e
Encryption: Fix multiple data keys migration (#49848)
* Add migration

* Migrator: Extend support to rename columns

* Fix getting current key

* Fix column name in migration

* Fix deks reencryption

* Fix caching

* Add back separate caches for byName and byPrefix

* Do not concatenate prefix with uid

* Rename DataKey struc fields

* SQLStore: Add deprecation comments for breaking migrations

* Add comment

* Minor corrections

Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
2022-06-04 12:55:49 +02:00
Jean-Philippe Quéméner
8de4ffe61f
Alerting: only delete mute time if not used by route (#50193)
* Alerting: only delete mute time if not used by route

* add a testcase

* import package only once

* replace apimodels with definitions
2022-06-04 07:48:24 +02:00
Joan López de la Franca Beltran
219e848e73
SQLStore: Prevent migration_id duplicates (#47774)
* SQLStore: Prevent migration_id duplicates

* Migrations: Remove non-executed migration (duplicated id)

Co-authored-by: Leonard Gram <leo@xlson.com>
2022-06-04 01:59:49 +02:00
Alexander Emelin
d2868a1ce7
SearchV2: instant local updates, folder events (#50001) 2022-06-03 13:11:32 -07:00
Yuriy Tseretyan
49d93fb67e
Alerting: Update alert rule diff to not see difference between nil and empty map (#50192) 2022-06-03 21:27:29 +02:00
Jean-Philippe Quéméner
d2f3631a47
Alerting: add mute timings provenance to config api (#50149) 2022-06-03 19:32:31 +02:00
Joan López de la Franca Beltran
5f1305d280
SQLStore: Add deprecation comments for breaking migrations (#49740)
* Migrator: Extend support to rename columns

* SQLStore: Add deprecation comments for breaking migrations
2022-06-03 17:42:08 +02:00
Marcus Efraimsson
36c3398c6d
Datasource: Remove support for unencrypted passwords (#49987)
* Datasource: Remove support for unencrypted passwords

* regenerate swagger

* [WIP] Remove references to datasource password and basic auth password fields (#50015)

* try delete moar tings

* delete provisioning stuff

* remove from yaml

* update snapshots

* remove lingering snapshot fields

* fix ds http settings

* Re-generate swagger and fix swagger-api-spec make target

Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-06-03 17:38:22 +02:00
Tania
7a614fd8a1
Encryption: Stop decrypting EE encrypted secrets with legacy encryption (#50090) 2022-06-03 17:06:00 +02:00
Yuriy Tseretyan
c85567f490
fix logging of resolving scopes (#50173) 2022-06-03 10:53:53 -04:00
Alexander Weaver
67290aa49f
Alerting: Add version segment to all provisioning routes (#49121)
Co-authored-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>
2022-06-03 16:45:08 +02:00
Gilles De Mey
e6ceee501f
Alerting: Use correct permission scope for external AM updates (#50159)
Co-authored-by: konrad147 <konrad.lalik@grafana.com>
2022-06-03 15:12:34 +02:00
Todd Treece
64d93498de
Chore: Update grafana-plugin-sdk-go to v0.136.0 (#50127) 2022-06-03 08:25:52 -04:00
Jean-Philippe Quéméner
468ed68d64
Alerting: allow custom UID for contact points through API (#50089)
* Alerting: allow custom UID for contact points through API

* fix auth
2022-06-03 10:33:47 +02:00
Kat Yang
3c3039f5b3
Chore: Remove Wrap (#50048)
* Chore: Remove Wrap and Wrapf

* Fix: Add error check
2022-06-03 09:24:24 +02:00
Jeff Levin
52ed651958
public dashboards: insert default public dashboard config into database on save (#49131)
This PR adds endpoints for saving and retrieving a public dashboard configuration and and api endpoint to retrieve the public dashboard.

All of this is highly experimental and APIs will change. Notably, we will be removing isPublic from the dashboard model and moving it over to the public dashboard table in the next release.

Further context can be found here: https://github.com/grafana/grafana/pull/49131#issuecomment-1145456952
2022-06-02 18:27:23 -08:00
Ryan McKinley
efca93a3f3
Search: exclude rows from search index (#50124) 2022-06-02 17:29:14 -07:00
Ryan McKinley
d452322aa8
Search (SQL): support dashboardUID query parameter (#50121) 2022-06-02 12:56:01 -07:00
Kat Yang
bc8578524b
Chore: Remove last build tag (#50120) 2022-06-02 17:36:34 +00:00
Ryan McKinley
15b3bbad6b
SearchV2: include appSubUrl in the response URL (#50059) 2022-06-02 17:56:20 +02:00
Karl Persson
896a101f48
RBAC: Extract method from access control impl to a function in domain packge (#49947)
* Remove GetUserBuiltInRoles and create it as a util function in
accesscontrol domain package
2022-06-02 16:10:41 +02:00
Kristin Laemmert
0e991461b0
backend/sqlstore: move GetDashboardTags to dashboard service (#50091)
+ removing some functions that were already copied to the dashboard service in a previous pr.
2022-06-02 10:00:47 -04:00
idafurjes
bdf50f3dd2
Dashboards: Split GetDashboardVersions method (#49967)
* Split GetDashboarVersions method

* Add sqlstore dialect and tests

* Fix signature of PAtchPreference

* Add GetDialect to sqlstore and remove GetDashboardVersions

* Add GetDialect to db interface

* Implement List

* add deleted test function

* Remove GetDialect from sqlstore interface

* Remove deleted method from mock

* Refactor test
2022-06-02 15:59:05 +02:00
Jean-Philippe Quéméner
81d360529b
Alerting: Provisioning API - Alert rules (#47930) 2022-06-02 14:48:53 +02:00
Ieva
5dbea9996b
RBAC: Make RBAC action names more consistent (#49730)
* update action names

* correctly retrieve teams for signed in user

* remove test

* undo swagger changes

* undo swagger changes pt2

* add migration from old action names to the new ones

* rename from list to read

* linting

* also update alertign actions

* fix migration
2022-06-02 13:14:48 +01:00
Joe Blubaugh
9759eeda17
Alerting: Remove Image Upload code from Slack notifier. (#50062)
The image file upload code as it is now simply doesn't work - it's
missing several important steps in the file upload process. There is
more information in the fixed issue as to the steps required.

After this change, screenshots will still be attached to slack messages
when external image storage is used with Grafana (an S3 bucket, for
example).

Fixes #50056
2022-06-02 17:18:35 +08:00
gotjosh
1a50b0dbb7
Alerting: Remove double quotes from matchers (#50038)
* Alerting: Remove double quotes from matchers

With #38629 a new Alertmanager configuration object was introduced with `object_matchers`, it was meant to circumvent around the fact that Prometheus label names don't support a set of characters that Grafana needs to support for alerts, silences, matchers, etc. (with a common example being elasticsearch's `.`).
This new object does not include the label of sanitzation or validation that its Prometheus equivalent supports in `matchers` and therefore are semantically not equivalent.

This triggered the problem that when the migration is run, we use `matchers` as the object to populate in configuration for routing policies, but when the UI does its first save this object is transformed to `object_matchers`.

Matchers that were previously running just fine would immediately stop working as soon as the configuration is saved.

This problem surfaced with the introduction of #49952 where we stopped stripping double quotes from matchers (not just regex but _all_ of them).

* Add comment explaining rationale and future removal

Co-authored-by: Alex Weaver <weaver.alex.d@gmail.com>
2022-06-01 16:05:24 -05:00
Kat Yang
c63ebc887b
Chore: Run integration tests without grabpl (#49448)
* Chore: Run integration tests without grabpl

* Add new step for integration tests in lib.star

* Remove old integration test step from lib.star

* Change drone signature

* Fix: Edit starlark integration step to not affect enterprise

* Remove all build tags & rename starlark integration test step

* Resync .drone.yml with .drone.star

* Fix lint errors

* Fix lint errors

* Fix lint errors

* Fix more lint errors

* Fix another lint error

* Rename integration test step

* Fix last lint error

* Recomment enterprise step

* Remove comment from Makefile

Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
2022-06-01 14:55:22 -04:00
Kristin Laemmert
2edfbb7767
sqlstore split: dashboard permissions (#49962)
* backend/sqlstore split: remove unused GetDashboardPermissionsForUser from sqlstore
* remove debugging line
* backend/sqlstore: move dashboard permission related functions to dashboard service
2022-06-01 14:16:26 -04:00
Connor Lindsey
3fff17af63
Tempo: Consider tempo search out of beta and remove beta badge and feature flags (#50030)
* Tempo: Remove beta notice and feature flag for search

* remove unused imports
2022-06-01 11:32:10 -06:00
Yuriy Tseretyan
c8d891785d
Alerting: Ticker to support stopping (#48142)
* add stop for ticker
* stop ticker when scheduler stops
* stop ticker when legacy engine stops
2022-06-01 17:48:10 +02:00
Yuriy Tseretyan
ad25e2a20c
Alerting: Update RBAC for alert rules to consider access to rule as access to group it belongs (#49033)
* update authz to exclude entire group if user does not have access to rule
* change rule update authz to not return changes because if user does not have access to any rule in group, they do not have access to the rule
* a new query that returns alerts in group by UID of alert that belongs to that group
* collect all affected groups during calculate changes
* update authorize to check access to groups
* update tests for calculateChanges to assert new fields
* add authorization tests
2022-06-01 10:23:54 -04:00
Guilherme Caulada
470be98588
Secrets: Fix unified secrets backwards compatibility (#49719)
* Fix unified secrets backwards compatibility

* Add compatibility fix to AddDataSource function

* Allow updating password on fail to decrypt secrets

* If unified secret is corrupt try migrating
2022-06-01 10:45:43 -03:00
Karl Persson
bdff63d4a8
RBAC: Include alert.rules action when setting folder permissions (#49946)
* Generate additional actions when setting folder permissions in acl list

* Add migration for managed folder permissions to include alert rule
actions
2022-06-01 15:29:37 +02:00
Carl Bergquist
9562fb389f
Metrics: Remove support for using summaries instead of histogram for HTTP instrumentation (#49985)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2022-06-01 14:33:59 +02:00
Alexander Zobnin
50538d5309
ServiceAccounts: refactor UI (#49508)
* ServiceAccounts: refactor ServiceAccountRoleRow

* Refactor ServiceAccountRoleRow

* Refactor ServiceAccountProfile

* Refactor components

* Change service accounts icon

* Refine service accounts page header

* Improve service accounts filtering

* Change delete button style

* Tweak account id

* Auto focus name field when create service account

* Add disable/enable button

* Enable/disable service accounts

* Optimize updating service account (do not fetch all)

* Remove status column (replace by enable/disable button)

* Add banner with service accounts description

* Add tokens from main page

* Update tokens count when add token from main page

* Fix action buttons column

* Fix tokens count when change role

* Refine table row classes

* Fix buttons

* Simplify working with state

* Show message when service account updated

* Able to filter disabled accounts

* Mark disabled accounts in a table

* Refine disabled account view

* Move non-critical components to separate folder

* Remove confusing focusing

* Fix date picker position when creating new token

* DatePicker: able to set minimum date that can be selected

* Don't allow to select expiration dates prior today

* Set tomorrow as a default token expiration date

* Fix displaying expiration period

* Rename Add token button

* Refine page styles

* Show modal when disabling SA from main page

* Arrange role picker

* Refine SA page styles

* Generate default token name

* More smooth navigation between SA pages

* Stop loading indicator in case of error

* Remove legacy styles usage

* Tweaks after code review

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

* Get rid of useDisapatch in favor of mapDispatchToProps

* Tests for ServiceAccountsListPage

* Tests for service account page

* Show new role picker only with license

* Get rid of deprecated css classes

* Apply suggestion from code review

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

* Fix service accounts icon

* Tests for service account create page

* Return service account info when update

* Add behaviour tests for ServiceAccountsListPage

* Fix disabled cursor on confirm button

* More behavior tests for service account page

* Temporary disable service account migration banner

* Use safe where condition

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

* Apply review suggestions

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

* Remove autofocus from search

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-06-01 09:35:16 +02:00
Adela Almasan
e18e8002c4
Canvas: add feature flag for nesting elements (#49958) 2022-05-31 12:03:34 -07:00
Marcus Efraimsson
a7813275a5
Plugins: Support headers field for check health (#49930) 2022-05-31 17:58:06 +02:00
Marcus Efraimsson
1196b4a609
Datasource: Fix allowed cookies to be forwarded as header to backend datasources (#49541)
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-05-31 17:02:58 +02:00
Joe Blubaugh
56f40bd413
Alerting: Add Go error message to warning log for screenshots. (#49870)
Makes debugging problems with alert screenshotting easier.
2022-05-31 20:56:22 +08:00
Karl Persson
f4f25d911b
add migrator to drop folder create actions that was set fromt he folder (#49878) 2022-05-31 12:45:22 +02:00
idafurjes
f69c9bd704
Split Delete expired dashboard version store (#49610)
* Split Delete expired dashboard version store

* Add method to fakes

* Fix lint

* Fix lint 2

* Use split store method in cleanup

* Add tests

* Remove DeleteExpiredVersions from sqlstore

* Fix lint

* Fix integration tests
2022-05-31 11:56:05 +02:00
kyamau
8b2a3a018d
Alerting: Chore: Fix event name in ngalert/README.md (#49829)
Fix event name from *evalContext to *evaluation as #45144.
2022-05-31 10:30:56 +08:00
Matthew Jacobson
d92625125b
Alerting: Add templated subject config to email notifier (#49742)
* Add subject templating to email notifier

* Fix linting
2022-05-30 11:55:34 -04:00
Karl Persson
d82eb5902d
AccessControl: Cleanup access control interface (#49783)
* removed unused function

* Rename interface
2022-05-30 17:48:12 +02:00
George Robinson
3b7f871bf4
Alerting: Enable Unified Alerting for open source and enterprise (#49834)
This commit enables Unified Alerting for open source and enterprise unless disabled in configuration.
2022-05-30 16:47:15 +01:00
Sergey Kostrukov
2b83cf4618
Prometheus: Predefined scopes for Azure authentication (#49557)
* Predefined scopes for Azure Prometheus

* Allow override of audience
2022-05-30 17:43:32 +02:00
Todd Treece
b8563958bd
Prometheus: Disable prometheusStreamingJSONParser by default (#49825) 2022-05-30 10:04:44 -04:00
George Robinson
47a3ddd968
Alerting: Add GetImages to ImageStore (#49717)
* Alerting: Add GetImages to ImageStore

* Use assert.ElementsMatch instead of sort.Sort
2022-05-30 09:26:16 +01:00
Joe Blubaugh
d5a327f43d
Alerting: Add tests for Slack Notifier Image Upload (#49669)
Tests that file bytes are correctly read from storage when an image is
available without a URL. Tests that not found and success cases are both
handled.
2022-05-27 10:30:44 +08:00
Ryan McKinley
a641949a05
SearchV2: improve searcher API, and include a fallback SQL based implementation (#49535) 2022-05-26 17:08:17 -07:00
Alexander Weaver
909ebcf979
Alerting: Endpoints for provisioning mute timings (#49635)
* Add validator for mute timing and make it provisionable

* Add tests to ensure prometheus validators are running and errors are propagated

* Internal API for manipulating mute timings

* Define and generate API layer

* Wire up generated code

* Implement API handlers

* Tests for golang layer

* Fix reference bug

* Fix linter and auth tests

* Resolve semantic errors and regenerate

* Remove pointless comment

* Extract out provisioning path param keys, simplify

* Expected number of paths
2022-05-26 14:24:34 -05:00
Johannes Hertenstein
16d738a03a
Alerting: Do not include button in googlechat notification if URL invalid (#47317)
* Alerting: Do not include button in googlechat notification if URL invalid

* Apply suggestions from code review

Co-authored-by: Alexander Weaver <weaver.alex.d@gmail.com>

* Alerting: Add test case for invalid external URL in googlechat notifier

Co-authored-by: Alexander Weaver <weaver.alex.d@gmail.com>
2022-05-26 11:23:39 -05:00
Sofia Papagiannaki
7cf321d7bd
Alerting: Fix swagger specification (#49273)
* Alerting: fix specification

* Update merged swagger specification
2022-05-26 14:43:59 +03:00
Jguer
ab85029969
Remove migrations from behind configs (#49415) 2022-05-26 13:21:02 +02:00
Ashley Harrison
8b509eb6dd
Notification history: Enable by default (#49502)
* remove persistNotifications feature flag

* remove unused imports
2022-05-26 12:03:04 +01:00
Joe Blubaugh
9e8efaa459
Alerting: Add stored screenshot utilities to the channels package. (#49470)
Adds three functions:
`withStoredImages` iterates over a list of models.Alerts, extracting a stored image's data from storage, if available, and executing a user-provided function.
`withStoredImage` does this for an image attached to a specific alert.
`openImage` finds and opens an image file on disk.

Moves `store.Image` to `models.Image`
Simplifies `channels.ImageStore` interface and updates notifiers that use it to use the simpler methods.
Updates all pkg/alert/notifier/channels to use withStoredImage routines.
2022-05-26 13:29:56 +08:00
Karl Persson
5caf97be40
AccessControl: Replace IsEnterprise checks with license checks (#49572) 2022-05-25 20:40:41 +02:00
Todd Treece
70b3a0a500
Prometheus: Enable prometheusStreamingJSONParser by default (#49475) 2022-05-25 12:51:09 -04:00
idafurjes
b07904fe56
Add store split for Get Dashboard version method (#49138)
* Add store split for Get Dashboard version method

* Implement dashboard version service

* Fix api tests

* Remove GetDashboarVersion from sqlstore

* Add fakes for Get dashboard version

* Fix sqlstore test

* Add Get Dashboard store test

* Add dashver service test

* Remove useless comments
2022-05-25 10:41:51 +02:00
Joan López de la Franca Beltran
73a729bbe8
Login: Fix AuthInfo update process (#49556)
* Login: Fix AuthInfo update process

* Fix GoDoc

* Add regression test for oauth info overwrite

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2022-05-25 10:00:21 +02:00
Todd Treece
94b9c524a8
Prometheus: Streaming JSON parser performance improvements (#48792) 2022-05-24 16:17:11 -04:00
sh0rez
3ca3a59079
pkg/web: remove dependency injection (#49123)
* pkg/web: store http.Handler internally

* pkg/web: remove injection

Removes any injection code from pkg/web.

It already was no longer functional, as we already only injected into
`http.Handler`, meaning we only inject ctx.Req and ctx.Resp.

Any other types (*Context, *ReqContext) were already accessed using the
http.Request.Context.Value() method.

* *: remove type mappings

Removes any call to the previously removed TypeMapper, as those were
non-functional already.

* pkg/web: remove Context.Invoke

was no longer used outside of pkg/web and also no longer functional
2022-05-24 15:35:08 -04:00
Will Browne
635fa4ab0f
Alerting: Validate alert notification UID length (#45546)
* validate alert notification UID length

* simplify-ish

* remove unused field

* whoopsie

* delete newline

* remove check

* apply feedback
2022-05-24 17:02:47 +02:00
Kristin Laemmert
debbb8d59d
sqlstore: finish removing Find and SearchDashboards (#49347)
* chore: replace artisnal FakeDashboardService with generated mock

Maintaining a handcrafted FakeDashboardService is not sustainable now that we are in the process of moving the dashboard-related functions out of sqlstore.

* sqlstore: finish removing Find and SearchDashboards

Find and SearchDashboards were previously copied into the dashboard service. This commit completes that work, removing Find and SearchDashboards from the sqlstore and updating callers to use the dashboard service.

* dashboards: remove SearchDashboards from Store interface

SearchDashboards is a wrapper around FindDashboard that transforms the results, so it's been moved out of the Store entirely and the functionality moved into the Dashboard Service's search implementation.

The database tests depended heavily on the transformation, so I added testSearchDashboards, a copy of search dashboards, instead of (heavily) refactoring all the tests.
2022-05-24 09:24:55 -04:00
Kat Yang
50c2b4682a
Chore: Rename integration tests (#49438)
* Chore: Rename integration tests

* Remove one Integration

Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
2022-05-24 11:04:03 +02:00
Joe Blubaugh
a0193c248f
Alerting: Add entries to ngAlert changelog for screenshots. (#49457)
Notes the PRs that added the feature.
2022-05-24 16:50:07 +08:00
Joan López de la Franca Beltran
3e4b4dba46
Encryption: Enable envelope encryption by default (#49301)
* Encryption: Enable envelope encryption by default

* Stop relying on feature toggles from settings (deprecated)

* Database encryption docs (envelope encryption)

* Remove deprecated (and no longer used) FT

* Apply suggestions from code review

Co-authored-by: Tania <yalyna.ts@gmail.com>
2022-05-24 10:34:47 +02:00
Eric Leijonmarck
cbf71fbd7f
Serviceaccounts: Do not display service accounts assigned to team (#48995)
* Add IsServiceAccount to query

* test for excluding service accounts in query

* align test

* test update

* added logging

* should fix tests

* moved test to bottom

* add back setup function

* Remove IsServiceAccount from query

Instead use false for is_service_account
and when the time comes to implement service accounts
for team. we deal with it

* missed teamtest

* formatting
2022-05-24 16:52:39 +10:00
Alexander Emelin
1e7e149ed6
search: close unused reader and writer on re-indexing (#49458) 2022-05-24 09:42:21 +03:00
Alexander Weaver
a92f85a87b
Alerting: Factor out shared code for working with configs in provisioning package (#49419)
* Factor out shared code for working with configs

* Refactor in notification policies and contact points

* Better file ordering

* Address feedback
2022-05-23 18:16:03 -05:00
Alexander Weaver
2ba4f7ed7d
Alerting: Attach image URLs to Google Chat notifications. (#49445)
* Add a test card to see what styles look like

* Add text and image cards

* Address feedback
2022-05-23 18:15:44 -05:00
Alexander Weaver
d7c65d3323
Alerting: Attach image URLs or upload files to Discord notifications. (#49439)
* Images in discord

* Drop duplicated field initialization

* Fix tests

* Use the proper context
2022-05-23 17:28:16 -05:00
Alexander Emelin
7411c81e7f
Search: use prefix search for queries exceeding ngram filter max length (#49409) 2022-05-23 14:33:56 -07:00
Alexander Weaver
ac8951f689
Alerting: Add support for documenting which alerting APIs are stable (#49018)
* Support for documenting stable vs unstable alerting routes

* empty commit, restart drone

* Touch-up references in root makefile and drop trailing escape newline

* Rebase and regenerate

* Extend README with docs for this change
2022-05-23 14:08:27 -05:00
Ryan McKinley
8af587e7ba
Search: support alpha + and enterprise sorting values (#49362) 2022-05-23 10:05:15 -07:00
Ryan McKinley
9a59ccd644
Search: remove internal ID from bluge index (#49205)
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-05-23 09:22:35 -07:00
Kristin Laemmert
8c753999df
chore: replace artisanal FakeDashboardService with generated mock (#49276)
* chore: replace handmade FakeDashboardService with generated mock

Maintaining a handcrafted FakeDashboardService is not sustainable now that we are in the process of moving the dashboard-related functions out of sqlstore.

* remove dialect global variable
2022-05-23 11:14:27 -04:00
Joe Blubaugh
ccd160a75e
Alerting: Add image url or file attachment to email notifications. (#49381)
If an image token is present in an alert instance, the email notifier will attempt to find a public URL for the image token. If found, it will add that to the email as the `ImageLink` field. If only local file data is available, the notifier will attach the file to the outgoing email using the `EmbeddedImage` field.
2022-05-23 23:08:28 +08:00
Jguer
3250bf6b2b
AccessControl: Add migration for seeding managed inherited permissions (#49337)
* AccessControl: Add migration for seeding managed inherited permissions

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

* AccessControl: move to single file

* AccessControl: Add tests for managed permission migration

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

* AccessControl: Ensure no duplicate insertion

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

* Remove commented code

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

* Add code migration constant

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

* Ensure DB is clean between tests

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

* Update pkg/services/sqlstore/migrations/accesscontrol/managed_permission_migrator.go

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-05-23 16:50:10 +02:00
Joe Blubaugh
307e33614e
Alerting: Add image_urls to OpsGenie notification details. (#49379)
Adds an array of image_urls to the OpsGenie details field in a message, if image urls are available.

```json
{
  "message": "Alert with Images!",
  "details": {
    "image_urls": ["http://www.example.com"]
  }
}
```
2022-05-23 22:41:29 +08:00
Yuriy Tseretyan
3dfafbadef
Alerting: Fix access to alerts for viewer with editor permissions when RBAC is disabled (#49270)
* Add folder edit permission for users with Viewer role
* relax permissions required to create an alert when RBAC is disabled
2022-05-23 09:58:20 -04:00
Joe Blubaugh
4ea0b39db1
Alerting: Add Image URLs to Microsoft Teams notifier. (#49385)
If there are screenshot images with URLs, they will be attached to the
Microsoft teams notification in the first sections, as a slice of image
objects.
2022-05-23 21:53:36 +08:00
Jguer
6891bbf03c
ServiceAccounts: Add identifiable token prefix to service account tokens (#49011)
* Add prefixed API key gen.

* Retrieve API Key by hash

* Handle prefixed API keys for login

* Add placeholder key generator

* fix spelling

* add get by hash sqlstore test

* reformat query

* quote usage of reserved keyword key

* use constant

* improve error handling and pre-select key type

Co-authored-by: Victor Cinaglia <victor@grafana.com>

* nits

Co-authored-by: Victor Cinaglia <victor@grafana.com>
2022-05-23 13:14:38 +02:00
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