Commit Graph

885 Commits

Author SHA1 Message Date
Arve Knudsen
b79e61656a
Introduce TSDB service (#31520)
* Introduce TSDB service

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-03-08 07:02:49 +01:00
Labesse Kévin
bd0d051438
Alerting: PagerDuty: adding current state to the payload (#29270)
* adding state to the payload

* fix test

* fix linter

* documentation payload current state

* Apply suggestions from code review

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
2021-03-02 17:50:51 +01:00
Levi Harrison
d3a590ca19
Alerting: Fix bug in Discord for when name for metric value is absent (#31257)
* Make sure Metric field in Discord notification is never empty

Discord uniquely does not send the alert if the metric field is empty, which can happen in some cases, such as when the legend is {{hostname}}.

Signed-off-by: Levi Harrison <levisamuelharrison@gmail.com>

* Changed name of empty metric in Discord alert

Signed-off-by: Levi Harrison <levisamuelharrison@gmail.com>
2021-03-02 11:37:35 +02:00
M4t3o
0bb4cbdb68
Alerting notifier SensuGo: improvements in default message (#31428)
* add related metrics as default message

* fix CI linter error
2021-02-25 10:52:34 +01:00
Levi Harrison
e0a6854c36
Correct name of Discord notifier tests (#31277) 2021-02-17 17:24:07 +01:00
Ricky Putra
e21f6a29b7
Alerting: Fix so that sending an alert with the Alertmanager notifier doesn't fail when one of multiple configured URL's are down (#31079)
Fixes behaviour of Notify that returns error when one of the dispatch 
event return error, to maintain high availability, we should return error 
when all dispatched events return error instead.

Fixes #30509
2021-02-11 15:13:53 +01:00
Joan López de la Franca Beltran
6415d2802e
Plugins: Requests validator (#30445)
* Introduce PluginRequestValidator abstraction with a NoOp implementation

* Update PluginRequestValidator abstraction to use the dsURL instead

* Inject PluginRequestValidator into the HTTPServer and validate requests going through data source proxy

* Inject PluginRequestValidator into the BackendPluginManager and validate requests going through it

* Validate requests going through QueryMetrics & QueryMetricsV2

* Validate BackendPluginManager health requests

* Fix backend plugins manager tests

* Validate requests going through alerting service

* Fix tests

* fix tests

* goimports

Co-authored-by: Leonard Gram <leo@xlson.com>
2021-02-03 20:47:45 +01:00
Ash Caire
4ed283e7bf
Alerting: Customise OK notification priorities for Pushover notifier (#30169)
* pushover: Customise OK notification priorities

* Apply suggestions from code review

* Fix build failure

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Update pkg/services/alerting/notifiers/pushover.go

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

* Update docs

* Apply suggestions from code review

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
2021-02-03 10:57:18 +02:00
Silje Enge Kristensen
c91db6ae17
Chore: fix spelling mistake (#30473) 2021-01-21 09:17:46 +01:00
Will Browne
c9da053e5d
Alerting: Evaluate data templating in alert rule name and message (#29908)
* evaluate Go style template

* inlince func

* add test case

* PR feedback and add tests for templte data map func

* Add test case

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* do regex check

* ensure ecape

* small cleanup

* dont exit on template execution errors

* add info tooltip

* add docs

* switch from go tmpl to regex

* update docs/comments

* update tooltip wording

* update docs wording

* add simple test

* avoid .MustCompile

* point to labels in docs

* update docs

* fix docs links

* remove line

* fix lint

* add note about multiple labels

* propagate labels for CM

* update docs

* remove whitespace

* update task title

* update docs

* pr feedback

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-01-19 22:02:44 +01:00
Kyle Brandt
1c1a800bc0
API: Add by UID routes for data sources (#29884)
- also add Get by UID+OrgID to datasource cache
- Refactor backend commands for Delete and Get to be unified
2021-01-13 13:16:27 -05:00
ying-jeanne
2a9c625c9f
Alerting: improve alerting default datasource search when extracting alerts (#29993)
* improve alerting search datasource

* correct the xorm get usage

* adding default datasource unittest
2021-01-07 21:33:17 +01:00
Sofia Papagiannaki
3cac10e598
AlertingNG: Create a scheduler to evaluate alert definitions (#29305)
* Always use cache: stop passing skipCache among ngalert functions

* Add updated column

* Scheduler initial draft

* Add retry on failure

* Allow settting/updating alert definition interval

Set default interval if no interval is provided during alert definition creation.
Keep existing alert definition interval if no interval is provided during alert definition update.

* Parameterise alerting.Ticker to run on custom interval

* Allow updating alert definition interval without having to provide the queries and expressions

* Add schedule tests

* Use xorm tags for having initialisms with consistent case in Go

* Add ability to pause/unpause the scheduler

* Add alert definition versioning

* Optimise scheduler to fetch alert definition only when it's necessary

* Change MySQL data column to mediumtext

* Delete alert definition versions

* Increase default scheduler interval to 10 seconds

* Fix setting OrgID on updates

* Add validation for alert definition name length

* Recreate tables
2020-12-17 16:00:09 +02:00
Will Browne
af47d28499
Alerting: Copy frame field labels to time series tags (#29886)
* Alerting: Copy frame field labels to time series tags

* keep comment

* add test case
2020-12-16 18:07:45 +01:00
Arve Knudsen
c2cad26ca9
Chore: Disable default golangci-lint filter (#29751)
* Disable default golangci-lint filter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix linter warnings

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-15 09:32:06 +01:00
Will Browne
3de091edf1
Alerting: Use correct time series name override from frame fields (#29693)
* cater for empty labels and new DisplayNameFromDS field

* simplify

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* increase priority for ds display name

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-08 22:04:05 +01:00
Arve Knudsen
f326b79cc1
Security: Add gosec G304 auditing annotations (#29578)
* Security: Add gosec G304 auditing annotations

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* Add gosec annotations

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* Add gosec annotations

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* add G304 auditing comment

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* Add gosec annotations

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* space

Signed-off-by: bergquist <carl.bergquist@gmail.com>

* Add gosec annotations

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: bergquist <carl.bergquist@gmail.com>
2020-12-03 22:13:06 +01:00
Arve Knudsen
f2b7fbc32a
Chore: Check errors from Close calls (#29562)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-03 10:11:14 +01:00
Arve Knudsen
58dbf96a12
Middleware: Rewrite tests to use standard library (#29535)
* middleware: Rewrite tests to use standard library

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-03 08:28:54 +01:00
Tomo Wang
d33c4e5e7c
Alarting: fix alarm messages in dingding (Fixes #29470) (#29482) 2020-12-02 11:09:49 +01:00
Arve Knudsen
f55818ca70
Chore: Enable exhaustive linter (#29458)
* Chore: Enable exhaustive linter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-01 09:53:27 +01:00
Todd Campbell
643f790753
Alerting: Add support for Sensu Go notification channel (#28012)
* Add support for Sensu Go notification channel

Similar to current support for the older "Core" version of
Sensu, this commit add support for the newer version.

Closes #19908

Signed-off-by: Todd Campbell <todd@sensu.io>

* fix linter errors

Signed-off-by: Todd Campbell <todd@sensu.io>

* Apply suggestions from code review

PR review suggestions

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix no new variables error

* Replace convey testing with testify

Signed-off-by: Todd Campbell <todd@sensu.io>

* Wording suggestions

Signed-off-by: Todd Campbell <todd@sensu.io>

* Add docker compose environment for testing/maintenance

Signed-off-by: Todd Campbell <todd@sensu.io>

* Renamed and fixed docker-compose.yaml to work in devenv

Signed-off-by: Todd Campbell <todd@sensu.io>

* Change sensugo web UI port to 3080 so as not to conflict with grafana

Signed-off-by: Todd Campbell <todd@sensu.io>

* Apply suggestions from code review

Set the API key as a secure value.

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

* Add Sensu Go information to notifications doc

Signed-off-by: Todd Campbell <todd@sensu.io>

* Update pkg/services/alerting/notifiers/sensugo.go

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

* change assert to require for Error/NoError tests

Signed-off-by: Todd Campbell <todd@sensu.io>

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
2020-11-27 19:09:24 +02:00
Carl Bergquist
cffc1b13ad
adds tracing for all bus calls that passes ctx (#29434)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2020-11-27 14:58:45 +01:00
Will Browne
d10a8b2761
Alerting: Improve Prometheus Alert Rule error message (#29390)
* provide better ctx for prom err

* rework

* Update pkg/tsdb/prometheus/prometheus.go

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Update pkg/tsdb/prometheus/prometheus.go

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* call func

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-26 13:38:36 +01:00
Arve Knudsen
063f863abc
WebhookNotifier: Convert tests away from goconvey (#29291)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-23 10:37:53 +01:00
Arve Knudsen
9593d57914
Chore: Enable errorlint linter (#29227)
* Enable errorlint linter
* Handle wrapped errors

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2020-11-19 14:47:17 +01:00
Arve Knudsen
4dd7b7a82d
Chore: Remove unused Go code (#28852)
* Chore: Remove more unused Go code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-17 11:51:31 +01:00
Arve Knudsen
676d393ec9
Chore: Fix issues reported by staticcheck; enable stylecheck linter (#28866)
* Chore: Fix issues reported by staticcheck

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Apply suggestions from code review

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2020-11-05 15:37:11 +01:00
Arve Knudsen
7897c6b7d5
Chore: Fix staticcheck issues (#28854)
* Chore: Fix issues reported by staticcheck

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Undo changes

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-05 11:57:20 +01:00
Arve Knudsen
dff84f6a31
Chore: Remove dead code (#28664)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-05 11:00:00 +01:00
Sofia Papagiannaki
48e753d888
Alerting: Log alert warnings for obsolete notifiers when extracting alerts and remove spammy error (#28162)
* Lower level of notification translation messages

* API: Log alert warnings when saving dashboard

* Remove spammy error

* Rename function parameter

* Apply suggestions from code review

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Apply suggestions from code review

* Fix test

* Change alertValidator return type

* Small fix

* Rename symbol

* Revert "Rename symbol"

This reverts commit 40b619b21a.

* Revert "Small fix"

This reverts commit 2df8319d1d.

* Revert "Change alertValidator return type"

This reverts commit ad933863e3.

* Revert "Fix test"

This reverts commit f728ece2db.

* Revert "Apply suggestions from code review"

This reverts commit f35c5f52af.

* Revert "Apply suggestions from code review"

This reverts commit 7f95800c5f.

* Revert "Rename function parameter"

This reverts commit 95d3e75b00.

* Revert "API: Log alert warnings when saving dashboard"

This reverts commit 1ac5c3f281.

* Conditionally log translation failures

* Fix issue causing test to fail

* Fix test

* Log instead of propagating translations failures due to database errors

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-10-22 14:43:12 +03:00
Kyle Brandt
e16637793d
Alerting: Add labels to name when converting data frame to series (#28085)
* also move conversion func to alerting package since it is not used in other places

Fixes #28068
2020-10-09 08:21:16 -04:00
Harald Kubota
81bf9fc278
LINE Notify to have Alerts and OK notifications (#27639)
* Get Alerts AND OKs for LINE Notify

* Get Alerts AND OKs for LINE Notify

* Get Alerts AND OKs for LINE Notify
2020-09-24 15:45:53 +02:00
Arve Knudsen
a5d9196a53
Chore/fix lint issues (#27704)
* Chore: Fix linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-09-22 16:22:19 +02:00
Alvaro Olmedo Rodriguez
20292bdb0e
Alerting: Ensuring notifications displayed correctly in mobile device with Google Chat (#27578)
* Added previewText to Google Chat notifier
2020-09-18 09:41:34 +03:00
Marcus Efraimsson
91a8937e6c
Alerting: Fix integration key so it's stored encrypted for Pagerduty notifier (#27484)
Fixes an issue introduced by migration in #25980 which 
removed storing the Pagerduty integrating key encrypted.
2020-09-10 17:43:49 +02:00
Peter Holmberg
400aafa3b3
Migration: Edit notification channel (#25980)
* implement edit page

* connectWithCleanup

* remove angular related code

* use loadingindicator

* use the correct loading component

* handle secureFields

* fixed implementation of secure fields

* Keep secureFields after rerendering the form

* CollapsableSection and Page refactor

* use checkbox instead of switch

* fix comment

* add cursor to section

* Fixed issues after PR review

* Fix issue with some settings being undefined

* new reducer and start with test

* algorithm to migrate secure fields

* UX: Minor UI Tweaks

* Added field around checkboxes, and missing required field

* fixed test

* tests for util

* minor tweaks and changes

* define as records

* fix typ error

* forward invalid to textarea and inputcontrol

* merge formdata and redux data in test

* fix issue with creating channel

* do not figure out securefields in migration

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-09-09 12:46:19 +02:00
robert lestak
d0e980c2fa
Alerting: Change Panel Edit link to Panel View link (#27378)
Enables alerts to be sent to users who do not have edit permissions.

Addresses Issue: https://github.com/grafana/grafana/issues/26014
2020-09-08 07:01:48 +02:00
Arve Knudsen
4b1eb6e5c7
Chore: Enable gocyclo linter (#26395)
* Chore: Enable gocyclo linter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* API: Fix linting issue

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* API: Refactor to reduce complexity

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix type assertion

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-09-07 22:10:06 +02:00
Andrei Lavrov
8253b9ddb3
Alerting: override PagerDuty 'dedup_key' via tags (#27356)
* Alerting: override PagerDuty 'dedup_key' via tags

Added ability to override PagerDuty 'dedup_key' via Alert tags

Updated unit tests

* Updated documentation

* add comma

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* add space

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
2020-09-07 18:42:06 +02:00
Will Browne
9feaa91bf5
Alerting: Store sensitive settings encrypted for Telegram notifier (#27122)
* encrypt bot token

* update docs

* re-add uploadImage to docs
2020-08-25 14:35:57 +02:00
Will Browne
daaa3e571b
Alerting: Store sensitive settings encrypted for Threema notifier (#27160)
* encrypt API secret

* update docs
2020-08-24 16:49:45 +02:00
Will Browne
30d6405c53
Alerting: Store sensitive settings encrypted for Pushover notifier (#27159)
* encrypt api + user keys

* update docs

* fix decrypt steps
2020-08-24 16:49:30 +02:00
Will Browne
bbbbf9ac42
Alerting: Store sensitive settings encrypted for LINE notifier (#27157)
* encrypt token

* update docs
2020-08-24 16:49:10 +02:00
Will Browne
ed6f0663c2
Alerting: Store sensitive settings encrypted for Sensu notifier (#27131)
* encrypt password

* update docs
2020-08-24 16:48:55 +02:00
Will Browne
9f2386a219
Alerting: Store sensitive settings encrypted for OpsGenie notifier (#27074)
* encrypt OpsGenie API key

* make whitespace consistent

* update docs
2020-08-20 16:05:48 +02:00
Kyle Brandt
96babf1268
Alerting: copy queryType prop to tsdb.Query (#27053)
fixes #27048
2020-08-19 10:03:39 -04:00
Arve Knudsen
16c185c3b9
Chore: Drop xerrors dependency (#26718)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-31 09:45:20 +02:00
Arve Knudsen
415638cdda
Chore: Use interfaces where possible (#26392)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-23 08:17:20 +02:00
Arve Knudsen
4c56eb3991
Chore: Enable goprintffuncname and nakedret linters (#26376)
* Chore: Enable goprintffuncname linter
* Chore: Enable nakedret linter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-23 08:14:39 +02:00
Mitsuhiro Tanda
528a61b86b
Alerting: Store sensitive settings encrypted for alertmanager notifier (#26318)
Ref #25967
2020-07-17 13:56:06 +02:00
Arve Knudsen
d4e4cb4c71
Chore: Enable Go linter gocritic (#26224)
* Chore: Enable gocritic linter

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-16 14:39:01 +02:00
Mitsuhiro Tanda
92767f00e0
Alerting: Store sensitive settings encrypted for pagerduty notifier (#26319)
Store pagerduty integration key in secure setting.

Ref #25967
2020-07-16 10:53:35 +02:00
Marcus Efraimsson
c91e5adfcc
Alerting: Don't encrypt username for webhook notifier (#26170)
Can be hard for users to understand what user is configured
when encrypting the username field why this reverts to
store the username in cleartext.
Also, we don't encrypt username for data sources.

Ref #25967
2020-07-08 19:13:59 +02:00
Marcus Efraimsson
3223d4b419
Alerting: Store sensitive settings encrypted for webhook notifier (#26164)
Store sensitive settings (username and password) encrypted for webhook notifier.

Ref #25967
2020-07-08 17:46:34 +02:00
Mitsuhiro Tanda
292c985b76
Alerting: Support storing sensitive notifier settings securely/encrypted (#25114)
Support storing sensitive notification settings securely/encrypted.
Move slack notifier url and api token to secure settings.
Migrating slack notifier to store token and url encrypted is currently 
a manual process by saving an existing slack alert notification channel.
saving an existing slack alert notification channel will reset the stored 
non-secure url and token.

Closes #25113
Ref #25967

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2020-07-08 10:17:05 +02:00
Arve Knudsen
41d432b5ae
Chore: Enable whitespace linter (#25903)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-07-06 20:17:28 +02:00
Arve Knudsen
3651a8e976
Chore: Disable scopelint for tests (#25923)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-06-30 11:05:47 +02:00
Arve Knudsen
d1e6214a4a
Chore: Enable scopelint Go linter (#25896)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-06-29 17:04:38 +02:00
Peter Holmberg
6465b2f0a3
Migration: Migrate New notification channel page (#25265)
* creating page

* add types select

* adding switches

* start with converting angular templates to json

* converting more alert channels to new format

* convert remaining channels

* typing the form

* add validation, update models

* fix default value in type select

* fix type

* fix issue with validation rule

* add missing settings

* fix type errors

* test notification

* add comments to structs

* fix selectable value and minor things on each channel

* More typings

* fix strictnull

* rename ModelValue -> PropertyName

* rename show -> showWhen

* add enums and adding comments

* fix comment

* break out channel options to component

* use try catch

* adding default case to OptionElement if element not supported
2020-06-29 13:39:12 +02:00
Mitsuhiro Tanda
9f82cd4713
Slack: Support use of chat.postMessage (#25818)
* set bearer token if token is provided
* update slack notification document

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-06-26 20:47:06 +02:00
Marcus Efraimsson
53175a41c9
Make tsdb dataframes response able to carry encoded/decoded frames (#25454)
Make tsdb dataframes response able to carry encoded and/or decoded frames
2020-06-09 13:13:06 +02:00
Sofia Papagiannaki
1e543d5ac1
Alerting: Ignore obsolete notification channels referenced by alerts (#25302)
* Ignore obsolete notification channel

* Fix tests

* Update pkg/services/alerting/rule.go
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2020-06-02 19:33:13 +03:00
Josh Soref
e4fcc39e55
Chore: spelling in Go code (#24433) 2020-06-02 14:42:34 +02:00
Arve Knudsen
07582a8e85
Chore: Fix various spelling errors in back-end code (#25241)
* Chore: Fix various spelling errors in back-end code
Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>>
2020-06-01 17:11:25 +02:00
Andrew Burian
a0e5f51d05
Alerting: Remove message from PagerDuty summary field (#24813)
closes #16930
2020-05-25 21:01:29 +02:00
Victor Coutellier
3a0f2dc160
Alerting: Adds support for multiple URLs in Alertmanager notifier (#24196)
* Alerting: Adds support for multiple URLs in Alertmanager notifier

Adds support for multiple URLs in Alertmanager notifier following
alertmanager documentation for high availability setup.
Update the documentation for alertmanager notifier.

Closes #24195

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: bergquist <carl.bergquist@gmail.com>
2020-05-20 08:49:53 +02:00
Rob Russo
9fa551cc32
Alerting: updating the victorops alerter to handle the no_data alert type (#23761) 2020-05-19 09:58:57 +02:00
Kamal Galrani
319051c70e
Capitalize Grafana in test email notification (#24770) 2020-05-17 13:57:43 +02:00
Mario Trangoni
5116420e9a
Fix misspell issues (#23905)
* Fix misspell issues

See,
$ golangci-lint run --timeout 10m --disable-all -E misspell ./...

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>

* Fix codespell issues

See,
$ codespell -S './.git*' -L 'uint,thru,pres,unknwon,serie,referer,uptodate,durationm'

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>

* ci please?

* non-empty commit - ci?

* Trigger build

Co-authored-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
2020-04-29 21:37:21 +02:00
kay delaney
f48ba11d4c
Datasource/Cloudwatch: Adds support for Cloudwatch Logs (#23566)
* Datasource/Cloudwatch: Adds support for Cloudwatch Logs

* Fix rebase leftover

* Use jsurl for AWS url serialization

* WIP: Temporary workaround for CLIQ metrics

* Only allow up to 20 log groups to be selected

* WIP additional changes

* More changes based on feedback

* More changes based on PR feedback

* Fix strict null errors
2020-04-25 22:48:20 +02:00
Marcus Efraimsson
58de0dabd4
Alerting: Upload error image when image renderer unavailable (#23713)
When Include image is enabled for an alert notification channel, but there's 
no image renderer available/installed when sending notification an error 
image will be uploaded/attached explaining that you need to install the 
Grafana Image Renderer plugin.

Ref #13802

Co-Authored-By: Arve Knudsen <arve.knudsen@gmail.com>
2020-04-24 11:35:55 +02:00
Carl Bergquist
46fd7c094b
Alertmanager: Basic auth should not be required (#23691) 2020-04-20 11:19:31 +02:00
Carl Bergquist
9652a1410b
Build: Stricter linting should break the build (#23606) 2020-04-16 16:09:27 +02:00
Marcus Efraimsson
6e313e7d37
Image Rendering: Remove PhantomJS support (#23460)
Removes all references and usage of PhantomJS #23375.
Remove direct link rendered image e2e smoke test for now.
Docker: Fix installing chrome in ubuntu custom docker image.
Improve handling of image renderer not available/installed #23593.
Add PhantomJS breaking change and upgrading notes.
Use grabpl v0.2.10.

Closes #13802

Co-authored-by: Kyle Brandt <kyle@grafana.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
2020-04-15 22:17:41 +02:00
Hugo Häggmark
2661054fe8
Hangouts: fixes notifications for alerts with empty message (#23559)
* Hangouts: fixes notifications for alerts with empty message

* Update pkg/services/alerting/notifiers/googlechat.go

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

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2020-04-14 15:02:58 +02:00
Torkel Ödegaard
5a4f690807
NewPanelEditor: Enable new edit mode (#23405)
* WIP: initial commit to transition to new edit mode

* More old edit cleanup

* Minor update

* Refactoring url edit/fullscreen state to simplify logic, now seperate states

* Fixed tests and part of the explore integration

* Updated snapshot

* Fix alert rule links

* Fixed issue going back from explore

* Updated snapshots

* Fixes and changes

* Fixed bridge srv issue

* Fixed add panel issue

* Removed console log

* Removed render

* Tests: fixes e2e smoketest

* Make description optional

* Fixed typings

* e2e fixes

* removed import

* updated snapshot

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2020-04-10 16:37:26 +02:00
Kyle Brandt
5153673884
BackendPlugins: update to sdk v0.42.0
misc cleanup
2020-04-09 15:47:30 -04:00
Carl Bergquist
15bff3114f
Usagestats: Add usage stats about what type of datasource is used in alerting. (#23125) 2020-04-02 08:45:04 +02:00
melchiormoulin
1814dc5afc
Alertmanager: Adds support for basic auth (#23231)
Add basicauth username and password to the alertmanager notifier UI
2020-04-01 09:29:28 +02:00
Marcus Efraimsson
6bd7411f04
Alerting: Only include image in notifier when enabled (#23194)
Fixes a bug when you had multiple notifiers for a rule, but not all 
had enabled to include image.

Fixes #22883
2020-03-31 00:46:01 +02:00
Andrew Burian
7d9b6a0dee
Alerting: Enable Alert rule tags to override PagerDuty Severity setting (#22736) 2020-03-23 19:32:55 +01:00
Carl Bergquist
3798ac903d
Upgrade golangci-lint and fixes some linting errors. (#22909)
Example: https://play.golang.org/p/cfPIPG3BwjJ
2020-03-23 13:37:53 +01:00
Kyle Brandt
0e09a3fe15
Alerting: support alerting on data.Frame (that can be time series) (#22812)
data.Frame (that can be series) are converted to as tsdb.TimeSeriesSlice - so new backend plugins can be shimmed into existing alerting

use sdk v0.31.0
2020-03-18 10:30:07 -04:00
Dima Ryskin
44b7f3ea1c
AlertNotifications: Translate notifications IDs to UIDs in Rule builder (#19882)
* AlertNotifications: Translate notifications IDs to UIDs in alert Rule builder

* Avoid shadowing errors, raise validation error on non-existing notification id

* create a cache for notification Uids to minimize db overhead

* add cache usage test

* avoid caching empty notification Uids

* isolate db in alert notificationUid caching tests
2020-03-18 15:00:56 +02:00
Carl Bergquist
b1e112923b
aligns the severity dropdown with other fields (#22779) 2020-03-13 14:19:35 +01:00
Vikky Omkar
066d5cf4da
Alerting: Fixed the issue/bug of diff and percent_diff functions *Breaking change* (#21338)
fixes #16270 #10129
2020-02-27 20:25:03 +01:00
Arve Knudsen
bf908424a7
Alerting: Don't include image_url field with Slack message if empty (#22372) 2020-02-21 15:43:54 +01:00
Marcus Efraimsson
d0a80c59f3
Rendering: Store render key in remote cache (#22031)
By storing render key in remote cache it will enable
image renderer to use public facing url or load
balancer url to render images and thereby remove
the requirement of image renderer having to use the
url of the originating Grafana instance when running
HA setup (multiple Grafana instances).

Fixes #17704
Ref grafana/grafana-image-renderer#91
2020-02-19 19:47:39 +01:00
Arve Knudsen
019834ae12
Alerting: Update the types of recipient supported by the Slack notifier (#22205)
* Alerting: Update types of supported Slack recipients
* Document Slack recipient requirements
2020-02-14 17:11:23 +01:00
Arve Knudsen
6f09bc9fb4
Fix mentioning Slack users/groups (#21734)
* alerting/slack: Allow mentioning users, groups, and channels separately
2020-02-11 21:43:28 +01:00
Andrii Melnyk
47314d0f13
Alerting: Handle NaN in reducers (#22053)
- Fix bug with NaN in alerting - Closes #21953
- Alert reducers (avg/max/etc) drop null values from their calculation. This change makes it so NaN values are handled in the same way as null values.
2020-02-10 19:28:07 -05:00
John Dyer
0fcb2d0b2f Alerting: Support passing tags to Pagerduty and allow notification on specific event categories (#21335)
Add support for passing tags to Pagerduty and allow notification 
on specific event categories such as Class, Group and Component.

Ref #19912, #19913

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-01-23 13:20:07 +01:00
Marcus Efraimsson
71ffd1d108
Alerting: Fix image rendering and uploading timeout preventing to send alert notifications (#21536)
* svc alerting - use a shorter ctx to upload the img
This will prevent timeout on img upload to cancel the notifications from being sent

* components img uploader - pass the ctx to aws lib

* make webdavuploader use the ctx

* make azureblobuploader use the ctx

* rename uploadImage() to renderAndUploadImage()
for better clarity about what this method work

* Use timeout + 2s for plugin renderer (same as service and phantomjs)

* Make sure that original EvalContext is updated after render and upload

* Verify notification sent even if render or image upload times out

* fix lint

* fixes after review

Co-authored-by: Edouard Hur <3418467+hekmon@users.noreply.github.com>

Fixes #21018
2020-01-17 12:07:16 +01:00
Marcus Efraimsson
492912845f
Chore: Adds basic alerting notification service tests (#21467)
Adds basic alerting notification tests. First steps towards 
getting #18011 merged.

Ref #18011
2020-01-14 17:27:16 +01:00
Sofia Papagiannaki
d135f1229d
Alerting: new min_interval_seconds options to enforce a minimum eval frequency (#21188)
* add min_interval_seconds setting to alerting config

It will let operator enforce a minimum time for the scheduler to enqueue evaluations

* Introduce UI modifications

* Update docs

Co-authored-by: Martin <uepoch@users.noreply.github.com>
2020-01-14 11:13:34 +02:00
zabullet
bcac76f5d4 Alerting: Enable setting of OpsGenie priority via a tag (#21298)
OpsGenie's model works heavily off of the priority of an alert, 
e.g. routing and escalation. Currently this plugin only supports 
the default "P3".
Setting a tag og_priority to the correct P-value, e.g. P1, P2, P3, 
P4 or P5, will call the OpsGenie API with the correct priority value 
set.
2020-01-13 21:04:24 +01:00
Alvaro Olmedo Rodriguez
abc806e17b Alerting: fallbackText added to Google Chat notifier (#21464)
Add fallbackText to Google Chat notifications. 
Definition of fallbackText: A plain-text description of the message's 
cards, used when the actual cards cannot be displayed, 
e.g. mobile notifications.

Fixes #21463
2020-01-13 20:42:52 +01:00
Marcus Efraimsson
0f0772b629
Alerting: Adds support for sending a single email to all recipients in notification channel (#21091)
When an alert is sent by e-mail, the process sends an e-mail to 
each recipient separately. This PR is a single delivery to all recipients.
For companies that use e-mail extensively, this is necessary in order 
not to overload the sending queue.

Replaces #18013
Fixes #12650

Co-authored-by: Henrique Oliveira <holiiveira@users.noreply.github.com>
2020-01-10 16:06:33 +01:00
Danilo Bargen
8a02fa7691 ThreemaNotifier: Use fully qualified status emoji (#21305) 2020-01-10 16:00:20 +01:00
Zach Bagnall
d0360de8f1 Alerting: Add configurable severity support for PagerDuty notifier (#19425)
* Pagerduty notifier: configurable severity

Instead of hardcoding `critical` make it configurable per notification channel instance.

* fix html

* Add a test to ensure default severity is correct

* Notifications doc

* Add a non-default test

* Add err check on NewJson (all tests)

* Add default severity (critical) to AlertNotificationEditCtrl class
2019-12-24 09:32:05 +02:00
michael-az
5b3ff90377 Alerting: Add more information to webhook notifications (#20420)
Adds the orgId, dashboardId and panelId of the Webhook alert notifier.
2019-12-18 14:03:59 +01:00
Christoph
8c089b98b3 PagerDuty: Fix custom_details to be a JSON object instead of a string (#21150) 2019-12-18 11:42:25 +02:00
csyangchen
34299a1bd2 Alerting: Fix panic in dingding notifier (#20378)
dingding notifier fails to send alert messages containing JSON, 
This change use map and json.Marshal to always produce valid 
JSON body.

Fixes #9771
2019-12-11 17:01:01 +01:00
Dima Ryskin
2027e1aaee AlertNotifier: Support alert tags in OpsGenie notifier (#20810)
* support alert tags in OpsGenie notifier

* update readme: OpsGenie alert tags support

* lintfix: remove redundant string formatting
2019-12-03 11:54:37 +01:00
Marcus Efraimsson
5b42bb58f6
Telegram: Check error before adding defer close of image (#20331)
Properly handles file opening error and returns before deferring 
close of file.

Fixes #20156
2019-11-13 13:33:03 +01:00
stratomonitor
4d7d13175c Alerting: Add alert_state to the kafka message Fixes #11401 (#20099)
* Notifications: Add alert_state to the kafka message Fixes #11401
2019-11-07 14:08:58 +02:00
Arve Knudsen
2a78d2a61c
pkg/services: Check errors (#19712)
* pkg/services: Check errors
* pkg/services: Don't treat context.Canceled|context.DeadlineExceeded as error
2019-10-22 14:08:18 +02:00
Abhilash Gnan
7f702f881c Alerting: All notification channels should always send (#19807)
Fixes so that all notification channels configured for an alert should 
try to send notification even if one notification channel fails to send
a notification.

Signed-off-by: Abhilash Gnan <abhilashgnan@gmail.com>

Fixes #19768
2019-10-16 09:55:51 +02:00
Andrew Rabert
8a991244d5 Alerting: Truncate PagerDuty summary when greater than 1024 characters (#18730)
Requests to PagerDuty fail with an HTTP 400 if the `summary` 
attribute contains more than 1024 characters, this fixes this.
API spec:
https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2

Fixes #18727
2019-09-20 10:39:27 +02:00
lzd
c9c0dd1ea8 Alerting: fix response popover prompt when add notification channels (#18967) 2019-09-09 14:09:21 +02:00
Sofia Papagiannaki
388d3d3714
Notification is sent when state changes from no_data to ok (#18920) 2019-09-05 18:54:27 +03:00
Kyle Brandt
364d2358d8
alerting: add lock on job to prevent a race condition (#18218)
without this lock there is a race condition between the scheduler and job processing.
2019-09-03 09:14:28 -04:00
Gali Alykoff
f942fecc52 Chore: Improve err message for notifications (#18757)
Improve message of notification json error
Fix test after change error message
2019-08-28 16:49:36 +02:00
Marcus Efraimsson
e83f55f394 Chore: Use ruleId instead of alertId as log keyword (#18738) 2019-08-27 08:40:03 +02:00
Oleg Gaidarenko
35b74a99a8
Emails: resurrect template notification (#18686)
* Emails: resurrect template notification

* Phantomjs (oh yeah, there is another dev dep phantom :-) was failing for
  the generation of the html templates so I had to update the dependencies
  in order to fix it. While doing that I update the scripts field and docs
  for it as well. yarn.lock is included

* Move splitting of the emails to separate helper function, since more services
  coming up that would need to use this functionality

* Add support for enterprise specific email letters. Probably could
  be done in the better way, but it's not a priority right now
2019-08-26 17:19:03 +02:00
Dominic Miglar
32d6740b8f Alerting: Also include configured AlertRuleTags in Webhooks (#18233)
* added alert rule tags in webhook notifications

* fix: don't include whole list of Tag objects but only key/value pairs in Webhook JSON

* marked webhook alerts to support alert rule tags
2019-08-03 17:00:40 +02:00
Dima Kurguzov
a4b0ccc138 Instrumentation: Add failed notifications metric (#18089) 2019-07-24 11:43:24 +02:00
Kyle Brandt
ea0cee4c35
alerting: more specific error when missing threshold (#18221)
fixes #18184
2019-07-22 13:23:33 -04:00
Oleg Gaidarenko
75fa1f0207 Metrics: use consistent naming for exported variables (#18134)
* Metrics: remove unused metrics

Metric `M_Grafana_Version` is not used anywhere, nor the mentioned
`M_Grafana_Build_Version`. Seems to be an artefact?

* Metrics: make the naming consistent

* Metrics: add comments to exported vars

* Metrics: use proper naming

Fixes #18110
2019-07-16 16:58:46 +02:00
Oleg Gaidarenko
caa1314f44
Build: use golangci-lint as a make command (#17739)
* Build: use golangci-lint as a make command

* Since gometalinter was deprecated in favor of golangci-lint so it was
  replaced by it. Responsibilities held by the gometalinter was moved to
  golangci-lint

* There was some changes in implementation (that was also mentioned in
  the code comment) between the tools, which uncovered couple errors
  in the code. Those issues were either solved or disabled by
  the inline comments

* Introduce the golangci-lint config, to make their
  configuration more manageable

* Build: replace backend-lint.sh script with make
2019-07-02 16:06:59 +03:00
Marcus Efraimsson
5713048f48
Alerting: Improve alert rule testing (#16286)
* tsdb: add support for setting debug flag of tsdb query

* alerting: adds debug flag in eval context

Debug flag is set when testing an alert rule and this debug
flag is used to return more debug information in test aler rule
response. This debug flag is also provided to tsdb queries so
datasources can optionally add support for returning additional
debug data

* alerting: improve test alert rule ui

Adds buttons for expand/collapse json and copy json to clipboard,
very similar to how the query inspector works.

* elasticsearch: implement support for tsdb query debug flag

* elasticsearch: embedding client response in struct

* alerting: return proper query model when testing rule
2019-06-25 08:52:17 +02:00
Carl Bergquist
1aadb4426a
metrics: expose stats about roles as metrics (#17469) 2019-06-06 16:39:35 +02:00
Thibault Chataigner
e06abb30aa Alerting: Add tags to alert rules (#10989)
Ref #6552
2019-06-06 13:29:30 +02:00
Mario Trangoni
87760d4fde Codestyle: Fix govet issues (#17178)
ref #10381

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
2019-06-04 22:00:05 +02:00
Carl Bergquist
d8736a2547
Alerting: golint fixes for alerting (#17246) 2019-06-03 10:25:58 +02:00
Abhilash Gnan
ca6151e23f Alerting: Support for configuring content field for Discord alert notifier (#17017) 2019-05-23 08:31:02 +02:00
Mario Trangoni
66ba2aa524 Fix gosimple issues (#17179)
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
2019-05-21 07:50:44 +02:00
Carl Bergquist
bfa7c3d963
alerting: golint fixes for alert notifiers. (#17167) 2019-05-20 15:23:06 +02:00
Carl Bergquist
bd5bcea5d0
alerting: fix a bunch of lint issues. (#17128) 2019-05-20 12:13:32 +02:00
Carl Bergquist
2904e2d9fe
Alertmanager: Replace illegal chars with underscore in label names (#17002)
closes #16624
2019-05-16 11:41:57 +02:00
Carl Bergquist
13f137a17d
tech: avoid alias for importing models in alerting (#17041)
ref #14679
2019-05-14 08:15:05 +02:00
zhulongcheng
2fff8f77dc move log package to /infra (#17023)
ref #14679

Signed-off-by: zhulongcheng <zhulongcheng.me@gmail.com>
2019-05-13 08:45:54 +02:00
Carl Bergquist
f001815d9d
alerting: no notification when going from nodata -> pending (#16905)
ref #16496
2019-05-07 10:34:00 +02:00
Andrej Ocenas
0433af6385
Config: Fixes bug where timeouts for alerting was not parsed correctly (#16784)
* Fix parsing of the config

* Remove unnecessary conversion

* Remove timeout modification

Co-Authored-By: aocenas <mr.ocenas@gmail.com>

* Remove unused import
2019-04-30 12:05:38 +02:00
Oleg Gaidarenko
54c1bf0cc9
Chore: a bit of spring cleaning (#16710)
* Chore: use early return technic everywhere

And enable "indent-error-flow" revive rule

* Chore: remove if-return rule from revive config

* Chore: improve error messages

And enable "error-strings" revive rule

* Chore: enable "error-naming" revive rule

* Chore: make linter happy

* Chore: do not duplicate gofmt execution

* Chore: make linter happy

* Chore: address the pull review comments
2019-04-23 11:24:47 +03:00
Hofls
c17226af95 Pushover alert, support for different sound for OK (#16525)
Closes #15889
2019-04-12 14:57:17 +02:00
Zzy
1b84a924a3 Alerting: Makes timeouts and retries configurable (#16259)
Adds new alert settings for configuring timeouts and retries named 
evaluation_timeout_seconds, notification_timeout_seconds 
and max_attempts.

Closes #16240
2019-03-29 12:58:37 +07:00
Navaneesh Kumar
5ea823a65a Fix: Alert email variable name typo fixed (#16232) 2019-03-27 09:42:20 +01:00
Torkel Ödegaard
7c81f4dfd8
fix(Alerting): Fixed alert rules with eval in day units, fixes #16174 (#16182) 2019-03-25 16:27:58 +01:00
Magnus Berglund
e6623de6b2 Rewrote creation of images tag 2019-03-20 18:59:13 +01:00
Magnus Berglund
0511095303 Added missing commas 2019-03-20 18:42:48 +01:00
Magnus Berglund
0de77598d7 Don't include non-existing image in MS Teams alert
If an image section is included in the JSON payload for MS Teams alerts
when no image URL exists, rendering of the alert in the client fails.
This change makes sure that an image section is only included in the
JSON payload if an image URL exists.

Closes #16082
2019-03-20 18:23:36 +01:00
zhulongcheng
755f60358b Add more info to victorOps alert notifications 2019-03-14 15:47:11 +08:00
genofire
6d578dd372
fix imageurl in notification test
skip unnecessary http -> https redirect, which could make problems on some notifiers
2019-03-11 00:23:07 +01:00
Torkel Ödegaard
570187384b
Merge pull request #13825 from athurg/optimize_dingding_alert_message
Optimize dingding alert message
2019-03-08 15:33:24 +01:00
Marcus Efraimsson
f21c976b27
fix discord notifier so it doesn't crash when there are no image generated 2019-03-06 17:03:14 +01:00
Marcus Efraimsson
36f3accf0d
log phantomjs output even if it timeout and include orgId when render alert 2019-03-06 13:53:23 +01:00
bergquist
8a3a3cccc3 moves metric package to /infra
ref #14679
2019-02-24 21:12:51 +01:00
Torkel Ödegaard
1adc1a6097
Merge pull request #15455 from grafana/fixed-handling-of-alert-urls
Fixed handling of alert urls with true flags
2019-02-15 16:27:23 +01:00