Commit Graph

6816 Commits

Author SHA1 Message Date
Peter Holmberg
75cff769f7
Alerting: Create alert from side menu (#40387)
* add entry for Create submeny

* extracting to function to resolve lint issue
2021-10-14 15:22:16 +02:00
Jean-Philippe Quéméner
153c356993
Alerting: delete orphaned records from kvstore (#40337) 2021-10-14 12:04:00 +02:00
Selene
a1230f44dc
Fix user's total count in search (#40415) 2021-10-14 09:51:32 +02:00
Ilya Stoliar
665055dbbc
CloudWatch: Add AWS Elastic GPUs metrics and dimensions (#40253)
* CloudWatch: Added AWS Elastic GPUs metrics and dimensions

* Delete extra space
2021-10-14 09:35:28 +02:00
Jesse Weaver
5af96544f3
Forbid creation of dashboard permissions with both a user and a team (#40104)
These permissions could be created through the API but would not show
correctly in the UI.
2021-10-13 12:16:58 -06:00
Emil Tullstedt
e73cd2fdeb
OAuth: Support PKCE (#39948) 2021-10-13 16:45:15 +02:00
Kevin Minehart
23bee50474
Prometheus: Fix issue where TCP connections not being reused when querying from Grafana alerting (#40349)
Fixes #40366

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-10-13 10:22:26 +02:00
Ben RUBSON
3d9e2d8c82
Application: Make error-template title configurable (#40310)
* Fix error-template title

as in index-template.html

* Test: fix for AppTitle

Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
2021-10-13 08:35:01 +02:00
gotjosh
2448123a65
Alerting: Remove invalid Slack URL as we migrate notification channels (#40344)
* Alerting: Remove invalid Slack URL as we migrate notification channels

Grafana will accept any type of utf8 valid string as the Slack URL and will simply fail as we try to deliver the notification of the channel. The Alertmanager will fail to apply a configuration if the URL of the Slack Receiver is invalid.

This change takes that into account by removing the URL for the receiver as we migrate notification channels that do not pass the url validation. As we assume the notification was not being delivered to being with.

* Add a log line when we modify the channel

Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
2021-10-12 18:55:39 -04:00
gotjosh
48d73cb148
Alerting: Fixes a bug when trying to sync broken alertmanager config (#40338)
* Alerting: Fixes a bug when trying to sync broken alertmanager config

Broken alertmanager configuration has the potential to be introduced as part of a migration e.g. due to incompatible data between what grafana accepts and what the Alertmanager expects. When this happens, we expect an eventually consistent behaviour where we'll keep trying to apply the configuration until it works.

As part of change in https://github.com/grafana/grafana/pull/39237 we introduced a regression that modified this behaviour and instead tried to create a new Alertmanager for that organization everytime, which eventually ended up in a panic due to a duplicate metrics being registered.

This PR fixes that and introduces a test to catch further regressions.

* Remove disable orgs
2021-10-12 18:10:08 +01:00
Tania B
f59aabbd3b
Chore: Refactor secrets service (#40331) 2021-10-12 17:08:07 +03:00
Ivana Huckova
19ad08e6b8
Prometheus: Run exemplars explore queries through backend (#39531)
* Prometheus: Run Explore both queries trough backend

* Refactor, simplify

* Set default values for query type selector

* Run multiple queries as one query trough backend

* Remove trailing newlines

* Pass utcOffset

* Remove trailing comma

* WIP: Implementatioon of exemplars

* add sampling for exemplars

* Refactor to use response as custom metadata

* Simplify processing of exemplars

* Update, clean up

* Refactor the way how we get available exemplars

* Simplify exemplars disabling and running on frontend

* Add tests

* Update toggle

* Remove console log

* Fix go linting

* Fix e2e test

* Trigger Build

* Compare lengts, small fix

* Remove duplicated time check

* Address feedback

* Remove redundant ! as not needed

* Update
2021-10-12 13:16:09 +02:00
Jean-Philippe Quéméner
e1dfec49f9
Alerting: cleanup alert resources on org removal (#39938) 2021-10-12 12:05:02 +02:00
gotjosh
f33f098b73
Alerting: Disable flaky assertion in TestSendingToExternalAlertmanager_WithMultipleOrgs (#40197)
* Alerting: Disable flaky assertion in TestSendingToExternalAlertmanager_WithMultipleOrgs

* Update pkg/services/ngalert/schedule/schedule_unit_test.go

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>

* Update pkg/services/ngalert/schedule/schedule_unit_test.go

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
2021-10-12 10:07:29 +01:00
Eric Leijonmarck
b88cd08177
feat: fallback for displayname of non-fixed role without displayname (#40277) 2021-10-11 16:00:54 +01:00
Giordano Ricci
24af3593a2
AWS: add OpenSearch to AWS services (#40290) 2021-10-11 15:53:04 +01:00
George Robinson
8318e45452
Alerting: Fix error message in ngalert when notifications cannot be sent to alertmanager (#40158) 2021-10-11 14:50:50 +01:00
Carl Bergquist
621bd477d0
Context: Add context to hasEditPermission call bus call (#40107)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-10-11 14:36:57 +02:00
Carl Bergquist
f20de5588b
add context to api crud calls (#40047)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-10-11 14:35:31 +02:00
Carl Bergquist
c9f25cf0a5
Context: Add context to /api/health calls (#40031)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-10-11 14:35:03 +02:00
Serge Zaitsev
57fcfd578d
Chore: replace macaron with web package (#40136)
* replace macaron with web package

* add web.go
2021-10-11 14:30:59 +02:00
Dimitris Sotirakis
d023cabae6
Add Headers to http client Options (#40214) 2021-10-08 16:52:41 +03:00
Jean-Philippe Quéméner
d9c0220824
Alerting: add organziation ID to the ngAlert webhook payload (#40189)
* Alerting: add organziation ID to the ngAlert webhook payload
2021-10-08 14:52:44 +02:00
sam boyer
0fe200ce41
Do codegen and check no-diff of all (non-blacklisted) CUE->TS codegen during CI (#39922)
* Add file blacklist to `grafana-cli cue gen-ts` cmd

* Add CI step checking all cuetsification is done

* Add dummy command to make the next one fail

* Generate drone bits

* Check diff output failure

* Echo list of untracked files, for failure locality

* Move git cleanness checking into script

* Blacklist of cue files is complete and correct

* Remove news panel plugin from cuetsify blacklist

* Dummy commit, check that untracked gen still fail

* Tie off remaining errors

* Re-add barchart to blacklist
* Remove file left around by earlier pipeline
* Commit generated news models.gen.ts

* Include eslint as part of cuetsified output gen

* Update pkg/cmd/grafana-cli/commands/cuetsify_command.go

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>

* Update scripts/drone/steps/lib.star

Co-authored-by: Maria Alexandra <239999+axelavargas@users.noreply.github.com>

* Update drone.yml

* Last fix on .drone.yml

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
Co-authored-by: Maria Alexandra <239999+axelavargas@users.noreply.github.com>
2021-10-08 08:47:55 -04:00
idafurjes
e822c8a24d
CloudMonitoring: Migrate to use backend plugin SDK contracts (#38650)
* Use SDK contracts for cloudmonitoring

* Get build running, tests passing and do some refactoring (#38754)

* fix build+tests and refactor

* remove alerting stuff

* remove unused field

* fix plugin fetch

* end to end

* resp rename

* tidy annotations

* reformatting

* update refID

* reformat imports

* fix styling

* clean up unmarshalling

* uncomment + fix tests

* appease linter

* remove spaces

* remove old cruft

* add check for empty queries

* update tests

* remove pm as dep

* adjust proxy route contract

* fix service loading

* use UNIX val

* fix endpoint + resp

* h@ckz for frontend

* fix resp

* fix interval

* always set custom meta

* remove unused param

* fix labels fetch

* fix linter

* fix test + remove unused field

* apply pr feedback

* fix grafana-auto intervals

* fix tests

* resolve conflicts

* fix bad merge

* fix conflicts

* remove bad logger import

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
2021-10-08 14:46:35 +02:00
Yuriy Tseretyan
5836def6c2
Alerting: declare constants for __dashboardUid__ and __panelId__ literals (#39976) 2021-10-07 17:30:06 -04:00
Joan López de la Franca Beltran
722c414fef
Encryption: Refactor securejsondata.SecureJsonData to stop relying on global functions (#38865)
* Encryption: Add support to encrypt/decrypt sjd

* Add datasources.Service as a proxy to datasources db operations

* Encrypt ds.SecureJsonData before calling SQLStore

* Move ds cache code into ds service

* Fix tlsmanager tests

* Fix pluginproxy tests

* Remove some securejsondata.GetEncryptedJsonData usages

* Add pluginsettings.Service as a proxy for plugin settings db operations

* Add AlertNotificationService as a proxy for alert notification db operations

* Remove some securejsondata.GetEncryptedJsonData usages

* Remove more securejsondata.GetEncryptedJsonData usages

* Fix lint errors

* Minor fixes

* Remove encryption global functions usages from ngalert

* Fix lint errors

* Minor fixes

* Minor fixes

* Remove securejsondata.DecryptedValue usage

* Refactor the refactor

* Remove securejsondata.DecryptedValue usage

* Move securejsondata to migrations package

* Move securejsondata to migrations package

* Minor fix

* Fix integration test

* Fix integration tests

* Undo undesired changes

* Fix tests

* Add context.Context into encryption methods

* Fix tests

* Fix tests

* Fix tests

* Trigger CI

* Fix test

* Add names to params of encryption service interface

* Remove bus from CacheServiceImpl

* Add logging

* Add keys to logger

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

* Add missing key to logger

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

* Undo changes in markdown files

* Fix formatting

* Add context to secrets service

* Rename decryptSecureJsonData to decryptSecureJsonDataFn

* Name args in GetDecryptedValueFn

* Add template back to NewAlertmanagerNotifier

* Copy GetDecryptedValueFn to ngalert

* Add logging to pluginsettings

* Fix pluginsettings test

Co-authored-by: Tania B <yalyna.ts@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-10-07 17:33:50 +03:00
Selene
da813877fb
Create search filters by interface (#39843)
* Extract search users to a new service

* Fix wire provider

* Fix common_test and remove RouteRegister

* Remove old endpoints

* Fix test

* Create search filters using interfaces

* Move Enterprise filter, rename filter for filters and allow use filters with params

* Each filter has unique key

* Back activeLast30Days filter to OSS

* Fix tests

* Delete unusued param

* Move filters to searchusers service and small refactor

* Fix tests
2021-10-07 16:06:16 +02:00
Karl Persson
efbb4c890f
Access Control: Add scope type prefix (#40076)
* prefix runtime scopes with key type
2021-10-07 11:54:43 +02:00
Ashley Harrison
009a26264c
NavBar: Order App plugins alphabetically (#40078)
* NavBar: Order App plugins alphabetically

* Update pkg/api/index.go

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

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2021-10-07 10:08:47 +01:00
Alexander Emelin
8180121495
Live: remote write sampling (#40079) 2021-10-07 11:42:57 +03:00
Alexander Emelin
5358c45a3a
Live: array for Processor, Outputter and Subscriber in channel rule top level (#39677) 2021-10-06 20:43:25 +03:00
Gabriel MABILLE
458371c8eb
AccessControl: Extend scope parameters with extra params from context (#39722)
* AccessControl: Extend scope parameters with extra params from context

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-10-06 13:15:09 +02:00
Serge Zaitsev
3131388084
Chore: Imperative request data binding (#39837)
* rename Bind to BindMiddleware

* make things private

* removed unused part of data bindings

* provide json and form binding helpers

* add example of binding migration in login api

* implement validation

* fix tests

* remove debug output

* put new bind api into macaron pacakge

* revert bind api breaking change
2021-10-06 12:52:27 +02:00
George Robinson
935bd34a30
Panel ID annotation cannot be set without Dashboard UID (#40019) 2021-10-06 11:34:11 +01:00
ying-jeanne
227c8403b5
Fix the disjuction of panels (#39412)
[As code] Correct trim apply defaults when import/export dashboards
2021-10-06 11:39:23 +02:00
Marcus Efraimsson
329f96db1a
Fix static path matching issue in macaron (#40023)
Co-authored-by: Malcolm Holmes <mdh@odoko.co.uk>
2021-10-05 19:38:09 +02:00
Eric Leijonmarck
5374eaca89
fix: marshal displayname RoleDTO (#40015) 2021-10-05 16:29:34 +02:00
Ieva
52220b2470
AccessControl: frontend changes for adding FGAC to licensing (#39484)
* refactor licenseURL function to use context and export permission evaluation fction

* remove provisioning file

* refactor licenseURL to take in a bool to avoid circular dependencies

* remove function for appending nav link, as it was only used once and move the function to create admin node

* better argument names

* create a function for permission checking

* extend permission checking when displaying server stats

* enable the use of enterprise access control actions when evaluating permissions

* import ordering

* move licensing FGAC action definitions to models package to allow access from oss

* move evaluatePermissions for routes to context serve

* change permission evaluator to take in more permissions

* move licensing FGAC actions again to appease wire

* avoid index out of bounds issue in case no children are passed in when creating server admin node

* simplify syntax for permission checking

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

* update loading state for server stats

* linting

* more linting

* fix test

* fix a frontend test

* update "licensing.reports:read" action naming

* UI doesn't allow reading only licensing reports and not the rest of licensing info

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-10-05 14:54:26 +01:00
Eric Leijonmarck
f384288183
AccessControl: Add displayname field to Role (#39904)
* feat: add displayname

* refactor: marshal role for fallback displayname

* refactor: moved to private heuristic function for displaynames

* refactor: display name trimspace and remove prefix

* refactor: renaming of fallbackFunction

* refactor: moved methods below struct types
2021-10-05 13:07:16 +01:00
idafurjes
2759b16ef5
Chore: Add context for dashboards (#39844)
* Add context for dashboards

* Remove GetDashboardCtx

* Remove ctx.TODO
2021-10-05 13:26:24 +02:00
Gabriel MABILLE
4160429b71
AccessControl: rename data source id read action (#39966) 2021-10-05 09:39:00 +02:00
Santiago
562cd9e44e
Alerting template functions (#39261)
* Alerting: (wip) add template funcs

* Alerting: (wip) numeric template functions

* Alerting: (wip) template functions

* Test for the "args" function

* Alerting: (wip) Documentation for template functions

* Alerting: template functions - refactor

* code review changes

* disable linter error

* Use Prometheus implementation of TemplateExpander

* Update docs/sources/alerting/unified-alerting/alerting-rules/create-grafana-managed-rule.md

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

* change templateCaptureValue to support using template functions

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

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

* Test and documentation added for reReplaceAll template function

* complete missing functions, documentation and tests

* Use the alert instance's evaluation time for expanding the template

* strvalue graphlink and tablelink functions

* delete duplicate test

* make strvalue return an empty string

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
Co-authored-by: gotjosh <josue.abreu@gmail.com>
2021-10-04 15:04:37 -03:00
George Robinson
2a4c1b1aa6
You can now get alert rules for a dashboard or a panel using /api/v1/rules endpoints. (#39476)
Get alert rules for a dashboard and panel in /api/v1/rules
2021-10-04 16:33:55 +01:00
idafurjes
f4f0d74838
Chore: Add context to user (#39649)
* Add context to user

* Add context for enterprise

* Add context for UpdateUserLastSeenAtCommand

* Remove xorm
2021-10-04 15:46:09 +02:00
gotjosh
6572017ec7
Alerting: Allow more characters in label names so notifications are sent (#38629)
Remove validation for labels to be accepted in the Alertmanager, This helps with datasources that produce non-compatible labels.

Adds an "object_matchers" to alert manager routers so we can support labels names with extended characters beyond prometheus/openmetrics. It only does this for the internal Grafana managed Alert Manager.

This requires a change to alert manager, so for now we use grafana/alertmanager which is a slight fork, with the intention of going back to upstream.

The frontend handles the migration of "matchers" -> "object_matchers" when the route is edited and saved. Once this is done, downgrades will not work old versions will not recognize the "object_matchers".

Co-authored-by: Kyle Brandt <kyle@grafana.com>
Co-authored-by: Nathan Rodman <nathanrodman@gmail.com>
2021-10-04 15:06:40 +02:00
Guilherme Caulada
706a665240
Auth: add name parameter to auth.saml (#39883)
* add name parameter to auth.saml

* Create constant to store default SAML name
2021-10-04 09:58:16 -03:00
Yuriy Tseretyan
4dadb8fc51
Alerting: Remove extra field orgId from notifier.Alertmanager (#39870) 2021-10-01 09:54:37 -04:00
Domas
e343b62665
Alerting: make /api/prometheus/grafana/api/v1/rules faster (#39660) 2021-10-01 16:39:04 +03:00
Domas
a1d4be0700
Alerting: Alertmanager datasource support for upstream Prometheus AM implementation (#39775) 2021-10-01 16:24:56 +03:00