Commit Graph

159 Commits

Author SHA1 Message Date
Yuri Tseretyan
316870c658
Alerting: PagerDuty receiver to let user configure fields Source, Client and Client URL (#59895)
* add support for source field
* add client_url
* use real host name for source placeholder
2022-12-08 11:49:27 -05:00
Serge Zaitsev
43f40e6c7c
Chore: Replace yaml.v2 with yaml.v3 (#59897)
* replace yaml.v2 with yaml.v3

* fix a few tests due to the yaml.v3 api changes

* and another goconvey mistake in tests
2022-12-06 21:17:17 +01:00
Yuri Tseretyan
eeb57cd520
Alerting: Refactor PagerDuty and OpsGenie notifiers to use encoding/json to parse settings (#58925)
* update pagerduty and opsgenie to deserialize settings using standard JSON library
* update pagerduty truncation to use a function from Alertamanger package
* update opsgenie to use payload model (same as in Alertmanager)
2022-12-05 11:38:50 -05:00
Yuri Tseretyan
866aea0db2
Alerting: fix UI element for PagerDuty's severity field configuration (#58927)
* make severity a regular text field
* add logs + fallback to critical if empty
2022-12-05 11:02:20 -05:00
George Robinson
ec1d93c8ab
Alerting: Upload images to Slack via files.upload (#59163)
This commit makes a number of changes to how images work in Slack
notifications.

It adds support for uploading images to Slack via the files.upload
API when the contact point has a token. Images are no longer linked
via a URL if a token is present.

Each image uploaded to Slack is posted as a reply to the original
notification. Up to maxImagesPerThreadTs images can be posted as
replies before a final message is sent with:

  There are no images than can be shown here. To see the panels for
  all firing and resolved alerts please check Grafana

Incoming Webhooks cannot upload files via files.upload and so webhooks
require the image to be uploaded to cloud storage and linked via URL.
2022-12-02 09:41:24 +00:00
Alexander Weaver
1481ace528
Alerting: Fix swallowing of errors when attaching images to notifications (#59432)
* Break out image logic and add logging

* Attach alert log context to image attachment

* Fix capitalization
2022-11-29 13:18:47 -06:00
Denis Limarev
4d8287b319
Performance: add preallocation for some slice/map (#57860)
This change preallocates slices and maps where the size of the data is known before the object is created.

Co-authored-by: Joe Blubaugh <joe.blubaugh@grafana.com>
2022-11-22 20:24:36 +08:00
Yuri Tseretyan
8c72d19bcc
Alerting: Refactor MS teams, Pushover and Webhook notifiers to use encoding/json to parse settings (#56834)
* update teams
* update sensugo
* update pushover
* update webhook to use json.Number
2022-11-18 09:24:12 -05:00
Gilles De Mey
ea27eca147
Email: Use MJML email templates (#57751)
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-11-17 21:41:46 +01:00
matt abrams
74010fd05d
Admin: Fix broken links to image assets in email templates (#58729)
fix broken links to image assets
2022-11-16 14:17:39 +01:00
gotjosh
d748979048
Alerting: Implement the Webex notifier (#58480)
* Alerting: Implement the Webex notifier

Closes https://github.com/grafana/grafana/issues/11750

Signed-off-by: gotjosh <josue.abreu@gmail.com>
2022-11-11 17:27:13 +00:00
Neel
db1fd10ff1
Alerting: Append org ID to alert notification URLs (#57123) 2022-11-07 16:03:25 +00:00
Will Jordan
d581b368bd
Alerting: Remove duplicate Slack notification title (#58107)
Move mentions to a markdown-formatted pretext field
to prevent issues mixing blocks and legacy-attachment content.
2022-11-04 17:09:24 +01:00
Alex Moreno
3558cadb7e
Alerting: Add title and description to Webhook contact point (#58058)
* Add title and description to Webhook contact point

* Remove deprecation message
2022-11-03 10:52:07 +01:00
Alex Moreno
c08c14f8dd
Alerting: Add custom title to pushover contact point (#57530)
* Add custom title to pushover contact point

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

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

* Use simplejson

* Use more verbose variable names

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-10-27 19:07:01 +02:00
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
Alex Moreno
f8d12af021
Add custom title to googlechet contact point (#57517)
* Add custom title to googlechet contact point

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

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

* Use simplejson

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-10-27 16:19:48 +02:00
Alex Moreno
3d437117ad
Alerting: Add custom title to discord contact point (#57506)
* Add custom title to discord contact point

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

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

* Use simplejson

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-10-27 16:17:18 +02:00
Alex Moreno
1ab0af1eb2
Alerting: Add custom title to DingDing contact point (#57498)
* Add custom title to DingDing contact point

* Update pkg/services/ngalert/notifier/channels_config/available_channels.go

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

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

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

* Add error checking before URL templating

* Remove comment

* Use simplejson

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-10-27 16:16:36 +02:00
Alex Moreno
fb62660df7
Alerting: Add title and description to VictorOps contact point (#57458)
* Add title and description to VictorOps contact point

* Update pkg/services/ngalert/notifier/channels_config/available_channels.go

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-10-27 16:12:14 +02:00
Alex Moreno
73a9e2a115
Add title and description to Threema contact point (#57429) 2022-10-27 16:11:38 +02:00
Alex Moreno
6839154720
Alerting: Add missing custom title and description to Line contact point (#57388)
* Add title and description to Line receiver

* Fix labal names for LINE contact point
2022-10-27 15:27:04 +02:00
Alex Moreno
1dcc432537
Alerting: Add missing custom title and description fields in Kafka contact point (#57361)
* Add description and details to Kafka notifier

* Fixed testing and add new logic testing

* Add proper description to kafka contact point UI

* Update pkg/services/ngalert/notifier/channels_config/available_channels.go

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

* Update pkg/services/ngalert/notifier/channels_config/available_channels.go

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-10-27 15:25:54 +02:00
Alexander Weaver
3ddb28bad9
Find-and-replace 'err' logs to 'error' to match log search conventions (#57309) 2022-10-19 17:36:54 -04:00
Santiago
85cda0db69
Alerting: Templated URLs for webhook type contact points (#57296)
* templated URLs for webhooks

* clear tmplErr before using tmpl() again
2022-10-19 16:14:53 -03:00
aimuz
c0cc85b5f1
Alerting: Add support for wecom apiapp (#55991)
This change adds new functionality to the wecom alerting contact point. In addition to a webhook address, you can now send alerts to the wecom apiapp endpoint.

Based on https://github.com/grafana/grafana/discussions/55883

Signed-off-by: aimuz <mr.imuz@gmail.com>
2022-10-19 12:17:37 +08:00
Joe Blubaugh
c7c640d903
Alerting: Fix email image embedding on Windows. (#56766)
The email notifier was incorrectly handling Windows filepaths. This is
fixed by using the `path/filepath` package.
2022-10-13 10:24:00 +08:00
Matt
26bb139470
Fixes 48972 - Exposes channels.WebhookMessage (#56140) 2022-10-12 09:50:28 +01: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
Joe Blubaugh
13067b39da
Alerting: Update replacement of prometheus-alertmanager (#56519)
grafana.com/grafana/prometheus-alertmanager has been updated to a
version that fixes some bugs upstream. This change just updates that
dependency and a few shared ones.
2022-10-07 17:10:20 +08:00
Yuriy Tseretyan
0b3c60fc22
Alerting: Refactor notifiers VictorOps, Threema, Telegram to use encoding/json to parse settings instead of simplejson (#55779)
* update victorops
* update threema
* update telegram
2022-09-27 16:58:18 -04:00
Yuriy Tseretyan
29fdbf0354
Alerting: Refactor webhook notifier to use encoding/json to parse settings instead of simplejson (#55517)
* update webhook to use json marshaller
* make maxAlerts to be interface{}
2022-09-26 12:51:58 -04:00
Yuriy Tseretyan
57a0b6db2c
Alerting: Refactor WeCom notifier to use encoding/json to parse settings instead of simplejson (#55423) 2022-09-20 14:37:24 -04:00
Alexander Weaver
3a580dc3cd
Alerting: Extract default message embed into named constant (#55424)
* Resolve conflicts

* Combine multiple const definitions
2022-09-20 10:20:06 -05:00
Alexander Weaver
4df41972f1
Alerting: Refactor one notifier to use encoding/json to parse settings instead of simplejson (#55271)
* Create struct for Slack's receiver settings

* Remove one layer of indirection when building slack notifier

* Delete un-used struct

* Validate against settings struct instead of simplejson object

* Genericize settings marshalling

* Remove repetition between fields on notifier and fields on settings struct

* Rename unmarshal settings wrapper

* Handle comma separated strings at marshalling time rather than validation time

* Address misc review feedback
2022-09-19 17:30:16 -05: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
Ilya Galimyanov
b593d371ef
Alerting: Telegram: truncate long messages (#54339)
Truncate messages longer than 4096 characters
2022-09-06 16:47:04 +01:00
George Robinson
e163a976fa
Alerting: Fix width of Adapative Cards in Teams notifications (#53996) 2022-08-22 16:04:22 +01:00
George Robinson
c960301aa8
Alerting: Fix links in Microsoft Teams notifications (#54003) 2022-08-22 12:08:38 +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
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
gotjosh
d762de7aa7
Revert "Alerting: Add support for images in Line alerts (#50703)" (#52593)
This reverts commit 0af09b8c57.
2022-07-21 06:57:57 -04:00
George Robinson
0af09b8c57
Alerting: Add support for images in Line alerts (#50703) 2022-07-21 11:43:06 +02:00
gotjosh
b026f2bc5d
Alerting: Allow the webhook notifier to support a custom Authorization header (#52515)
* Allow the webhook notifier to support a custom Authorization header

Instead of doing something clever of re-using the existing username/password fields of Basic Authentication - I opted for two diffent fields to match the upstream Alertmanager configuration (that in turn is based of the HTTP Basic authentication).

 It'll fail if you have values for both HTTP Basic Authentication and Authorization.
2022-07-21 10:25:58 +01:00
George Robinson
094dfd0d4d
Alerting: Fix Slack push notifications (#52391)
This commit fixes push notifications for Slack which used to show "This content cannot be displayed". The text field is shown in both the message and the push notification.
2022-07-19 17:42:24 +01:00
Matthew Jacobson
efa0d90093
Alerting: Fix Teams notifier not failing on 200 response with error (#52254)
Team's webhook API does not always use the status code to communicate errors.
There are cases where it returns 200 and an error message in the body.
For example, 429 - Too Many Requests or when the message is too large.
Instead, what we should be looking for is a response body = "1".

https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-messages-using-curl-and-powershell
2022-07-14 13:15:18 -04:00
dingweiqings
119c13e666
Alerting: Add custom templated title to Wecom notifier (#51529)
* add custom title in wecom channel

* add wecom test case and setting config in ui

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

Co-authored-by: Matthew Jacobson <JacobsonMT@gmail.com>

* change version in comment

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

Co-authored-by: Matthew Jacobson <JacobsonMT@gmail.com>

* format

Co-authored-by: Matthew Jacobson <JacobsonMT@gmail.com>
2022-07-06 11:54:46 -04:00
George Robinson
6844ac9879
Alerting: Change __alertScreenshotToken__ to __alertImageToken__ (#50771) 2022-07-04 06:05:36 -04:00
George Robinson
7fea330dc1
Alerting: Remove withStoredImage and change forEachFunc (#51384) 2022-06-30 15:27:57 +01:00