Commit Graph

57 Commits

Author SHA1 Message Date
Simon Pasquier f32ad1dd8b *: enable default linters (#1861)
* *: enable default linters

* Remove direct usage of errcheck

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-04-29 10:54:40 +02:00
Simon Pasquier 9f5447bf46 Build container images for ARM32v7 and ARM64v8
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-04-16 14:41:18 +02:00
Simon Pasquier ad71e1c0f3 Makefile: remove bzr check
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-03-18 09:55:12 +01:00
Paul Gier 8688c7b9ad api/v2: move generated client code from test to api/v2 (#1792)
- Move the generated api/v2 client code out of the test directory
and into the api/v2 directory with models and restapi.
- Remove duplicate models directory
- Update tests to use api/v2 package for models and client

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-12 17:11:23 +01:00
Paul Gier 458f1d646b Makefile improvements
- make clean shouldn't print errors when files/directories have already
been removed
- add copyright header to generated api files to pass license check

Signed-off-by: Paul Gier <pgier@redhat.com>
2019-03-11 10:45:45 -05:00
Simon Pasquier a4412270ef Switch to Go 1.12
It also pins errcheck to the latest stable release and simplifies how it
gets installed.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-03-04 16:33:32 +01:00
beorn7 15ed7be846 Remove `-u` from `go get` for `errcheck`
Without the `-u`, it will load what's required in the `go.mod`
file. But with the `-u`, it will load new stuff once it's available,
which makes the build non-reproducible. (Without any change in the
`errcheck` repo, other things will happen.)

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-02-28 14:27:21 +01:00
Simon Pasquier c7de536129
*: use stdlib context (#1768)
This changes removes all usage of golang.org/x/net/context in the code
base. It also bumps a few dependencies for the same reason:
- github.com/gogo/protobuf
- go-openapi/*

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-02-26 12:18:57 +01:00
beorn7 6f0e911dd1 Fix the assets make target
Presumable, it broke with the introduction of Go modules

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-02-07 15:11:13 +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
Max Inden 37e019017b
Merge pull request #1630 from simonpasquier/go-modules
*: support Go modules
2018-11-27 15:32:13 +01:00
Max Leonard Inden f504f953c1
ui: Move /alerts to API v2
Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-11-23 12:53:48 +01:00
Simon Pasquier d2bc742474 *: support Go modules
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-11-20 16:09:40 +01:00
Max Leonard Inden e4e053b18e
ui: Move /status & /silences to API v2
This patch makes the Alertmanager UI (/status & /silences) use the
api/v2 endpoint. In addition it adds logic to generate the elm side data
model based on the OpenAPI specification.

Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
2018-11-15 13:24:26 +01:00
Simon Pasquier 3558e6fd9e Migrate from go-bindata to vfsgen (#1532)
* Migrate from go-bindata to vfsgen

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

* Ensure idempotent generation for vfsgen

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

* asset: update generated files

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

* Fix asset paths for Windows platforms

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

* Regenerate assets

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

* Add vfs wrapper that returns constant mod time

This is identical to what we had with go-bindata and avoids the extra
step of storing the identity of the complete file system in another
location.

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

* Additional cleanup

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-09-24 15:12:40 +02:00
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