Commit Graph

7241 Commits

Author SHA1 Message Date
ying-jeanne
a8eef45a44
Logger migration from log15 to gokit/log (#41636)
* migrate log15 to gokit/log

* fix console log

* update some unittest

* fix all unittest

* fix the build

* Update pkg/infra/log/log.go

Co-authored-by: Yuriy Tseretyan <tceretian@gmail.com>

* general type vector

* correct the level key

Co-authored-by: Yuriy Tseretyan <tceretian@gmail.com>
2022-01-06 22:28:05 +08:00
J Guerreiro
6bbf85e2e9
AccessControl: verify metadata map is not null (#43743) 2022-01-06 11:54:51 +01:00
Travis Patterson
20b3b2a448
Forward oauth tokens after prometheus datasource migration (#43686)
* create the prom client

* implement lru cache of prometheus clients based on auth headers

* linter
2022-01-05 13:55:55 -07:00
Gabriel MABILLE
92c568e9f7
AccessControl: Remove unused error from GetResourcesMetadata (#43710)
* AccessControl: Remove unused error from GetResourcesMetadata

Co-authored-by: J Guerreiro <joao.guerreiro@grafana.com>
2022-01-05 17:24:14 +01:00
Alexander Weaver
fd583a0e3b
Alerting: Allow customization of Google chat message (#43568)
* Allow customizable googlechat message via optional setting

* Add optional message field in googlechat contact point configurator

* Fix strange error message on send if template fails to fully evaluate

* Elevate template evaluation failure logs to Warn level

* Extract default.title template embed from all channels to shared constant
2022-01-05 09:47:08 -06:00
Eric Leijonmarck
0aa905bb1f
Serviceaccounts: feat - tabview for serviceaccounts (#43573) 2022-01-05 15:32:38 +01:00
Ivana Huckova
d7d6c10664
Prometheus: Fill missing steps with null values (#43622)
* Prometheus: Add empty points when data points missing

* Remove newline

* Add comments

* Improve/Fix test

* Remove unused variable
2022-01-05 11:40:32 +01:00
Gilles De Mey
837925390f
fix: pass OrgId to alertNotification model (#43678)
fixes #43214
2022-01-05 10:19:45 +01:00
J Guerreiro
056e143664
AccessControl: Present user edit actions according to AC metadata (#43602)
* AccessControl: Add user metadata to user detail view

* AccessControl: Do not present delete or disable buttons based on ac metadata in admin/users

* AccessControl: do not allow password changing or user editing without permission

* AccessControl: Fetch global:users scope for admin

* AccessControl: optimize org.user metadata fetch

* Chore: early return if ac metadata is not available
2022-01-05 09:59:17 +01:00
Ryan McKinley
b09d498484
Import: fix dashboard imports with expressions (#43630) 2022-01-04 08:42:18 -08:00
Jeremy Price
42ccc44eca
Accesscontrol: Apply FGAC to APIKey endpoints (#42659)
* Move definitions to serviceaccounts

* Use constant names, add scope to delete

* Add descriptions to roles

* Rename roles
2022-01-04 15:37:40 +01:00
Travis Patterson
c4c05a5b71
refactor promethueus package into sub packages (#43634) 2022-01-04 07:22:33 -07:00
Emil Tullstedt
df4e9ca12b
Datemath: Support fiscal years (#43558) 2022-01-04 13:56:34 +01:00
Karl Persson
2425828a0b
quote reserved keyword (#43652) 2022-01-04 13:35:52 +01:00
Selene
bdbd199910
Remove unnecesary joins from queries (#43626) 2022-01-04 13:04:02 +01:00
Karl Persson
ee690a7bb0
Add org_id in join (#43648) 2022-01-04 11:13:45 +01:00
idafurjes
65e60759fb
Rename AddEventListenerCtx to AddEventListener and PublishCtx to Publish (#43566) 2022-01-04 09:36:01 +01:00
J Guerreiro
a0cf57b5b8
AccessControl: Reduce tone of access error (#43601) 2022-01-04 09:28:55 +01:00
Kyle Brandt
f17fb76b5e
SSE: Add is_nan() and other like functions and allow '_' in func names (#43555)
* SSE: Add is_nan() and allow '_' in func names

is_null() infn(), is_inf(), is_number()
2021-12-29 11:40:52 -05:00
idafurjes
8e6d6af744
Rename DispatchCtx to Dispatch (#43563) 2021-12-28 17:36:22 +01:00
idafurjes
7936c4c522
Rename AddHandlerCtx to AddHandler (#43557) 2021-12-28 16:08:07 +01:00
Joan López de la Franca Beltran
80e0dd74d2
Encryption: Increase context timeout on flaky test (#43553) 2021-12-28 13:34:45 +01:00
idafurjes
56c3875bb9
Chore: Remove context.TODO (#43458)
* Remove context.TODO() from services

* Fix live test
2021-12-28 10:26:18 +01:00
Alexander Weaver
56b3dc5445
Alerting: Allow configuration of non-ready alertmanagers (#43063)
* Create API test for overwriting invalid alertmanager config

* Avoid requiring alertmanager readiness for config changes

* AlertmanagerSrv depends on functionality rather than concrete types

* Add test for non-ready alertmanagers

* Additional cleanup and polish

* Back out previous integration test changes

* Refactor of tests incorrectly caused a test to become redundant

* Use pre-existing fake secret service

* Drop unused interface

* Test against concrete MultiOrgAlertmanager re-using fake infra from other tests

* Fix linter error

* Empty commit to rerun checks
2021-12-27 17:01:17 -06:00
Alexander Weaver
9abdaf251f
Alerting: Fix global state sensitivity in notifier channel tests (#43508) 2021-12-27 11:58:17 -06:00
Joan López de la Franca Beltran
83bc445d3e
Encryption: Fix DEKs cache (#43129)
* Encryption: Fix DEKs cache

* Clarify tests
2021-12-27 18:04:47 +01:00
Alex Khomenko
3b4a4be3c6
Feature highlights: add setting toggle (#43394)
* Feature highlights: add toggle setting

* Settings: Use provider for 'feature_highlights' section

* Fix frontendsettings API tests

* Document the toggle

Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
2021-12-24 10:49:52 +02:00
Ryan McKinley
4233a62aeb
DashboardPreviews: add dashboard previews behind feature flag (#43226)
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
Co-authored-by: Artur Wierzbicki <artur@arturwierzbicki.com>
2021-12-23 09:43:53 -08:00
Karl Persson
0ace9695a6
Access control: Add optional hooks (#43372)
* Add optional OnSet hooks
2021-12-23 10:10:06 +01:00
J Guerreiro
3d4fafcf70
AccessControl: Add access control metadata to org user DTOs (#43362)
* AccessControl: Add access control metadata to OrgUserDTO

* AccessControl: get User AC metadata

* AccessControl: return User Access Control metadata when requested
2021-12-22 18:46:33 +01:00
Marcus Efraimsson
7d3bdb6d1b
Plugins: Set backend metadata property for core plugins (#43349)
Ref #42648
Ref #42781
2021-12-22 17:59:26 +01:00
J Guerreiro
a1b8b5d123
Usage stats: Count API keys (#42883)
* Stats: add api key count to usage stats

* Chore: correctly capitalize struct member
2021-12-22 17:37:45 +01:00
David Henderson
575eb68828
CloudWatch: Add Missing Elasticache Host-level metrics (#43455)
Add missing host-level Elasticache metrics from https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheMetrics.HostLevel.html

Follows from https://github.com/grafana/grafana/pull/43336#issuecomment-999367311
2021-12-22 14:02:52 +01:00
idafurjes
b8852ef6a3
Chore: Remove context.TODO() (#43409)
* Remove context.TODO() from services

* Fix live test

* Remove context.TODO
2021-12-22 11:02:42 +01:00
Karl Persson
2409d8dc1f
check the value of the feature toggle (#43433) 2021-12-22 10:05:53 +01:00
Jean-Philippe Quéméner
ffc72aa255
Alerting: fix gosec warning that is not valid (#43425) 2021-12-21 19:47:47 +01:00
Daniel Lee
93de61f690
fix for CWE-89 (#43407)
The sqlOrArgs unpacking seems to confuse CodeQL. Trying something simpler
2021-12-21 19:04:56 +01:00
Karl Persson
b3d5a607d4
Access Control: Add option to filter only managed permissions (#43371)
* Add option to filter only managed permissions
2021-12-21 14:22:54 +01:00
Tania B
c1be17bec7
Chore: Add Google Cloud KMS dependency (#43211)
* Encryption: Add Google Cloud KMS dependency

* Change version
2021-12-21 14:15:27 +02:00
Siavash Safi
4c4322f717
CloudWatch: Add all ElastiCache Redis Metrics (#43336)
Add all missing Redis ElastiCache metrics.
https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheMetrics.Redis.html

Signed-off-by: Siavash Safi <siavash.safi@gmail.com>
2021-12-21 09:13:41 +01:00
idafurjes
ff3cf94b56
Chore: Remove context.TODO() from services (#42555)
* Remove context.TODO() from services

* Fix live test
2021-12-20 17:05:33 +01:00
Carl Bergquist
f373588810
setting: configure toggles as true/false instead of array (#43326)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-12-20 15:33:11 +01:00
Tania B
0dc86bf7f4
Chore: Move default encryption provider to kmsproviders package (#43331) 2021-12-20 12:47:49 +02:00
Gábor Farkas
1879a6855e
prometheus: respect the http-method data source setting (#42753)
* prometheus: respect the http-method data source setting

* removed forgotten if-true section

* refactored json-check
2021-12-20 11:27:18 +01:00
Karl Persson
c3ca2d214d
Access control: Refactor managed permission system to create api and frontend components (#42540)
* Refactor resource permissions
* Add frondend components for resource permissions

Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2021-12-20 09:52:24 +01:00
Ilya Stoliar
9cf5623918
CloudWatch: Add Data Lifecycle Manager metrics and dimension (#43310) 2021-12-20 09:48:07 +01:00
Artur Wierzbicki
197f4f81f2
#41993: make it possible to create N random60hz channels (#43295) 2021-12-17 23:42:37 +04:00
Sofia Papagiannaki
c4aaf5f9d1
API: prevent provisioned dashboard from being updated (#41894) 2021-12-17 10:31:52 -05:00
Alexander Zobnin
2c0f961c59
OAuth: Fix forwarding id token to the data source (#43204) 2021-12-17 03:34:16 -05:00
Yuriy Tseretyan
1a762083d7
Alerting: make alert rule routine evaluation control be thread-safe (#41220)
* change registry.delete to return deleted struct
* use pointer to alertRuleInfo instead copying.
* do not access evaluation channel when routine is stopped
* remove stopCh and use context cancellation
* do not return ctx.Err when channel is cancelled because it cancels all other routines
* make alertRuleInfo fields and functions package private
2021-12-16 14:52:47 -05:00
Ryan McKinley
2754e4fdf0
Expressions: use datasource model from the query (#41376)
* refactor datasource loading

* refactor datasource loading

* pass uid

* use dscache in alerting to get DS

* remove expr/translate pacakge

* remove dup injection entry

* fix DS type on metrics endpoint, remove SQL DS lookup inside SSE

* update test and adapter

* comment fix

* Make eval run as admin when getting datasource info

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

* fmt and comment

* remove unncessary/redundant code

Co-authored-by: Kyle Brandt <kyle@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2021-12-16 13:51:46 -03:00
Jeremy Price
13fdc5231d
AccessControl: upgrade apikeys by adding service accounts (#42425)
Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>

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

* Change default options for cloned service account

* Run in background

* Add endpoint to upgrade api keys to service accounts
2021-12-16 14:28:16 +01:00
Jean-Philippe Quéméner
b605340668
Alerting: log errors happening in the API on server side (#43192)
* Alerting: log errors happening in the API on server side

* adapt tests to reflect changed payload
2021-12-16 13:33:10 +01:00
Gilles De Mey
bb3b5c10e7
Alerting: fix WeCom channel notifier test assertion (#43173) 2021-12-15 19:45:12 +01:00
Gilles De Mey
cbbbb505b4
Alerting: use HTML-safe characters for the default template (#43148) 2021-12-15 17:57:08 +01:00
smallpath
aec14cba42
Alerting: Support WeCom as a contact point type (#40975)
* add wecom notifier

* fix backend lint

* fix alerting channel test

* update wecom doc

* update notifiers

* update wecom notifier test

* Apply suggestions from code review

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* unify wecom alerting

* fix backend lint

* fix front lint

* fix wecom test

* update docs

* Update pkg/services/ngalert/notifier/channels/wecom.go

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* Update docs/sources/alerting/old-alerting/notifications.md

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* Update docs/sources/alerting/old-alerting/notifications.md

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* Update docs/sources/alerting/old-alerting/notifications.md

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* remove old wecom notifier

* remove old notifier doc

* fix backend test

* Update docs/sources/alerting/unified-alerting/contact-points.md

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* fix doc style

Co-authored-by: gotjosh <josue.abreu@gmail.com>
2021-12-15 16:42:03 +00:00
Gabriel MABILLE
c7cabdfd6f
AccessControl: Add accesscontrol metadata to datasources DTOs (#42675)
* AccessControl: Provide scope to frontend

* Covering datasources with accesscontrol metadata

* Write benchmark tests for GetResourcesMetadata

* Add accesscontrol util and interface

* Add the hasPermissionInMetadata function in the frontend access control code

* Use IsDisabled rather that performing a feature toggle check

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2021-12-15 12:08:15 +01:00
Ryan McKinley
c0ff685d3b
Live: support query execution with live RPC (#43118)
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2021-12-14 18:38:20 +01:00
Alexander Emelin
f4cc353225
Live: proxy subscribe data for subscribe and runstream plugin calls (#42824)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-12-14 20:12:00 +03:00
Karl Persson
9558c09a7c
Access Control: Store permissions on SignedInUser (#43040)
* add permission structure to signedinuser

* add middleware to load user permissions into signedinuser struct

* apply LoadPermissionsMiddleware to http server

* check for permissions in signedinuser struct

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-12-14 16:05:59 +01:00
Will Browne
e4ba5f17dd
add core plugins thru store (#43085) 2021-12-14 15:22:40 +01:00
Leonard Gram
5d18834deb
OAuth: persisting the id token (#42938)
* OAuth: persisting the id token

* OAuth: verifies that the idtoken gets persistet in the database
2021-12-14 15:22:10 +01:00
Eric Leijonmarck
4a3961400a
Serviceaccounts: create serviceaccount api (#42150)
* WIP

* wip

* wip

* wip

* refactor: new return of the create service accoutn

* refactor: change to have correct role

* refactor: ability to create service accounts

* make public

* refactor: make ints instead

* refactor: remove location sprintf

* refactor: added back named constants
2021-12-14 14:39:25 +01:00
Shirley
21656a0491
Remove reference to legacydata package (#43075)
* Remove reference to legacydata package

* Change from and to times
2021-12-14 12:58:31 +01:00
Will Browne
155487bfb0
Plugins: Add typed models for frontend settings data sources and panels (#42062)
* add model for data source

* add model for panels

* add omitempty

* make consistent with main

* dont emit bools

* resolve conflicts

* remove file

* remove file

* update field name

* always pass jsonData

* minify the changes

* remove dupe line
2021-12-14 11:16:13 +01:00
Will Browne
6c4555265a
Plugins: Update client to use SDK resource contract (#42888)
* client uses sdk resource handler

* apply pr feedback
2021-12-14 11:15:49 +01:00
Erik Sundell
043680371f
add all new es metrics (#43034) 2021-12-14 10:12:39 +01:00
Yuriy Tseretyan
35b0067650
Populate missing UID of provisioned data source only for new records (#42999)
* defer updating empty UID to insert command
* change logging to use the command
2021-12-13 14:14:39 -05:00
Yuriy Tseretyan
b63595b47f
Alerting: fix sqlstore.GetFolderByTitle to search for folder (#42898)
* a test to reproduce the bug
2021-12-13 13:59:20 -05:00
Ieva
2ef071e728
log provisioning errors (#43041) 2021-12-13 16:50:02 +01:00
Serge Zaitsev
f5802878f1
Chore: Move remaining web framework code to pkg/web, remove macaron binding module (#43018)
* remove macaron binding dependency

* completely purge macaron binding

* move everything to pkg/web

* remove non-go files from pkg/web

* clean up leftovers of macaron imports

* make linter happy
2021-12-13 15:56:14 +01:00
Yuriy Tseretyan
1db9b1e6a9
Improve bridge for Alertmanager logger (#42958)
* Implement go-kit/log.Logger for internal logger.
2021-12-13 09:41:53 -05:00
Torkel Ödegaard
0e88f5db85
AppPlugins: Support app plugins with only default nav (#43016) 2021-12-13 14:06:15 +01:00
Sofia Papagiannaki
c6483cd8ed
Alerting: Refactor API handlers to use web.Bind (#42600)
* Alerting: Refactor API handlers to use web.Bind

* lint
2021-12-13 09:22:57 +01:00
Marcus Efraimsson
d6ec6f8ad2
Backport fix to main (#42979)
* fixes

(cherry picked from commit a2c386915ce11b9422f4af8ae181eaa1a22bc5c3)
(cherry picked from commit 06706efbbe)

* fix regex

(cherry picked from commit a259213a3badc9618e969f2c8db0a0143f00faee)
(cherry picked from commit 1d7105c095)

* lint (#42970)

(cherry picked from commit afb9e8e5f3)

Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: malcolmholmes <42545407+malcolmholmes@users.noreply.github.com>
2021-12-10 16:10:04 +01:00
Carl Bergquist
f9481527de
Macaron: Prevent WriteHeader invalid HTTP status code panic (#42973)
(cherry picked from commit 92005159c89f848ab8b8435e0c8751599e2e8aff)

Co-authored-by: Todd Treece <todd.treece@grafana.com>
2021-12-10 13:54:12 +01:00
Gábor Farkas
a4cc1f6b39
loki: alerting: handle curly-braces-style variables (#42933) 2021-12-09 15:16:01 +01:00
Ivana Huckova
2655be61b6
Prometheus: Interpolate curly brackets syntax variable (#42927) 2021-12-09 14:37:24 +01:00
Gábor Farkas
3232ae08c0
loki: removed unused variable (#42909) 2021-12-09 13:16:52 +01:00
Dimitris Sotirakis
c798c0e958
Security: Fix directory traversal issue (#42846)
* security: fix dir traversal issue

(cherry picked from commit 00e38ba555)

* Improve comments and error message.

Co-authored-by: Kyle Brandt <kyle@grafana.com>
2021-12-07 19:15:53 +02:00
Isabella Siu
a2ad0a0fb6
CloudMonitor: Iterate over pageToken for resources (#42546) 2021-12-07 08:54:50 -05:00
Gábor Farkas
6686f8c345
loki: rename ResponseModel to QueryModel (#42794) 2021-12-07 07:57:52 +01:00
William Assis
eab0ba8716
Analytics: RudderStack custom URLs to fetch SDK and Config (#41988)
* Add config options to provide custom URL to fetch Rudderstack SDK and Config

* Add new entries to defaults.ini

* Update docs
2021-12-06 09:42:29 -05:00
Ivana Huckova
21fe78302b
Prometheus: Fix passing of custom params when running queries (#42728)
* Prometheus: Fix passing of custom params

* Remove prints
2021-12-03 16:28:05 +01:00
gotjosh
bdab1d1f1f
Fix flaky tests in several notifiers (#42668)
* Fix flaky tests in several notifiers

- Non-mocked time in sensu go tests
- Close server in Slack tests
- Use a mutex for writing responses in the fake slack server

* Remove mutex at the fake slack server
2021-12-03 12:34:31 +00:00
George Robinson
c932dc959c
Alerting: Add Ref ID to DatasourceNoData and DatasourceError alerts (#42630) 2021-12-03 09:55:16 +00:00
idafurjes
c80e7764d8
Chore: Remove Dispatch and AddHandler (#42603)
* Remove Dispatch

* Remove context.TODO()

* Remove AddHandler and Dispatch
2021-12-02 18:08:59 +01:00
David Parrott
a53b78df0c
Alerting: improve error on failure to remove query referenced by legacy alerting (#42169)
* Improve error and add test

* praise the linter!

* pr feedback

* guard against nil

* getters and setters

* Use IsEnabled instead of accessing struct
2021-12-02 07:41:24 -08:00
Marcus Efraimsson
54fa7b57fe
Chore: Fix flaky serverlock integration test (#42633) 2021-12-02 12:53:21 +01:00
Piotr Jamróz
bb24e8d578
Chore: Report frontend metrics for JS/CSS load time (#42421)
* Report frontend metrics for js/css load time

* Add FCP metric

* Change comment

* Simplify reporting frontend metrics
2021-12-02 09:34:39 +01:00
idafurjes
9880a843ed
Add context to notifications (#42578) 2021-12-01 17:56:08 +01:00
Joan López de la Franca Beltran
5183cc4dc4
Store 'alertmanager_configuration' as JSON string instead of raw bytes (#42443) 2021-12-01 17:49:57 +01:00
idafurjes
d993b12415
Add interface Tracer, add Opentelemetry (#41963)
* Add interface Tracer, add Opentelemetry

* Fix lint

* Fix failing tests and return error if config not parsed fo opentelemetry

* Update defaults.ini

Add comment with jaeger url

* go mod tidy

* Remove comments that are not needed

* Move OpentracingSpan to tracing.go

* Add opentelemetry to sample.ini
2021-12-01 17:05:08 +01:00
Jesse Weaver
be578e5700
Improve handling of old/slow-to-start remote renderer (#40492)
* Assume the remote renderer is old if it returns 404 to the version endpoint

* Retry fetch of remote image renderer version on failure

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2021-12-01 08:58:43 -07:00
idafurjes
e6123bc3ef
Replace AddHandler with AddHandlerCtx in tests (#42585) 2021-12-01 15:43:31 +01:00
gotjosh
5b64c4f684
Alerting: Fix panic while proxying 4xx responses of requests to cortex/loki (#42570)
Fixes a panic that would ocurr as we proxy 4xx responses. When this happens and the content type of the response is JSON we try to check if the response has a "message" key. Then, we assume that the key will contain a value of string but we don't take into account that this value can potentially be `null`.

This adds a type assertion check to to this assumption so that we can keep the original JSON body as the response if we're unable to extract an `message`.
2021-12-01 13:53:29 +00:00
Leonard Gram
c6021c8b4f
Build: building a local docker image using build-docker-dev no longer supported (#42563) 2021-12-01 14:34:28 +01:00
Yuriy Tseretyan
9139f61105
Alerting: Update alert rule migration to use expanded queries (#42493)
* move targetData to target

* use constants instead of literals.

* Update comments and add tests

Co-authored-by: gotjosh <josue.abreu@gmail.com>
2021-12-01 11:45:27 +00:00
gotjosh
357e9ed1ea
Alerting: Fix Annotation Creation when the alerting state changes (#42479)
* Fix Annotation creation
- Remove validation of panelID, now annotations are created irrespective on whether they're attached to a panel or not.
- Alwasy attach the annotation to an AlertID

* Fix annotation creation

* fix tests
2021-12-01 11:04:54 +00:00
Sofia Papagiannaki
9c7b52fd36
Alerting: Fix API specification (#42282)
* Alerting: Fix API specification
2021-11-30 20:55:54 +01:00
ying-jeanne
e13e6a7bd7
fix error code for delete folder (#42470) 2021-11-30 21:07:04 +08:00
Joan López de la Franca Beltran
690ffdff56
Settings: Fix handling (#42497)
* Settings: Fix handling
2021-11-30 11:28:52 +01:00
Erik Sundell
bab78a9e64
CloudWatch: Add support for AWS Metric Insights (#42487)
* add support for code editor and builder

* refactor cloudwatch migration

* Add tooltip to editor field (#56)

* add tooltip

* add old tooltips

* Bug bash feedback fixes (#58)

* make ASC the default option

* update sql preview whenever sql changes

* don't allow queries without aggregation

* set default value for aggregation

* use new input field

* cleanup

* pr feedback

* prevent unnecessary rerenders

* use frame error instead of main error

* remove not used snapshot

* Use dimension filter in schema picker  (#63)

* use dimension key filter in group by and schema labels

* add dimension filter also to code editor

* add tests

* fix build error

* fix strict error

* remove debug code

* fix annotation editor (#64)

* fix annotation editor

* fix broken test

* revert annotation backend change

* PR feedback (#67)

* pr feedback

* removed dimension filter from group by

* add spacing between common fields and rest

* do not generate deep link for metric queries (#70)

* update docs (#69)

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>

* fix lint problem caused by merge conflict

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2021-11-30 10:53:31 +01:00
Ivan Anselmi
cf3105e5be
MSSQL: Change regex to validate Provider connection string (#40248)
* Change the regex to allow to specified other connection attribute for MSSQL connection like ApplicationIntent property

* Docs update

* docs update

* some tests added

* formatting

* Change the regex to allow to specified other connection attribute for MSSQL connection like ApplicationIntent property

* Docs update

* docs update

* some tests added

* formatting

* docs and formatting

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-11-30 09:28:48 +01:00
Yuriy Tseretyan
005c8f8894
Alerting: Disable unified alerting by default in Enterprise Grafana (#42476)
* fallback to enable false if Enterprise is true

* anyBoolean
2021-11-29 20:51:15 +01:00
Santiago
a21d1e50f1
avoid template execution errors on missing values (#41617) 2021-11-29 15:26:51 -03:00
Serge Zaitsev
95831e9be0
Fix: Restore data binding in the create dashboard handler 2021-11-29 19:05:20 +01:00
Will Browne
9c9e79da4f
only preload app plugins (#42434) 2021-11-29 18:26:04 +01:00
Alexander Emelin
7034173ef5
Live: fix closing ws conns for push endpoints (#42447) 2021-11-29 19:22:42 +03:00
Alexander Zobnin
becfd776c3
OAuth: Forward id token to the data source (#42422)
* OAuth: Forward id token to the data source

* Add tests

* Forward id token in legacy API

* Check if id_token is string or not
2021-11-29 15:40:05 +01:00
Tania B
58978dcf96
Encryption: Add usage stats to secrets service (#42437)
* Encryption: Add usage stats to secrets service

* Sort imports
2021-11-29 16:35:15 +02:00
Will Browne
e440796cb3
only load CSV when data exists (#42441) 2021-11-29 15:21:18 +01:00
idafurjes
a65e0be110
Replace AddEventListener with AddEventListenerCtx and Publish with PublishCtx (#42284) 2021-11-29 14:23:24 +01:00
Marcus Efraimsson
8927a3ca20
Chore: Query endpoint refactor (#41637)
Get rid of using legacydata.RequestHandler in HTTPServer, /api/tsdb/query and pkg/expr 
with the goal of deprecating /api/tsdb/query and remove it completely eventually. This is 
the first step of cleaning up the HTTP API query endpoint.

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2021-11-29 14:21:54 +01:00
Ivana Huckova
0b5d7067f9
Prometheus: Fix range variables interpolation for time ranges smaller than 1 second (#42242)
* Prometheus: Fix precision for queries with < 1s timeRange

* Update pkg/tsdb/prometheus/time_series_query.go

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
2021-11-29 12:41:23 +01:00
Serge Zaitsev
d9cdcb550e
Chore: Refactor api handlers to use web.Bind (#42199)
* Chore: Refactor api handlers to use web.Bind

* fix comments

* fix comment

* trying to fix most of the tests and force routing.Wrap type check

* fix library panels tests

* fix frontend logging tests

* allow passing nil as a response to skip writing

* return nil instead of the response

* rewrite login handler function types

* remove handlerFuncCtx

* make linter happy

* remove old bindings from the libraryelements

* restore comments
2021-11-29 10:18:01 +01:00
Artur Wierzbicki
1f237d0193
#42174: fix: fill 'field.name' in the auto-added Time field (#42301) 2021-11-26 23:52:01 +04:00
gotjosh
dd5a2e5128
Alerting: Clear alerting rule evaluation errors after intermittent failures (#42386)
* Alerting: Clear alerting rule evaluation errors after intermittent failures

When an alert transitioned in a way that `alerting -> error -> (alerting|nodata)`, the error provided by the `error` state would never be cleared thus the API and UI would show the health as an error.
2021-11-26 17:58:19 +00:00
idafurjes
725dbf8d95
Chore: Add context to datasource service (#42294)
* Add context to datasource service

* Adjust wire for ShouldBeReported method

* Replace inTransactionCtx
2021-11-26 18:10:36 +01:00
idafurjes
ac6867c3bb
Chore: Add context to authinfo (#42096)
* Add context to authinfo

* Replace Dispatch with DispatchCtx
2021-11-25 14:22:40 +01:00
George Robinson
1b26d4d88e
Alerting: Create DatasourceError alert if evaluation returns error (#41869)
* Alerting: Create DatasourceError alert if evaluation returns error

* Alerting: Add docs for DatasourceError alert

* Alerting: Fix DatasourceError alert does not have dashboard_uid label

* Alerting: Add break when datasource_uid found

* Alerting: Update TestProcessEvalResults
2021-11-25 11:46:47 +01:00
George Robinson
1e5b0e64ac
Alerting: Add comments to ScheduleService interface (#42228) 2021-11-25 10:12:04 +00:00
Sriram
70bc0b86e2
TestDataDB: Raw frame input (#42209)
* test datasource raw-frame scenario added

* typo fix in doc
2021-11-25 09:14:34 +00:00
Armand Grillet
6523486122
Alerting: Make Unified Alerting enabled by default for those who do not use legacy alerting (#42200)
* update AlertingEnabled and UnifiedAlertingSettings.Enabled to be pointers
* add a pseudo migration to fix the AlertingEnabled and UnifiedAlertingSettings.Enabled if the latter is not defined
* update the default configuration file to make default value for both 'enabled' flags be undefined

Misc
* update Migrator to expose DB engine. This is needed for a ualert migration to access the database while the list of migrations is created.
* add more verbose failure when migrations do not match

Co-authored-by: gotjosh <josue@grafana.com>
Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2021-11-24 14:56:07 -05:00
Peter Holmberg
a5436b4435
Alerting: Move Alert Groups tab to end of tabs (#42241)
* move alertgroups tab to end of tabs

* more reorder
2021-11-24 18:28:19 +01:00
Gábor Farkas
24d4c8a9d1
Loki: alerting: handle variables like __interval and __range (#42126) 2021-11-24 16:56:53 +01:00
Tania B
4014891971
Encryption: Cleanup and add logging (#42084)
* Encryption: Add more logs

* Add logging and checks

* Removed unused methods from secrets service

* Refactor and update tests

* Address review feedback
2021-11-24 15:01:44 +02:00
Jeremy Price
a145ec37bb
Handle request service account when not enabled (#42122)
* Handle request service account when not enabled
2021-11-24 11:56:55 +01:00
Gábor Farkas
fe84454bb0
loki: alerting: simplified config (#42147)
* loki: alerting: simplified config

* adjusted config handling
2021-11-24 11:52:33 +01:00
n2N8Z
eaf46600c4
CloudWatch: Add missing AWS/Events metrics. (#42164)
* Add missing InvocationsFailedToBeSentToDlq metric.

* Add missing InvocationsSentToDlq metric.
2021-11-24 11:35:18 +01:00
Gabriel MABILLE
eea0e6a6c0
AccessControl: Renamed orgs roles, removed fixed:orgs:reader introduced in beta1 (#42049)
* AccessControl: Rework Orgs roles

* Increase version for name migration

* Update pkg/api/roles.go

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

* Use maintainer instead of manager

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2021-11-24 10:08:42 +01:00
Eric Leijonmarck
9c11040c3e
Serviceaccounts: Filtering service accounts from user queries (#41410)
* Add extra fields to OSS types to support enterprise

* WIP service accounts

* Update public/app/features/api-keys/ApiKeysForm.tsx

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>

* Create a service account at the same time as the API key

* Use service account credentials when accessing API with APIkey

* Throw better error

* Use Boolean for "create service account button"

* Add GetRole to service, merge RoleDTO and Role structs

This patch merges the identical OSS and Enterprise data structures, which improves the code for two reasons:

1.  Makes switching between OSS and Enterprise easier
2.  Reduces the chance of incompatibilities developing between the same functions in OSS and Enterprise

* Start work cloning permissions onto service account

* If API key is not linked to a service account, continue login as usual

* Fallback to old auth if no service account linked to key

* Commented

* Add CloneUserToServiceAccount

* Update mock.go

* Put graphical bits behind a feature toggle

* Start adding LinkAPIKeyToServiceAccount

* Update pkg/models/user.go

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

* Update pkg/api/apikey.go

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

* Update pkg/api/apikey.go

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

* Finish LinkAPIKeyToServiceAccount

* Update comment

* Handle api key link error

* Update pkg/services/sqlstore/apikey.go

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

* Feature toggle

* Update pkg/services/accesscontrol/accesscontrol.go

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

* Not needed (yet)

* Better error messages for OSS accesscontrol

* Set an invalid user id as default

* ServiceAccountId should be string

* Re-arrange field names

* ServiceAccountId is integer

* Update ossaccesscontrol.go

* Linter

* Remove fronend edits

* Remove console log

* Update ApiKeysForm.tsx

* feat: add serviceaccount deletion

* feat: make sure we do not accidently delete serviceaccount

* feat: ServiceAccount Type

* refactor: userDeletions function

* refactor: serviceaccount deletions\

* refactor: error name and removed attribute for userDeletecommand

* refactor:: remove serviceaccount type for now

* WIP

* add mocked function

* Remove unnecessary db query, move to right place

* Update pkg/services/accesscontrol/mock/mock.go

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

* Update pkg/services/accesscontrol/mock/mock.go

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

* Update pkg/services/accesscontrol/mock/mock.go

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

* Better error messages

* Better and correcter error messages

* add mocked function

* refactor: move function call, add error msg

* add IsServiceAccount and fix table

* add service accounts package

* WIP

* WIP

* working serviceaccountsapi registration

* WIP tests

* test

* test working

* test running for service

* moved the error out of the models package

* fixed own review

* linting errors

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

Co-authored-by: Jeremy Price <Jeremy.price@grafana.com>

* tests running for api

* WIP

* WIP

* removed unused secrets background svc

* removed background svc for serviceaccount infavor or wire.go

* serviceaccounts manager tests

* wip

* Filtering service accounts from the user queries in frontend

* clean up

* Update pkg/services/sqlstore/org_test.go

* methods on same type should have same receiver

* _ unused variable and comment

* add additional join for results query

* remove unused code

* remove error fmt

* refactor: change to only have false

* no new variable to the left hand side

* refactor: create serviceaccount cmd

* dialect fix

Co-authored-by: Jeremy Price <jeremy.price@grafana.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2021-11-23 23:06:40 +00:00
Will Browne
0921037f32
Plugins: Move logs from globals to fields (#42141)
* move logs from globals to fields

* fix test
2021-11-23 17:09:52 +01:00
Will Browne
96b1776856
Chore: Fix pass context for SetAlertStateCommand (#42135)
* fix pass ctx for SetAlertStateCommand

* fix integration test
2021-11-23 16:40:09 +01:00
Jean-Philippe Quéméner
cec2d965ec
Alerting: validate mute timings in the alertmanager configuration (#42125)
* Alerting: check for uniqueness of mutetime names

* add some testing

* add name validation

* add root route validation

* add tests for validation

* add check for root route mute_time_intervals

* add duplicate test

* remove useless yaml test

* refactor table test
2021-11-23 16:25:20 +01:00
Alexander Zobnin
da2c99a2e1
Access control: use delegatable flag to check if role can be granted (#42070)
* Access control: use delegatable flag to check if role can be granted or not

* Fix naming
2021-11-22 17:44:03 +03:00
Gábor Farkas
037fd9cc8c
Loki: alerting: adjust step-calculation to be the same as in frontend (#42033)
* loki: alerting: adjust step-calculation to be the same as in frontend

* loki: simplified test

* lint fix
2021-11-22 14:28:51 +01:00
George Robinson
9122e7f647
Alerting: Check for nil model.Settings and models.SecureSettings (#37738) 2021-11-22 11:56:18 +00:00
Peter Holmberg
97978a7c02
Alerting: Add value to notifier template (#41951)
* add value to email template

* add value to default template

* update test string

* test: fix ngalert test suite

* test: run CI

Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2021-11-22 08:45:44 +01:00
Ryan McKinley
f661e20dd7
Testdata: add random labeled stream (#41932) 2021-11-19 09:54:05 -08:00
Gábor Farkas
2fbc6b1d2f
loki: simplify interval calculation (#41857) 2021-11-19 17:20:32 +01:00
Jean-Philippe Quéméner
b9cdad3814
Alerting: support mute timings configuration through the api for the embedded alertmanager (#41533)
* Alerting: accept mute_timing_intervals through the api for the embedded alertmanager

* add workaround for mutetimeinterval

* add mute timings to routes

* revert changes

* Update pkg/services/ngalert/api/api_alertmanager.go

* Update pkg/services/ngalert/api/api_alertmanager.go

* Update pkg/services/ngalert/api/api_alertmanager.go

* update prometheus/alertmanager dependency

* add some var docs
2021-11-19 16:50:55 +01:00
idafurjes
87f148aa27
Chore: Add context to playlist (#41337)
* Add context to playlist

* Add AddEventListenerCtx and more context

* Update pkg/services/sqlstore/playlist.go

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

* Update pkg/services/sqlstore/playlist.go

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

* Update pkg/services/sqlstore/playlist.go

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

* Fix lint

* Rename listener help function

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-11-19 14:32:14 +01:00
idafurjes
972764cf8f
Add context for Publish and AddEventListener (#41665)
* Add context for Publish and AddEventListener

* Add test and listenersWithCtx

* Refactor listener logic

* Refactor publish logic for all combination of listeners and publish with and without ctx
2021-11-19 13:56:42 +01:00
Eric Leijonmarck
253da4a936
refactor: fix displayname and description for serviceaccount role (#41946)
* refactor: fix displayname and description for serviceaccount role

* add: ActionWrite, ActionCreate

* refactor: update description
2021-11-19 12:39:50 +01:00
Emil Tullstedt
12e0a94316
JWT: Split race-y test into two stable tests (#41950) 2021-11-19 12:05:04 +01:00
Ieva
03b7a55242
show admin nav link it the user only has permissions to view licensing and not other pages under admin node (#41948) 2021-11-19 11:02:13 +00:00
sam boyer
fc3ed34b22
Add basic resource trimming command (#41780)
* Add basic trim command

* Indent properly

* Actually apply defaults if the user asks for it
2021-11-18 10:02:11 -05:00
Gabriel MABILLE
0ee0a0b7a0
AccessControl: FGAC permissions for orgs endpoint on frontend (#41050)
* AccessControl: FGAC permissions for orgs endpoint on frontend

Protect org update endpoints

add or refactor missing right messages

cover org page

* removing scopes from orgs

* Perform permission control with global org

* Perform the error handling in case of 403

* Simplify frontend code by requiring read access for sure

* Remove roles I added to decrease the number of changes

* Remove the check for server admin to reduce the number of changes

* change error message

* Cleaning todos

* Remove unecessary changes

* Fix tests

* Update test snapshot

* Update pkg/api/roles.go

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>

* Update public/app/features/admin/AdminEditOrgPage.tsx

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>

* Format AdminEditOrgPage for linting

* Update public/app/features/admin/AdminEditOrgPage.tsx

Co-authored-by: Vardan Torosyan <vardants@gmail.com>

* Update public/app/features/admin/AdminEditOrgPage.tsx

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

* Update public/app/features/admin/AdminListOrgsPage.tsx

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

* Commit suggestions

* Commit suggestion canRead canWrite

* fix typo

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Vardan Torosyan <vardants@gmail.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
2021-11-18 14:10:38 +01:00
George Robinson
ac59b7615d
Alerting: README.md for ngalert 2021-11-18 10:26:42 +00:00