Commit Graph

209 Commits

Author SHA1 Message Date
Jo Walsh 8642c0b46e Allow sending of unauthenticated SMTP requests when smtp_auth_username is not supplied (#1739)
* try a more complicated but clearer approach explicitly returning a no-auth stmp.Auth when no username is supplied in config

Signed-off-by: Jo Walsh <jowalsh@bgs.ac.uk>

* fix test to expect no error from auth if username is not supplied
Signed-off-by: Jo Walsh <jowalsh@bgs.ac.uk>

* clean up some formatting errors in surplus comments

Signed-off-by: Jo Walsh <jowalsh@bgs.ac.uk>

* keep noAuth / loginAuth functions all together

Signed-off-by: Jo Walsh <jowalsh@bgs.ac.uk>

* Address latest comments

Co-Authored-By: Jo Walsh <jowalsh@bgs.ac.uk>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-03-01 15:53:18 +01:00
beorn7 3c981a92f7 Improve `Mutes` performance for silences
Add version tracking of silences states. Adding a silence to the state
increments the version. If the version hasn't changed since the last
time an alert was checked for being silenced, we only have to verify
that the relevant silences are still active rather than checking the
alert against all silences.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-02-28 12:34:41 +01:00
beorn7 f3d9c89bbc Create a `Muter` implementation for silences
This encapsulates the logic of querying and marking silenced
alerts. It removes the code duplication flagged earlier.

I removed the error returned by the setAlertStatus function as we were
only logging it, and that's already done anyway when the error is
received from the `silence.Query` call (now in the `Mutes` method).

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-02-26 16:42:59 +01:00
Simon Pasquier b10646f9ac notify: factorize code truncating strings (#1752)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-02-11 18:07:14 +01:00
JoeWrightss b926c6935e Fix some typos in comment (#1750)
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>
2019-02-08 14:57:08 +01:00
Max Leonard Inden 09a7370572
main.go: Move marker metric registering into types/types.go
Instead of registering marker metrics inside of
cmd/alertmanager/main.go, register them in types/types.go, encapsulating
marker specific logic in its module, not in main.go. In addition it
paves the path for removing the usage of the global metric registry in
the future, by taking a local metric registerer.

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2019-02-05 14:59:22 +01:00
Stefan Büringer fc1153560d trim PagerDuty message summary to 1024 chars, add PagerDuty debug log (#1701)
PagerDuty Alerts are rejected (a 400 BadRequest is sent back from PagerDuty)
when the summary field is longer than 1024 characters
(https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2).

Signed-off-by: Stefan Bueringer <sbueringer@gmail.com>
2019-01-24 14:38:35 +01:00
Jason Roberts b02afcad63 Support adding custom fields to VictorOps notifications (#1420)
* Support adding custom fields to VictorOps notifications

* Response to feedback

* Added logic to validate victorops custom fields to config load time

* Cleanup victorops notifier of logic duplicated in config check

* rebase and further cleanup from feedback

* another grammer fix

Signed-off-by: Jason Roberts <jroberts@drud.com>
2019-01-15 11:59:05 +01:00
Simon Pasquier b676fa79c0 *: update Makefile.common with new staticcheck (#1692)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-01-04 15:37:33 +01:00
Tomas Dabasinskas cfc0d9c558 Pushover: support HTML, URL title and custom sounds (#1634)
* Support HTML inside Pushover message

Signed-off-by: Tomas Dabasinskas <tomas@dabasinskas.net>
2018-12-18 15:15:30 +01:00
Max Inden 96fce3e8ab
Merge pull request #1591 from ckressibucher/bugfix-980-smtp-auth
FIX "PLAIN" auth during notification via smtp-over-tls on port 465
2018-11-22 11:54:54 +01:00
Max Inden 9426724e4a
Merge pull request #1609 from free/fix-mime-line-length
Use quoted-printable transfer encoding for the email notifier
2018-11-14 15:11:57 +01:00
Guillaume Le Floch 108388a72f notify/email: Throw error if no auth mechanism matches (#1608)
Signed-off-by: glefloch <glfloch@gmail.com>
2018-11-09 12:45:07 +00:00
Simon Pasquier 306fd73e32 *: remove use of golang.org/x/net/context
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-11-09 10:00:23 +01:00
Alin Sinpalean 9513afbe6b Use quoted-printable transfer encoding for the email notifier. Turns out MIME has a maximum line length of 998 bytes and some SMTP servers will enforce that by inserting a newline after 998 characters, whether that's in the middle of a URL or HTML tag.
Signed-off-by: Alin Sinpalean <alin.sinpalean@gmail.com>
2018-11-07 12:46:08 +01:00
Arno Uhlig b63b560074 [notify/slack] Add name, value, SlackConfirmationField to slack action (#1557)
Signed-off-by: Arno Uhlig <arno.uhlig@sap.com>
2018-10-29 15:55:43 +01:00
Tom Wieczorek 875f6ba178 Make OpsGenie API Key a templated string. (#1594)
This is analogous of what is done for PagerDuty secrets.

Signed-off-by: Tom Wieczorek <t.wieczorek@yieldlab.de>
2018-10-23 12:53:57 +01:00
Arno Uhlig c38ac84a6d Slack notifier missing callback_id parameter (#1592)
* fix callback id in slack attachments

Signed-off-by: Arno Uhlig <arno.uhlig@sap.com>
2018-10-23 11:22:23 +02:00
Claudio Kressibucher 352b2ae093 FIX "PLAIN" auth during notification via smtp-over-tls on port 465
When creating a `NewClient`, pass only the hostname
as value for the `host` parameter, instead of `n.conf.Smarthost`,
which is hostname port.

This is the same as `smtp.Dial` does, which is called in
the else-branch.

Signed-off-by: Claudio Kressibucher <ckressibucher@graphicworks.ch>
2018-10-21 20:43:31 +02:00
Chris Mark 6eaacfe243 Changes alertmanager_notifications to count attempted notifications (#1578)
alertmanager_notifications_total is increased only on
successful notifications, and not on any attempted
notification as the current description points

Signed-off-by: Chris Mark <chrismarkou92@gmail.com>
2018-10-09 13:23:12 +01:00
Sean Houghton c9e250dab1 Add support for images and links in the PagerDuty notification config (#1559)
* Add support for images and links in the PagerDuty notification config

This only works when using the v2 API. It supports template values for all fields.

Signed-off-by: Sean Houghton <sean.houghton@activision.com>
2018-10-02 10:45:53 +02:00
Max Inden a74f94c4aa
Merge pull request #1528 from miton18/feat/notifier-email-tls-config
feat(email): support custom TLS certificates
2018-09-19 13:39:46 +02:00
miton18 e132c81c5c feat(email): support custom TLS certificates
Signed-off-by: miton18 <remi+github@collignon-ducret.fr>
2018-09-05 08:38:15 +02:00
Max Leonard Inden 1219541184
*.go: Introduce errcheck enforcing error handling
Errcheck [1] enforces error handling accross all go files. Functions can
be excluded via `scripts/errcheck_excludes.txt`.

This patch adds errcheck to the `test` Make target.

[1] https://github.com/kisielk/errcheck

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-08-30 15:47:13 +02:00
Johannes 'fish' Ziemke f443038149 Slack: Support image/thumb url in attachment (#1506)
This closes #1491

Signed-off-by: Johannes 'fish' Ziemke <github@freigeist.org>
2018-08-13 15:14:45 +02:00
stuart nelson f8b95a2e95
Correctly encode query strings in notifiers (#1516)
In moving from a plain string to url.URL, we
incorrectly were setting the query string via the
path. The `?` signaling the start of the query
string would then be escaped when the URL was
turned into a string.

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>
2018-08-13 13:33:51 +02:00
Julius Volz 6d0edbe630 Fix a bunch of unhandled errors (#1501)
...as discovered by "gosec" (many other ones reported, but not all make
a lot of sense to fix).

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2018-08-05 15:38:25 +02:00
Mike Bryant 216aa785b0 fix: Update PagerDuty API V2 to send full details on resolve (#1483)
This adds compatiblity with PagerDuty's Event rules feature, allowing resolve events to be routed based on attributes

Fixes #1440

Signed-off-by: Mike Bryant <m@ocado.com>
2018-08-01 15:57:15 +02:00
Adam Shannon 77452894b8 notify: log PagerDuty v1 response on BadRequest (#1481)
Signed-off-by: Adam Shannon <adamkshannon@gmail.com>
2018-07-30 12:25:52 +02:00
Simon Pasquier 0ccc7c9f74 config: validate URLs at config load time (#1468)
* config: validate URLs at config load time

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Address Brian and Lucas comments

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Shallow copy of URL instead of reparsing it

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Unshadow net/url package

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Make a deep-copy of URL struct

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-07-26 12:39:33 +02:00
Max Inden 81b9a83f06 notify: Improve error handling (#1474)
- `tmplText` and `tmplHTML` are using a monad-style error handling [1].
This reduces the verbosity of the error logic, but introduces the risk
of forgetting the final error check. This patch does not remove this
coding-style, but ensures proper error checking in the Email and
PagerDuty notifier.

- Ensure to handle errors returned by `multipartWriter.Close()` and
`wc.Write(buffer.Bytes())` in `Email.Notify()`.

[1] https://www.innoq.com/en/blog/golang-errors-monads/

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-07-23 14:04:40 +02:00
Mark Van De Weert 7f86d613b6 enable templating of hipchat room_id (#1463)
Signed-off-by: Mark Van De Weert <mark.vandeweert@wpengine.com>
2018-07-19 18:35:53 +02:00
Simon Pasquier d188c21fb0 notify: catch templating errors for Wechat
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-06-24 14:02:21 +02:00
Simon Pasquier 387e684faa vendor: update prometheus/common packages (#1414)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-06-13 16:11:22 +02:00
Simon Pasquier b7d891cf39 notify: notify resolved alerts properly (#1408)
* notify: notify resolved alerts properly

The PR #1205 while fixing an existing issue introduced another bug when
the send_resolved flag of the integration is set to true.

With send_resolved set to false, the semantics remain the same:
AlertManager generates a notification when new firing alerts are added
to the alert group. The notification only carries firing alerts.

With send_resolved set to true, AlertManager generates a notification
when new firing or resolved alerts are added to the alert group. The
notification carries both the firing and resolved notifications.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Fix comments

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-06-08 11:37:38 +02:00
Simon Pasquier 0ebaeccd4b *: add missing license headers
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-05-14 17:37:13 +02:00
Alex Lardschneider 1f9a7b6182 [Request] Add Slack actions to notifications (#1355)
* Added slack actions to notifications

Signed-off-by: Alex Lardschneider <alex.lardschneider@gmail.com>
2018-05-14 17:26:11 +02:00
RogerYuQian 8a0faa9946 fix wechat issue (#1353) (#1356) 2018-05-03 09:32:09 +02:00
Simon Pasquier b3cc6229a2 notify: remove wechat unit test (#1350)
The unit test was making a request to the public Wechat endpoint which
caused flaky results.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-04-30 20:01:38 +02:00
Trevor Wood cecfe5b2f5 Validate Slack field config and only allow the necessary input (#1334)
Signed-off-by: Trevor Wood <Trevor.G.Wood@gmail.com>
2018-04-25 18:58:11 +02:00
stuart nelson bc263d3e61
Improve notification instrumentation (#1335)
* Improve notification instrumentation

- Add notificationLatencySeconds histogram to
debug duplicate messages. This can help rule out
if duplicate messages are being caused by
excessive latency when sending a notification.

Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
2018-04-23 14:23:01 +02:00
Manos Fokas 300a87e85b Removed file changes to resolve conflict. (#1318)
Signed-off-by: manosf <manosf@protonmail.com>
2018-04-17 16:22:46 +02:00
pasquier-s 7b80919b36 Remove unused code (#1272) 2018-03-03 11:07:47 +01:00
Corentin Chary dd75201f1c Add /-/ready based on mesh status (#1209)
* Wait for the gossip to settle before sending notifications

See #1209 for details.

As an heuristic for mesh readyness, try to see if
the mesh looks stable (the number of peers isn't changing too much).
This implementation always mark the altermanager as ready after a maximum of 60s.

This adds one new flags to control this behavior:
```
      --cluster.settle-timeout=60s  mesh settling timeout. Do not wait more than this duration on startup.
```

It also adds `/-/ready` which always return 200 (in order to make it clear
that we are ready as soon as we can receive requests).

The mesh status is exposed in `/api/v1/status` and visible on `/#/status`.

* cluster: fix typos and base interval on gossipInterval
2018-03-02 15:45:21 +01:00
pasquier-s e8a92f65ef Run staticcheck as part of the build process (#1264)
This change also fixes potential issues highlighted by running
staticcheck.
2018-02-28 17:42:32 +01:00
Simon Pasquier 955c92f1b6 Configure http client for Wechat 2018-02-13 14:52:53 +01:00
Frederic Branczyk d678022fea *: configure http client from config 2018-02-13 14:30:59 +01:00
Stuart Nelson a552afd998 Merge branch 'master' into memberlist 2018-02-13 10:47:17 +01:00
songjiayang d07a072b08 Fix WeChat issue (#1229)
* fix wechat issue

* wechat issue code review
2018-02-11 20:09:47 +01:00
Mike Bryant 6615ed15d2 Add templating to PD-CEF fields; Add missing field (#1231)
* Allow templating of Component and Group in PagerDuty v2

Related to #1211

* Add missing PD-CEF field Component
2018-02-09 10:50:18 +01:00