Commit Graph

230 Commits

Author SHA1 Message Date
Alex Moreno
10fdfa8583
Alerting: Change handling of settings to pagerduty contact point (#57524)
* Add custom title to pagerduty contact point

* Fix tests by saving decrypted key

* Use simplejson
2022-10-27 16:20:10 +02:00
Artur Wierzbicki
a63c529ad1
Chore: add query_retries=3 to querylibrary_integration_test.go (#57607) 2022-10-25 09:52:56 -04:00
Joey Tawadrous
d9a6c3f398
FlameGraph: Add newly designed flame graph icon (#57514)
* Add newly designed flame graph icon

* Update expectedListResponse
2022-10-25 07:18:17 +01:00
Kristin Laemmert
05709ce411
chore: remove sqlstore & mockstore dependencies from (most) packages (#57087)
* chore: add alias for InitTestDB and Session

Adds an alias for the sqlstore InitTestDB and Session, and updates tests using these to reduce dependencies on the sqlstore.Store.

* next pass of removing sqlstore imports
* last little bit
* remove mockstore where possible
2022-10-19 09:02:15 -04:00
Santiago
6ad405e256
fix swagger spec for receivers API response (#57124) 2022-10-17 16:58:55 -03:00
Yuriy Tseretyan
888bdfd4ad
Alerting: Use correct response body for silence post API (#57114) 2022-10-17 15:43:37 -04:00
Santiago
9996dbd577
use Prometheus' format for notification attempts durations (#56822) 2022-10-13 10:08:09 -03:00
idafurjes
ef651daed2
Use org service instead of sqlstore (#56407)
* Use org service instead of sqlstore

* Remove methods from sqlstore

* Remove commented out code

* Fix lint

* Fix lint 2
2022-10-13 08:40:46 -04:00
Giordano Ricci
f1a0a5cb47
Glue: improves validation & fix api docs for correlations (#56682) 2022-10-11 14:04:55 +01:00
Laura Benz
bc9a37ee8d
Glue: Add configuration support to PATCH (#56117)
* feat: add config to tests v0

* feat: add config to UpdateCorrelationCommand

* refactor: repair some tests

* refactor: repair another test

* refactor: repair last test

* refactor: remove possible test

* refactor: add comments

* refactor: add changes from code review

* refactor: implement more detailed patch

* feat: add tests for partial config update

* refactor: make error handling more detailed

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

Co-authored-by: Giordano Ricci <me@giordanoricci.com>
2022-10-10 15:36:14 +02:00
George Robinson
802d67eeca
Alerting: Support values in notification templates (#56457)
We have received a lot of feedback regarding the ValueString in alert notifications. Perhaps one of the most frequent complaints about ValueString is that it is difficult to read because it contains a lot of information, and the information is shown as a JSON-like string. Users have often asked how it can be templated and the answer is that it can't.

Until now users have been able to add custom annotations to their alert rules which contains values via the $values variable added in previous versions of Grafana. However, these custom annotations must be added for each of the user's alert rule, instead of once in a template that all of their alerts can be notified via.

This commit adds then the much requested feature to support values in notification templates. Users can then create a single template that prints the annotations, labels and values of their alerts in a format of their choice!
2022-10-10 13:40:21 +01:00
Ivana Huckova
23e04c0f9c
Elasticsearch: Add integration tests for http header handling (#56542)
* Elasticsearch: Add integration test

* Fix lint
2022-10-07 18:21:48 +02:00
Joey Tawadrous
74c809f544
Plugins: Introduce new Flame graph panel (#56376)
* Flamegraph

* Updated flame graph width/height values

* Fix top table rendering issue

* Add feature toggle for flamegraph in explore

* Update tests

* Hide flamegraph from dash panel viz list if feature toggle not enabled

* Show table if no flameGraphFrames

* Add flame graph to testdata ds

* Minor improvement
2022-10-07 11:39:14 +01:00
Ivana Huckova
eef3f28447
Loki: Add integration tests for http header handling (#56478)
* Loki: Add integration tests for http header handling

* Fix linting
2022-10-07 10:16:41 +02:00
Joe Blubaugh
b1df15c4b9
Alerting: Add basic test wrappers to notification channel API test. (#56432)
Adds t.Run calls that supply the name of a receiver and its integrations
when the API response is being verified. This test has a rare flake and
it's difficult to track down without more context for the test failure.
2022-10-06 17:38:54 +08:00
Nathan Marrs
2c1c98f3b6
Canvas: Promote to beta (#56217)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2022-10-04 12:29:56 -07:00
Giordano Ricci
489b302c03
Glue: Correlations minor APIs behavior improvements (#56078)
* add correlation config type, CorrelationConfig validator & default values

* make config required when creating correlations

* make targetUID optional, add validation for createCommand & configType

* fix tests

* update remaining tests

* fix lint error

* Update pkg/services/correlations/models.go

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

* update docs

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
2022-10-04 09:39:55 +01:00
Victor Marin
7b93d85a85
XYChart: Beta release (#55973)
* Bump state from alpha to beta

* Sync manual pointsize max with auto one

* Add xyChart to list
2022-10-04 10:41:36 +03:00
Santiago
09f8e026a1
Alerting: Expose info about notification delivery errors in a new /receivers endpoint (#55429)
* (WIP) switch to fork AM, first implementation of the API, generate spec

* get receivers avoiding race conditions

* use latest version of our forked AM, tests

* make linter happy, delete TODO comment

* update number of expected paths to += 2

* delete unused endpoint code, code review comments, tests

* Update pkg/services/ngalert/notifier/alertmanager.go

Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>

* remove call to fmt.Println

* clear naming for fields

* shorter variable names in GetReceivers

Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
2022-10-03 10:58:41 -03:00
Artur Wierzbicki
64eff8196c
Chore: expose grpc server address (#56013) 2022-09-29 08:42:01 -04:00
Piotr Jamróz
a8f43b97a2
Glue: Return correlation config in GET /correlations (#55801)
* Fix getting and creating correlations config

* Fix tests
2022-09-28 12:17:43 +01:00
Piotr Jamróz
becdf10f0e
Glue: Add DB migration & support provisioning for user-defined correlations config (#55560)
* Allow provisioning correlation config

* Simplify code

* Fix reading correlations test

* Fix linting errors

* Fix linting errors

* remove simpleJson

* Clean up

* Fix tests

* Update swagger docs

* Fix linting

* Fix linting

* Clean up swagger definitions

Co-authored-by: Elfo404 <me@giordanoricci.com>
2022-09-27 11:08:02 +02:00
Giordano Ricci
d07abdd23c
Correlations: Only return correlation for which both source and target datasources exist (#55454)
* Correlation: only return correlation for which both source and targe ds exist

* add test
2022-09-26 14:05:04 +01:00
Yuriy Tseretyan
2d38664fe6
Alerting: Improve validation of query and expressions on rule submit (#53258)
* Improve error messages of server-side expression 
* move validation of alert queries and a condition to eval package
2022-09-21 15:14:11 -04:00
Marcus Efraimsson
862a6a2fa6
Logging: Introduce API for contextual logging (#55198)
Introduces a FromContext method on the log.Logger interface that 
allows contextual key/value pairs to be attached, e.g. per request, 
so that any logger using this API will automatically get the per request 
context attached. The proposal makes the traceID available for 
contextual logger , if available, and would allow logs originating from 
a certain HTTP request to be correlated with traceID.
In addition, when tracing not enabled, skip adding
traceID=00000000000000000000000000000000
to logs.
2022-09-20 18:32:06 +02:00
Giordano Ricci
d815e2cb56
Correlations: Return 200 instead of 404 for empt correlation lists (#55242)
* return 200 instead of 404 for empty correlations list

* handle empty list response & improve consistency
2022-09-20 11:13:33 +01:00
Will Browne
0571d98bba
[WIP] Plugins: Introduce Plugins specific config (#54854) 2022-09-14 14:35:35 +01:00
Karl Persson
870929b463
RBAC: Add cache for oss rbac permissions (#55098)
* RBAC: Add cache for oss permissions

* RBAC: include service account actions

* RBAC: revert changes to fetch service account permissions

* Update comment for setting

* RBAC: Disable permission chache for tests
2022-09-14 09:13:10 +02:00
Emil Tullstedt
b287047052
Chore: Upgrade Go to 1.19.1 (#54902)
* WIP

* Set public_suffix to a pre Ruby 2.6 version

* we don't need to install python

* Stretch->Buster

* Bump versions in lib.star

* Manually update linter

Sort of messy, but the .mod-file need to contain all dependencies that
use 1.16+ features, otherwise they're assumed to be compiled with
-lang=go1.16 and cannot access generics et al.

Bingo doesn't seem to understand that, but it's possible to manually
update things to get Bingo happy.

* undo reformatting

* Various lint improvements

* More from the linter

* goimports -w ./pkg/

* Disable gocritic

* Add/modify linter exceptions

* lint + flatten nested list

Go 1.19 doesn't support nested lists, and there wasn't an obvious workaround.
https://go.dev/doc/comment#lists
2022-09-12 12:03:49 +02:00
Gabriel MABILLE
101349fe49
RBAC: Add permissions to install and configure plugins (#51829)
* RBAC: Allow app plugins restriction

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

* Moving declaration to HttpServer

Co-Authored-By: marefr <marcus.efraimsson@gmail.com>

* Picking changes from the other branch

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

* Rename plugins.settings to plugins

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

* Account for PluginAdminExternalManageEnabled

Co-authored-by: Will Browne <will.browne@grafana.com>

* Set metadata on instantiation

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

Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: marefr <marcus.efraimsson@gmail.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-09-09 09:44:50 +02:00
ismail simsek
9c6a6ca487
graphite and opentsdb integration tests (#54733) 2022-09-06 17:19:04 +03:00
ismail simsek
e912029ad3
influxdb integration tests (#54700) 2022-09-05 15:35:53 +02:00
Marcus Efraimsson
87afd9cadc
Plugins: Remove various custom headers logic (#54146)
Removes various custom headers logic sprinkled around in the backend. 
It should automatically be applied to outgoing HTTP requests via the 
CustomHeadersMiddleware.
This also removes decryption of SecureJSONData to populate custom 
headers in ngalert which seemed to have caused a ton of CPU usage.
2022-08-26 11:56:10 +02:00
George Robinson
e163a976fa
Alerting: Fix width of Adapative Cards in Teams notifications (#53996) 2022-08-22 16:04:22 +01:00
Karl Persson
1b933ff3ed
RBAC: Move resource permissions store to service package (#53815)
* Rename file to store

* Move resource permission specific database functions to
resourcepermissions package

* Wire: Remove interface bind

* RBAC: Remove injection of resourcepermission Store

* RBAC: Export store constructor

* Tests: Use resource permission package to initiate store used in tests

* RBAC: Remove internal types package and move to resourcepermissions
package

* RBAC: Run database tests as itegration tests
2022-08-18 09:43:45 +02:00
George Robinson
6d69d7acb8
Alerting: Fix notifications for Microsoft Teams (#53810)
This commit fixes notifications for Microsoft Teams where notifications
would just contain "Card" rather than the title.
2022-08-17 16:46:46 +01:00
Drew Slobodnjak
e9e5c97807
Geomap: Update language to match documentation and remove beta (#53703)
Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
2022-08-12 21:33:30 -04:00
Giordano Ricci
6b84dddee8
Fix build error (#53615) 2022-08-11 15:21:37 -04:00
Giordano Ricci
c1b30c56c9
Correlations: Add GetCorrelation(s) HTTP APIs (#52517)
* Correlations: Get Single correlations

* Correlations: Get all correlations for given source ds

* Correlations: Get all correlations

* add tests

* add DB indices

* fix lint errors

* remove skip from tests

* use DatasourceService in test
2022-08-11 16:58:11 +01:00
George Robinson
5e1d628f21
Alerting: Use Adaptive Cards in Teams notifications (#53532)
This commit changes the cards in Teams notifications from Office 365
Connector cards to Adaptive Cards to fix an issue where images were not
shown in Teams for desktop and web. Since Office 365 Connector cards
are deprecated, it made sense to move to Adapative Cards and fix this
bug at the same time.

The Adaptive Card messages maintain the design of the Office 365
Connector Card with a number of minor differences:

- In Adaptive Card messages the color of the title is red or green
  depending on the status of the alerts, where as with Office 365
  connector cards there was a colored border at the top of the title

- In Adaptive Card messages the title is bold to make it easier to read
  when the color is red or green

- In Adaptive Card messages the thumbnails for images are medium size
  if there are more than two images, otherwise large size
2022-08-10 19:51:20 +01:00
Jo
062d255124
Handle ioutil deprecations (#53526)
* replace ioutil.ReadFile -> os.ReadFile

* replace ioutil.ReadAll -> io.ReadAll

* replace ioutil.TempFile -> os.CreateTemp

* replace ioutil.NopCloser -> io.NopCloser

* replace ioutil.WriteFile -> os.WriteFile

* replace ioutil.TempDir -> os.MkdirTemp

* replace ioutil.Discard -> io.Discard
2022-08-10 15:37:51 +02:00
idafurjes
6afad51761
Move SignedInUser to user service and RoleType and Roles to org (#53445)
* Move SignedInUser to user service and RoleType and Roles to org

* Use go naming convention for roles

* Fix some imports and leftovers

* Fix ldap debug test

* Fix lint

* Fix lint 2

* Fix lint 3

* Fix type and not needed conversion

* Clean up messages in api tests

* Clean up api tests 2
2022-08-10 11:56:48 +02:00
sh0rez
534ece064b
pkg/web: closure-style middlewares (#51238)
* pkg/web: closure-style middlewares

Switches the middleware execution model from web.Handlers in a slice to
web.Middleware.
Middlewares are temporarily kept in a slice to preserve ordering, but
prior to execution they are applied, forming a giant call-stack, giving
granular control over the execution flow.

* pkg/middleware: adapt to web.Middleware

* pkg/middleware/recovery: use c.Req over req

c.Req gets updated by future handlers, while req stays static.

The current recovery implementation needs this newer information

* pkg/web: correct middleware ordering

* pkg/webtest: adapt middleware

* pkg/web/hack: set w and r onto web.Context

By adopting std middlewares, it may happen they invoke next(w,r) without
putting their modified w,r into the web.Context, leading old-style
handlers to operate on outdated fields.

pkg/web now takes care of this

* pkg/middleware: selectively use future context

* pkg/web: accept closure-style on Use()

* webtest: Middleware testing

adds a utility function to web/webtest to obtain a http.ResponseWriter,
http.Request and http.Handler the same as a middleware that runs would receive

* *: cleanup

* pkg/web: don't wrap Middleware from Router

* pkg/web: require chain to write response

* *: remove temp files

* webtest: don't require chain write

* *: cleanup
2022-08-09 14:58:50 +02:00
Giordano Ricci
09c4dbdb9f
Correlations: Add UpdateCorrelation HTTP API (#52444)
* Correlations: add UpdateCorrelation HTTP API

* handle correlation not found

* add tests

* fix lint errors

* add bad request to API spec

* change casing

* fix casing in docs

* fix tests

* update spec
2022-08-03 14:18:51 +01:00
Sofia Papagiannaki
7ba076de10
Chore: Move swagger definitions to the handlers (#52643) 2022-07-27 09:54:37 -04:00
Giordano Ricci
9a06b00e92
Correlations: Add DeleteCorrelation HTTP API (#51801)
* Correlations: add DeleteCorrelation HTTP API

* fix error message copy

* add readonly check

* add source_uid in delete condition

* make path singular

* Revert "make path singular"

This reverts commit d15be89578e202e5cb64a3e964ee09521b72d87c.

* add tests

* fix lint errors

* fix lint errors

* change casing

* update spec

* Remove transaction

* change casing in param name in docs
2022-07-27 09:07:58 +01:00
Giordano Ricci
4b2144fe40
Correlations: change casing of *UID properties (#52836)
* Correlations: change casing of *UID properties

* add link to correlations HTTP API
2022-07-27 07:01:46 +01:00
Giordano Ricci
5ce4baf6f5
Correlations: Add CreateCorrelation HTTP API (#51630)
* Correlations: add migration

* Correlations: Add CreateCorrelation API

* Correlations: Make correlations work with provisioning

* Handle version changes

* Fix lining error

* lint fixes

* rebuild betterer results

* add a UID to each correlation

* Fix lint errors

* add docs

* better wording in API docs

* remove leftover comment

* handle ds updates

* Fix error message typo

* add bad data test

* make correlations a separate table

* skip readonly check when provisioning correlations

* delete stale correlations when datasources are deleted

* restore provisioned readonly ds

* publish deletion event with full data

* generate swagger and HTTP API docs

* apply source datasource permission to create correlation API

* Fix tests & lint errors

* ignore empty deletion events

* fix last lint errors

* fix more lint error

* Only publish deletion event if datasource was actually deleted

* delete DS provisioning deletes correlations, added & fixed tests

* Fix unmarshalling tests

* Fix linting errors

* Fix deltion event tests

* fix small linting error

* fix lint errors

* update betterer

* fix test

* make path singular

* Revert "make path singular"

This reverts commit 420c3d315e.

* add integration tests

* remove unneeded id from correlations table

* update spec

* update leftover references to CorrelationDTO

* fix tests

* cleanup tests

* fix lint error
2022-07-25 15:19:07 +01:00
Jean-Philippe Quéméner
ba9c18d9c3
Alerting: use static channel configuration to determinate secure fields (#52527)
* Alerting: use static channel configuration to determinate secure fields

* move to channels package

* introduce channel_config package to fix cyclic import

* add missing changes

* compare type to type
2022-07-20 19:58:36 +02:00
Jean-Philippe Quéméner
50ae42130b
Alerting: take datasources as external alertmanagers into consideration (#52534) 2022-07-20 16:50:49 +02:00