Commit Graph

885 Commits

Author SHA1 Message Date
Artur Wierzbicki
e96f67ae2e
Renderer: Add sanitize API (#50936)
* svg fun

* #50597: add proto

* #50597: add sanitizer methods

* #50597: add provider

* #50597: use sanitizer

* #50597: use sanitizer

* update grafana to match new api

* add comments

* add capability check

* add timing

* update sanitize path

* improve log message

* strings.HasPrefix rather than filepath.IsAbs

* filepath.Clean + filepath.ToSlash for windows

* read 404

* remove `path.clean` from `getPathAndScope`

* add resp body close

* remove unneeded prop

* Update pkg/services/rendering/rendering.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* remove test files

* filepath.ToSlash correct wrapping

* filepath.ToSlash correct wrapping

* filepath.ToSlash comment

* compilation error

* lint fix

* fix error message

* Update pkg/services/rendering/rendering.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* add `image/svg+xml` mime type

* refactored log

* refactored log

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2022-07-07 15:32:18 +04:00
Kristin Laemmert
945f015770
backend/datasources: move datasources models into the datasources service package (#51267)
* backend/datasources: move datasources models into the datasources service pkg
2022-06-27 12:23:15 -04:00
Daniel Underwood
6f2c0d467f
Alerting: notifiers/discord: Fix group mention documentation (#51071)
This change updates the UI to document the correct Group Mention format for Discord Contact Points.

The Discord API documentation (https://discord.com/developers/docs/reference#message-formatting) uses `<@&ID>` for Group Mentions, not the bare `@` shown in the alerting UI. Testing on 8.5 shows that bare `@` isn't working there.
2022-06-21 05:34:49 +00:00
Torkel Ödegaard
c6ab87008a
Dashboard: Remove super old prop that has not been used in years (#50826) 2022-06-17 14:55:35 +02:00
Serge Zaitsev
ae9491c3a7
Chore: Make test tracer noop and return no errors (#50797) 2022-06-15 12:40:41 +02:00
Kat Yang
bd35e6917a
Chore: Exclude integration tests from running on test-backend step (#50359)
* Chore: Exclude integration tests from running on test-backend step

* Remove -v from go test command

* Add check to skip integration tests before each integration test

* Try to restart pipeline

* Retrying to make pipeline run
2022-06-10 11:46:21 -04:00
Yuriy Tseretyan
b0ae4d460e
Alerting: Make ticker to tick at predictable time (#50197) 2022-06-10 10:27:17 -04: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
Kat Yang
3c3039f5b3
Chore: Remove Wrap (#50048)
* Chore: Remove Wrap and Wrapf

* Fix: Add error check
2022-06-03 09:24:24 +02: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
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
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
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
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
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
gotjosh
25c07ff85e
Alerting: Wrap legacy alerting metrics with legacy_ (#48190)
* Alerting: Wrap legacy alerting metrics with `legacy_`
2022-04-25 17:19:36 +02:00
Yuriy Tseretyan
75ba4e98c6
Alerting: Remove unused features from ticker + metric + tests (#47828)
* remove not used code:
  - remove offset in ticket because it is not used
  - remove unused ticker and scheduler methods

* use duration for interval
* add metrics grafana_alerting_ticker_last_consumed_tick_timestamp_seconds, grafana_alerting_ticker_next_tick_timestamp_seconds, grafana_alerting_ticker_interval_seconds
2022-04-22 15:09:47 -04:00
Yuriy Tseretyan
53a6c0210d
Alerting: tests for ticker (#47986) 2022-04-21 19:58:05 +01:00
Armand Grillet
adbe374754
Alerting: fix SCC-S1017 linting issue in codebase (#47683) 2022-04-15 09:57:45 +02:00
Santiago
5fb80498b1
Apply templating on alert notifications on OK state (#47355)
* OK notifications using previous evaluation data

* copy rule.EvalMatches to avoid changes to the underlying array

* test cases added/modified

* delete trailing newline

* fix double newline in go import

* add change to the changelog

* specify that this only affects legacy alerting (changelog)

* use current eval data instead of prev eval data

* create evalMatch just once

* code comments, renamings, getTemplateMatches() function

* changelog and docs updated
2022-04-13 17:04:10 -03:00
Serge Zaitsev
e86b6662a1
Chore: Remove bus.Bus field (#47695)
* Chore: Remove bus.Bus field

* fix integration test
2022-04-13 15:24:13 +02:00
Serge Zaitsev
18e93c7077
Chore: Remove bus (#47511)
* Chore: Remove bus

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

* fix alerting tests

* fix provide service
2022-04-08 14:30:25 +02:00
Selene
87d3c06fef
Fix: Add missing store in test rule (#46151) 2022-03-03 12:00:33 +01:00
Selene
5eaf6509c0
Dashboard Extractor: Don't fail when using default OSS implementation (#46024)
* Don't fail when using default OSS implementation

* Check correct error
2022-03-02 11:04:29 +01:00
Selene
2c90dcf3c0
Dashboard Alert Extractor: Create service for dashboard extractor and remove bus (#45518)
* Create DashAlertService service

* Remove no used dashboard service from plugin's manager that generates dependency cycle in Enterprise

* Remove bus for dashboard permissions

* Remove bus from dashboard extractor service

* Add missing argument

* Fix wire

* Fix lint

* More goimports

* Use datasource service instead sql calls

* Fix integration test
2022-02-28 09:54:56 +01:00
Peter Holmberg
4ef58e595c
Alerting: Add validation to slack contact point (#45618)
* add requiredifempty

* rename field, fix logic

* update mockdata

* remove logs

* update test

* fix json expected payload in e2e tests

* fix test

* fix test again

Co-authored-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>
2022-02-25 15:10:21 +01:00
gotjosh
8bf2e642aa
Alerting: Fix updating notification channels in legacy (#45302)
The problem here is that without the orgID we ignore the lookup of the existing notification channel just before updating and end up failing the update because there is no channel available.
2022-02-11 16:13:51 +00:00
Artur Wierzbicki
a025109647
Dash previews: populate crawler queue from SQL query (#44083)
* add SQL migrations

* dashboard previews from sql: poc

* added todos

* refactor: use the same enums where possible

* use useEffect, always return json

* added todo

* refactor + delete files after use

* refactor + fix manual thumbnail upload

* refactor: move all interactions with sqlStore to thumbnail repo

* refactor: remove file operations in thumb crawler/service

* refactor: fix dashboard_thumbs sql store

* refactor: extracted thumbnail fetching/updating to a hook

* refactor: store thumbnails in redux store

* refactor: store thumbnails in redux store

* refactor: private'd repo methods

* removed redux storage, saving images as blobs

* allow for configurable rendering timeouts

* added 1) query for dashboards with stale thumbnails, 2) command for marking thumbnails as stale

* use sql-based queue in crawler

* ui for marking thumbnails as stale

* replaced `stale` boolean prop with `state` enum

* introduce rendering session

* compilation errors

* fix crawler stop button

* rename thumbnail state frozen to locked

* #44449: fix merge conflicts

* #44449: remove thumb methods from `Store` interface

* #44449: clean filepath, defer file closing

* #44449: fix rendering.Theme cyclic import

* #44449: linting

* #44449: linting

* #44449: mutex'd crawlerStatus access

* #44449: added integration tests for `sqlstore.dashboard_thumbs`

* #44449: added comments to explain the `ThumbnailState` enum

* #44449: use os.ReadFile rather then os.Open

* #44449: always enable dashboardPreviews feature during integration tests

* #44449: remove sleep time, adjust number of threads

* #44449: review fix: add `orgId` to `DashboardThumbnailMeta`

* #44449: review fix: automatic parsing of thumbnailState

* #44449: lint fixes

* #44449: review fix: prefer `WithDbSession` over `WithTransactionalDbSession`

* #44449: review fix: add a comment explaining source of the filepath

* #44449: review fix: added filepath validation

* #44449: review fixes https://github.com/grafana/grafana/pull/45063/files @fzambia

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-02-09 13:23:32 +04:00
Serge Zaitsev
43b15b92ad
Chore: Remove bus from the alerting service (#44496)
* propagate notificationservice down to the notifiers

* replace dispatch in result handler

* remove dispatch from the rule reader

* remove dispatch from eval context

* remove dispatch from alerting usage

* remove dispatch from alerting usage

* remove dispatch from notifier

* attempt to fix tests in alerting

* hello linter, my old friend; also disable some tests for now

* use mocks to fix the tests

* resolving wire providers

* make linter happy

* remove yet another bus.dispatch

* fix tests using store mock
2022-02-03 13:26:05 +01:00
Artur Wierzbicki
254c59725e
Rendering: add capabilities check (#44470)
* #44449: add feature check to rendering service

* #44449: formatting

* #44449: rename feature -> capability (https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/getCapabilities, https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities)

* #44449: refactor

* #44449: remove commented code

* Update pkg/services/rendering/capabilities.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* #44449: review fixes

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2022-01-28 21:24:15 +04:00
Artur Wierzbicki
5148250366
Rendering service - add optional RenderingSession (#44098)
* rendering service changes:
- make node-renderer request timeout configurable
- introduce optional RenderingSession providing a long-lived session key

* remove console logs

* added comment explaining empty "afterRequest" method

* fix compilation error

* update imports formatting

* Update pkg/services/rendering/interface.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* Update pkg/services/rendering/rendering.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* review fix: extract renderKey related functions/structs to auth.go

* #44449: private'd `rendering.getRequestTimeout`

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2022-01-27 02:02:19 +04:00
idafurjes
30aa24a183
Chore: Implement OpenTelemtry in Grafana (#42674)
* Separate Tracer interface to TracerService and Tracer

* Fix lint

* Fix:Make it possible to start spans for both opentracing and opentelemetry in ds proxy

* Add span methods, use span interface for rest of tracing

* Fix logs in tracing

* Fix tests that are related to tracing

* Fix resourcepermissions test

* Fix some tests

* Fix more tests

* Add TracingService to wire cli runner

* Remove GlobalTracer from bus

* Renaming test function

* Remove GlobalTracer from TSDB

* Replace GlobalTracer in api

* Adjust tests to the InitializeForTests func

* Remove GlobalTracer from services

* Remove GlobalTracer

* Remove bus.NewTest

* Remove Tracer interface

* Add InitializeForBus

* Simplify tests

* Clean up tests

* Rename TracerService to Tracer

* Update pkg/middleware/request_tracing.go

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

* Initialize tracer before passing it to SQLStore initialization in commands

* Remove tests for opentracing

* Set span attributes correctly, remove unnecessary trace initiliazation form test

* Add tracer instance to newSQLStore

* Fix changes due to rebase

* Add modified tracing middleware test

* Fix opentracing implementation tags

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-01-20 11:10:12 +01:00
Gilles De Mey
837925390f
fix: pass OrgId to alertNotification model (#43678)
fixes #43214
2022-01-05 10:19:45 +01: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
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
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
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
idafurjes
e6123bc3ef
Replace AddHandler with AddHandlerCtx in tests (#42585) 2021-12-01 15:43:31 +01: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
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
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
Selene
9f7942099b
Rendering: Add light theme for errors (#41616)
* Add light theme for error rendering

* Fix lint

* Update images and add rendering_limit_x images
2021-11-17 12:18:47 +01:00
idafurjes
d72e389d3d
Add context for GetAlertNotificationUidQuery (#41633) 2021-11-12 14:35:38 +01:00
Joan López de la Franca Beltran
44837fc592
Replace encryption.Service usages by secrets.Service (#41625)
* Replace encryption.Service by secrets.Service on expr.Service

* Replace encryption.Service by secrets.Service on live pkg

* Rename encryption.Service to encryption.Internal to clarify it must be not used
2021-11-12 12:16:39 +01:00
Marcus Efraimsson
baab021fec
Chore: Refactor usage of legacy data contracts (#41218)
Refactor usage of legacy data contracts. Moves legacy data contracts 
to pkg/tsdb/legacydata package.
Refactor pkg/expr to be a proper service/dependency that can be provided 
to wire to remove some unneeded dependencies to SSE in ngalert and other places.
Refactor pkg/expr to not use the legacydata,RequestHandler and use 
backend.QueryDataHandler instead.
2021-11-10 11:52:16 +01:00
George Robinson
d6ed5d295e
Alerting: Fix NoDataFound for alert rules using the AND operator (#41305)
This commit fixes an issue in alerting where NoDataFound is false
when using the AND operator to compare two conditions in an alert
rule and one of the conditions has no data.
2021-11-10 10:28:49 +00:00
ying-jeanne
54de1078c8
remove the global log error/warn etc functions (#41404)
* remove the global log error/warn etc functions and use request context logger whenever possible
2021-11-08 17:56:56 +01:00
ying-jeanne
a404a311da
add context in the alert_notification (#41307) 2021-11-05 16:41:24 +08:00