Commit Graph

42 Commits

Author SHA1 Message Date
Max Leonard Inden
f1b920bcc9
api: Implement OpenAPI generated Alertmanager API V2
The current Alertmanager API v1 is undocumented and written by hand.
This patch introduces a new Alertmanager API - v2. The API is fully
generated via an OpenAPI 2.0 [1] specification (see
`api/v2/openapi.yaml`) with the exception of the http handlers itself.

Pros:
- Generated server code
- Ability to generate clients in all major languages
  (Go, Java, JS, Python, Ruby, Haskell, *elm* [3] ...)
    - Strict contract (OpenAPI spec) between server and clients.
    - Instant feedback on frontend-breaking changes, due to strictly
      typed frontend language elm.
- Generated documentation (See Alertmanager online Swagger UI [4])

Cons:
- Dependency on open api ecosystem including go-swagger [2]

In addition this patch includes the following changes.

- README.md: Add API section

- test: Duplicate acceptance test to API v1 & API v2 version

  The Alertmanager acceptance test framework has a decent test coverage
  on the Alertmanager API. Introducing the Alertmanager API v2 does not go
  hand in hand with deprecating API v1. They should live alongside each
  other for a couple of minor Alertmanager versions.

  Instead of porting the acceptance test framework to use the new API v2,
  this patch duplicates the acceptance tests, one using the API v1, the
  other API v2.

  Once API v1 is removed we can simply remove `test/with_api_v1` and bring
  `test/with_api_v2` to `test/`.

[1]
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

[2] https://github.com/go-swagger/go-swagger/

[3] https://github.com/ahultgren/swagger-elm

[4]
http://petstore.swagger.io/?url=https://raw.githubusercontent.com/mxinden/alertmanager/apiv2/api/v2/openapi.yaml

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-09-04 13:38:34 +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
Simon Pasquier
0c512998ee Use Makefile.common from Prometheus (#1396)
* Include Makefile.common
* Fix the bindata.go files to make the style target happy
* Inline `.PHONY` statements

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-06-13 14:41:52 +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
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
c39a913f8a test: enable race detection (#1262)
This change enables race detection when running the tests. It also fixes
a couple of existing race conditions.
2018-02-27 18:18:53 +01:00
Andrey Kuzmin
f9e96fce3d
Use elm reactor for dev assets (#1133)
* Serve assets from elm reactor

* Update bindata.go
2017-12-10 21:59:15 +01:00
Callum Styan
ad27f483dd allow a binary name to be passed to make build, rather than only allowing build to build all binaries from .promu.yml 2017-09-10 14:30:55 -07:00
Max Leonard Inden
b3f3ecf803
Improve front-end build process
We generate binaries whenever `make build-all` is run. If they already
exist, we only regenerate them if they are outdated.

When one makes changes to the front-end and runs the single command
`make build-all` on the root level Makefile, the front-end is rebuild
accordingly.

`make build-all` will use Docker to build the front-end. If someone prefers
to install all the dev dependencies on their local machine instead, one
can add the `NO_DOCKER=true` flag.

For folks that only want to make back-end changes `ui/bindata.go` is
checked in, so they do not have to build the front-end. They still use
the `make build` command as before.
2017-07-06 13:43:10 +02:00
Max Leonard Inden
dd7ffe0515
Serve FontAwesome & Bootstrap ourself
Instead of using external CDNs for Bootstrap and FontAwesome, this patch
makes Alertmanager serve these libraries itself.
2017-06-07 22:40:18 +02:00
stuart nelson
2cf38e4c2e Fix external web url (#836)
Infer path from Navigation.Location

Build uses template, local dev uses elm-reactor

Remove unneeded local dev go server

Add script.js make target

Compiles and uglifies script.js

Before:
~570kb

After:
~170kb

Bootstrap loading state

Add trailing slash via JS & add routePrefix console param

Add Javascript script tag to `index.html` which adds a trailing slash to
the url pathname if none is present. This is done to ensure assets like
`script.js` are loaded properly.

Example without patch:
If the pathname is "mxinden.com/alertmanager" the browser will try to
download the `script.js` asset from "mxinden.com/script.js". This
request will fail.

Example with patch:
If the pathname is "mxinden.com/alertmanager", Javascript redirects the
browser to "mxinden.com/alertmanager/" and then the `script.js` asset
will be downloaded from "mxinden.com/alertmanager/script.js". This
request will succeed.

Add `-web.route-prefix` as a console parameter. This configures a
Prefix for the internal routes of web endpoints. Defaults to path of
-web.external-url like in *Prometheus*.

Trim slashes off of route prefix and add one slash at the beginning.
Make sure route prefix is not empty or just a slash before prefixing
router.
2017-06-07 22:38:39 +02:00
Andrey Kuzmin
3f60d01592 Add favicon (#839)
* Add favicon

* Fix the node version

* Update bindata.go
2017-06-01 10:13:20 +02:00
Max Inden
37bbc4c439 Merge pull request #736 from prometheus/ui-rewrite-merge-master
Update ui-rewrite with master branch
2017-04-25 17:36:55 +02:00
Max Leonard Inden
0d2b0b6bd6
Merge branch 'master' into ui-rewrite 2017-04-25 15:47:57 +02:00
Max Leonard Inden
e2898f8f4d
Exclude /ui folder from go tests 2017-04-25 15:01:07 +02:00
Max Leonard Inden
a8d7f92c66 test: Ensure bindata.go is always up to date
This adds three more steps to the Travis tests.
1. Compile Elm -> script.js
2. Bundle html.index & script.js -> bindata.go
3. Check if bindata.go hasn't changed
2017-04-25 11:33:57 +02:00
Fabian Reinartz
309c6af4b2
nflog: use alert set instead of hash for deduplication
Building a hash over an entire set of alerts causes problems, because
the hash differs, on any change, whereas we only want to send
notifications if the alert and it's state have changed. Therefore this
introduces a list of alerts that are active and a list of alerts that
are resolved. If the currently active alerts of a group are a subset of
the ones that have been notified about before then they are
deduplicated. The resolved notifications work the same way, with a
separate list of resolved notifications that have already been sent.
2017-04-13 15:13:47 +02:00
Max Leonard Inden
c3850708c1 Make assets generation deterministic
By passing "-modtime 1" flag into go-bindata command it uses the same
unix timestamp (1) for every file in the fake filesystem. Thereby every
execution of "make assets" results in the same asset outputs if the
inputs were the same. This forces us to set the "Cache-Control"
attribute to "no-cache".
2017-04-10 13:47:13 +02:00
Max Leonard Inden
0faf0f531f
Add Elm UI rewrite from github.com/stuartnelson3/am-ui with history
* Including glue between Alertmanager server and Elm UI.
* Rebuilding assets (ui/bindata.go).
* Exact commit: 'bd78de6b16bcefaacf4229304d439b33aa09cc72'
* Subdirectory: ui/app
2017-03-24 17:48:50 +01:00
stuart nelson
7987e9d5df Update format to find all .elm files 2017-01-04 18:02:49 -05:00
stuart nelson
e4d7663cb8 Add format make target 2016-11-06 21:07:17 +01:00
Steve Durrheimer
9d4dccae7c
New release process using docker, circleci and a centralized
building tool
2016-04-22 21:46:53 +02:00
Fabian Reinartz
1629e9d166 Statically compile default templates 2015-12-01 18:39:57 +01:00
Fabian Reinartz
f974dfa91f Remove 'assets' from default target
There are issues with changing timestamps for unmodified files
in go-bindata+git.
2015-11-23 16:16:07 +01:00
Fabian Reinartz
c5d77252e6 Improve button visibility in UI 2015-11-16 14:47:03 +01:00
Fabian Reinartz
d80fd26902 Add Dockerfile and target, change flag 2015-11-12 15:03:09 +01:00
Fabian Reinartz
78c6784672 Change Makefile target order 2015-11-11 15:50:19 +01:00
Fabian Reinartz
034ab0da0c Statically compile assets into binary 2015-11-11 15:34:36 +01:00
Fabian Reinartz
97c3f1f58e Add Makefile and build script 2015-09-25 14:42:14 +02:00
Fabian Reinartz
f129a30515 Remove old makefiles 2015-09-24 16:52:47 +02:00
Fabian Reinartz
4c58dc90e6 wipe everything 2015-06-30 12:34:45 +02:00
Fabian Reinartz
2e1a01b2fa switch to YAML config. 2015-06-29 18:53:47 +02:00
Julius Volz
53c131c535 Cut bugfix release 0.0.3. 2015-06-10 17:05:02 +02:00
Julius Volz
d5aa4039cb Cut Alertmanager version 0.0.2. 2015-06-09 18:53:24 +02:00
Julius Volz
aceb489817 Correct paths in "web" Makefile target. 2015-05-06 11:50:39 +02:00
Julius Volz
ea231ad7b2 Move including of Makefile.COMMON to top of Makefile.
This fixes the Makefile's default target.
2015-05-06 11:44:01 +02:00
Julius Volz
91cd73b00a Re-add config Makefile target.
This was accidentally removed in
https://github.com/prometheus/alertmanager/pull/55
2015-05-06 11:16:20 +02:00
Johannes 'fish' Ziemke
e38bb7c1c3 Use Makefile.COMMON and add generated files.go 2015-05-05 17:11:03 +02:00
Julius Volz
8655ec18b2 Use "-q" curl option to ignore any settings in ~/.curlrc. 2015-02-23 01:18:31 +01:00
Julius Volz
666a19830d Fix Makefile dependencies to work with parallelism.
This fixes https://github.com/prometheus/alertmanager/issues/34
2015-02-23 01:17:32 +01:00
Julius Volz
cbf5faaf8c Bring Makefiles into shape.
This borrows a lot of the latest changes to the node_exporter Makefile,
as well as some tricks from the Prometheus one.
2015-02-01 02:30:41 +01:00
Julius Volz
02b970b149 Show status and build information under /status.
Also add Makefile infrastructure for gathering status information.

Change-Id: Id7dcb9655d0b6024bf47d5dd41a7655df3635922
2013-08-14 18:56:41 +02:00