Commit Graph

54 Commits

Author SHA1 Message Date
Simon Pasquier
0ebaeccd4b *: add missing license headers
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-05-14 17:37:13 +02:00
Simon Pasquier
75900ea62a api: remove dead code (#1367)
This is a follow-up of f825d97de4.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-05-07 18:11:36 +02:00
Simon Pasquier
383024e63d api: support more query filters (#1366)
* api: support more query filters

This change adds 2 new query filters to the /api/v1/alerts endpoint.

- active, filter out active alerts when set to 'false' (default: 'true').
- unprocessed, filter out unprocessed alerts when set to 'false'
 (default: 'true').

The default values ensure that the API behavior remains the same as
before when the query filters aren't provided.

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

* api: address comments

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-05-07 18:07:19 +02:00
Max Leonard Inden
f825d97de4
api: Deprecate api/alerts endpoint
With prometheus/prometheus commit
e114ce0ff7a1ae06b24fdc479ffc7422074c1ebe [1] Prometheus switches from
using `api/alerts` to `api/v1/alerts`. This commit is included starting
from Prometheus v0.17.0. As discussed on the prometheus-developers
mailing list [2] the deprecation period is long over.

[1] github.com/prometheus/prometheus/commit/e114ce0ff7a1ae06b24fdc479ffc7422074c1ebe
[2]
https://groups.google.com/d/msg/prometheus-developers/2CCuFTMbmAg/Qg58rvyzAQAJ

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-05-04 09:59:14 +02:00
Simon Pasquier
f53b24765d api: initialize alerts_received_total labels (#1310) 2018-04-04 10:38:17 +02:00
Simon Pasquier
b95b32821f ui: replace deprecated InstrumentHandler() (#1302)
This change replaces the deprecated InstrumentHandler function by
the equivalent functions from the promhttp package.

The following metrics are removed:

* http_request_duration_microseconds (Summary).
* http_request_size_bytes (Summary).
* http_requests_total (Counter).

And the following metrics are added instead:

* alertmanager_http_request_duration_seconds (Histogram).
* alertmanager_http_response_size_bytes (Histogram).
* promhttp_metric_handler_requests_in_flight (Gauge).
* promhttp_metric_handler_requests_total (Counter).
2018-03-28 15:28:38 +02:00
Stuart Nelson
319687ab3c Re-simplify match filters fn 2018-03-20 16:11:01 +01:00
Stuart Nelson
0c026b4387 Remove empty alert labels on ingest
The same behavior exists in prometheus. This is a
bit superfluous, but in the event people are using
old versions of prometheus or a different metric
gathering system, it's still valid to check.
2018-03-20 12:06:34 +01:00
Stuart Nelson
4c98f4b4a9 Fix matchLabels logic 2018-03-20 11:47:53 +01:00
Stuart Nelson
f5df55666b Filter empty matchers correctly 2018-03-20 10:08:58 +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
pasquier-s
29e441f88f Fix miscellaneous issues revealed by Go 1.10 (#1256)
* provider/mem: fix format verbs in tests

* api: fix format verb
2018-02-22 14:57:45 +00:00
pasquier-s
382a0d8089 api: support zero StartsAt for alerts (#1238)
When the API receives alerts where StartsAt is zero, it updates the
value to EndsAt (if not zero itself) or "now". This ensures that the
alert validation will not fail since StartsAt has to be less than or
equal to EndsAt.
2018-02-13 16:26:34 +01:00
Stuart Nelson
a552afd998 Merge branch 'master' into memberlist 2018-02-13 10:47:17 +01:00
Fabian Reinartz
3f2e00fbea cluster/api: improve metrics and cluster status 2018-02-09 11:16:00 +01:00
Fabian Reinartz
fd49dbb477 *: move to memberlist for clustering 2018-02-08 12:18:44 +01:00
conorbroderick
e8832619e0 Fixes AM wrongly counting alerts with EndTimes in the future as resolved 2018-02-07 15:52:26 +00:00
Jose Donizetti
fc9306cd7e Add expired silence validation (#1096)
* Add expired silence validation

* Add silence end time in the past validation
2018-01-21 15:29:51 +01:00
pasquier-s
364979bbf8 Display connections in the Status page (#1164)
This change shows the status of the local connections in the web UI. It
can be used to troubleshoot mesh issues.
2017-12-22 11:39:27 +01:00
Fabian Reinartz
405dbb8d9c
Fix wrong lock 2017-12-21 16:55:55 +01:00
stuart nelson
1abe4c9a56 Lock around variables used in Update()
Found two places where struct members being
updated in api.Update() where being accessed
elsewhere without locks.
2017-12-21 12:08:39 +01:00
Jose Donizetti
10ed60361d Fix silences negative filtering (#1095)
* Fix silence negative filtering

* Refactor extract filtering labels func
2017-11-15 14:29:06 -05:00
Jose Donizetti
e303646b80 Fix typo (#1103) 2017-11-15 14:25:46 -05:00
Jose Donizetti
95e80d1aa8 Add tests to receiver filtering (#1098) 2017-11-12 11:35:49 -05:00
Julius Volz
fdee5fcbfc Fix UI when no silences are present (#1090)
* Explicitly initialize silences list to avoid "null" JSON

* Wrap "No silences found" message in error box

* bindata fixup
2017-11-11 14:48:48 +01:00
Jose Donizetti
74808e40f3 Refactor silence constants (#1076)
* Refactor remove dups silence state constants

* Refactor to use const instead of string
2017-11-07 11:36:30 +01:00
Jose Donizetti
b9597f5c7b Fix negative matchers filtering (#1077) 2017-11-04 14:38:16 +01:00
Julius Volz
947970af44 Convert Alertmanager to use non-global go-kit loggers
Fixes https://github.com/prometheus/alertmanager/issues/1040
2017-10-22 00:20:40 -07:00
Carlos Alexandro Becker
26489b13ef also hide inhibited alerts (#1039)
* also hide inhibited alerts

* split inhibited and silenced
2017-10-17 10:49:59 +02:00
Conor Broderick
c56d2b5d07 Sorted silences based on current status (#1015) 2017-10-02 18:42:43 +02:00
Stuart Nelson
ad64e9f1b2 Sort alerts by their fingerprint
Seemed like an ok way to sort.
2017-09-02 11:35:17 +02:00
Łukasz Mierzwa
8e61ebf6c3 Expose alert fingerprint in the API (#786)
* Expose alert fingerprint in the API

Alert fingerprint is already provided as the value of status.inhibitedBy[] attribute that inhibited alerts have, but there's no way to get back to the alert that's inhibiting it as the fingerprint is not exposed.

* Expose alert fingerprint as ID in the list endpoint

* Rename ID to Fingerprint

* Use Fingerprint().String() in the API
2017-08-18 19:30:18 +02:00
stuart nelson
040b1f9e53 Stn/status page ohne mesh (#920)
* Render status page without mesh connection (#918)

A mesh connection was assumed, even though the
value that was being passed into the helper
function was a possibly-nil pointer. Add a check
for this, and return a nil value in that case. The
frontend finds this when decoding the json
payload, and displays the "not configured"
message.

* Update bindata
2017-07-22 12:30:19 +02:00
stuart nelson
a7009a9db7 Stn/add receiver support (#872)
Add ability to filter alerts by receiver in UI. This adds changes both in the Elm UI, as well as the Go backend.
2017-06-26 18:20:26 +02:00
Frederic Branczyk
c4c0875ba3
fix config JSON marshaling 2017-06-08 13:37:57 +02:00
Max Inden
a217e162a8 Do not expose resolved alerts & do not send resolved if never firing (#820)
Do not expose resolved alerts on the /alerts endpoint. Do not send
resolved alerts to receivers if the alerts have never been fired before.
2017-05-29 14:07:05 +02:00
Max Leonard Inden
b9acb7a63f
Add 'silenced' query param to /alerts endpoint
This adds the silenced query parameter to the /alerts API endpoint. In
addition it changes the default in the UI. Previously silenced alerts
were displayed by default. This PR hides silenced alerts by default.
2017-05-17 18:59:20 +02:00
Fabian Reinartz
d73a655bf4 Simplify silence modifications, add update endpoint (#796)
* Simplify silence modifications, add update endpoint

* vendor: add pkg/errors

* ui: Handle upserting of silences

.

* Regenerate bindata
2017-05-16 16:48:25 +02:00
Max Leonard Inden
401e440db4
Return silence state on /silences
silenceState = "expired" | "active" | "pending"
```
"status": {
  "state": "expired"
}
```
2017-05-10 12:01:21 +02:00
Max Inden
d463f1c298 Sync ui-rewrite with master (#779) 2017-05-10 11:49:02 +02:00
Max Leonard Inden
96a28bbc36
Init result slice to prevent /alerts returning null
When there are no alerts to return the api endpoint `/alerts` should
return:
```
{
  "status": "success",
  "data": []
}
```
instead of
```
{
  "status": "success",
  "data": null
}
```
2017-05-02 11:51:09 +02:00
Max Leonard Inden
ef3cc7b001
Return alert status on /alerts endpoint and enable filtering
This makes the /alerts endpoint return the alert status introduced by PR
 # 717. In addition it enables alert filtering via matchers like on the
/alerts/groups endpoint.
2017-05-02 09:46:20 +02:00
Tom Wilkie
ba4fc17307 Remove use of route.Context 2017-04-25 17:43:01 -07:00
Fabian Reinartz
b1486ca546 silence: move to gogoproto
This generates the protobuf Go code with gogoproto and switches to
standard library time types.
2017-04-18 12:47:42 +02:00
stuart nelson
1e34f29532 Filter alerts (#633)
* Vendor dependencies.

This updates several old dependencies, removes
some that are no longer needed, and adds
`pkg/labels` from prometheus `dev-2.0` branch.

* Add metrics selector parsing code

This is a temporary simplified re-implementation
of promQL's metric selector parsing.

* Add alerts filtering

Filter alerts through `?filter=` query string.

* Add silences filtering

Filter silences through `?filter=` query string.

* Move `parse` to `pkg/parse`
2017-03-16 11:16:10 +01:00
Max Inden
fced9e126b api: Expose mesh status (#644)
* api: Expose mesh status

The weaveworks mesh package reveals information about the current status
of the mesh network between alertmanager instances. This commit exposes
the current address and connection status of each instance connected to
the targeted alertmanager instance via the /status API endpoint.

* api: Replace LocalConnectionStatus with PeerStatus

Now meshStatus contains all peers (Name, NickName, UID) of the network.
Additionally adding Name and Nickname of current target to toplevel of
meshNetwork object.
2017-03-07 18:17:03 +01:00
stuart nelson
0ecc59076c Add DELETE to acceptable cors methods 2017-02-22 13:55:57 +01:00
Matt Bostock
890f148a27 Prevent panic on failed config load
Prevent Alertmanager from panicking when the configuration cannot be
loaded.

Spotted in version 0.4.2:

    INFO[0000] Starting alertmanager (version=0.4.2, branch=HEAD, revision=9a5ab2fa63dd7951f4f202b0846d4f4d8e9615b0)  source=main.go:84
    INFO[0000] Build context (go=go1.7.3, user=root@45f28166fed1, date=20170117-13:50:50)  source=main.go:85
    INFO[0000] Loading configuration file                    file=alertmanager.yml source=main.go:156
    ERRO[0000] error: yaml: line 64: could not find expected ':'  source=api.go:115
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x401adb]

    goroutine 1 [running]:
    panic(0x83e240, 0xc42000e020)
            /usr/local/go/src/runtime/panic.go:500 +0x1a1
    main.(*API).Update(0xc4200b20f0, 0xc42019f800, 0x17e7, 0x45d964b800)
            /go/src/github.com/prometheus/alertmanager/api.go:117 +0xcb
    main.main.func3(0x0, 0x0)
            /go/src/github.com/prometheus/alertmanager/main.go:172 +0x226
    main.main()
            /go/src/github.com/prometheus/alertmanager/main.go:192 +0x97a
    make: *** [run] Error 2
2017-01-17 14:59:11 +00:00
Fabian Reinartz
d7843ad6a6 Export parsed configuration as JSON and drop js-yaml dependency. (#563)
* Export parsed configuration as JSON in /api/v1/status.
* Avoid exporting the XXX fields.
* Drop js-yaml library and use already parsed configuration.
* Go fmt + go-bindata
2016-11-22 15:05:14 +01:00