Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ager into feature/errors-in-notifications
  • Loading branch information
santihernandezc committed Jan 19, 2023
2 parents 6ef0570 + f59460b commit f58105d
Show file tree
Hide file tree
Showing 184 changed files with 5,816 additions and 1,620 deletions.
41 changes: 27 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
# containers with mounted volumes which isn't supported with the docker
# executor (even with setup_remote_docker).
machine:
image: ubuntu-2004:202201-02
image: ubuntu-2204:current
steps:
- checkout
- run: sudo service docker restart
Expand All @@ -18,7 +18,7 @@ jobs:
command: sudo rm -rf /usr/local/go
# Whenever the Go version is updated here, .promu.yml should also be updated.
- go/install:
version: "1.17"
version: "1.19"
- run:
name: Remove generated code
command: make clean
Expand Down Expand Up @@ -47,15 +47,15 @@ jobs:
test:
docker:
# Whenever the Go version is updated here, .promu.yml should also be updated.
- image: quay.io/prometheus/golang-builder:1.17-base
- image: quay.io/prometheus/golang-builder:1.19-base
# maildev containers are for running the email tests against a "real" SMTP server.
# See notify/email_test.go for details.
- image: djfarrelly/maildev:1.1.0
- image: maildev/maildev:1.1.0
name: maildev-noauth
entrypoint: bin/maildev
command:
- -v
- image: djfarrelly/maildev:1.1.0
- image: maildev/maildev:1.1.0
name: maildev-auth
entrypoint: bin/maildev
command:
Expand Down Expand Up @@ -104,13 +104,13 @@ jobs:
mixin:
docker:
# Whenever the Go version is updated here, .promu.yml should also be updated.
- image: quay.io/prometheus/golang-builder:1.17-base
- image: quay.io/prometheus/golang-builder:1.19-base
steps:
- checkout
- run: cd doc/alertmanager-mixin; go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest
- run: cd doc/alertmanager-mixin; go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest
- run: cd doc/alertmanager-mixin; go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
- run: cd doc/alertmanager-mixin; make lint
- run: go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest
- run: go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest
- run: go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
- run: make -C doc/alertmanager-mixin lint
workflows:
version: 2
alertmanager:
Expand All @@ -125,10 +125,21 @@ workflows:
only: /.*/
- prometheus/build:
name: build
parallelism: 8
parallelism: 3
promu_opts: "-p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386"
filters:
tags:
only: /.*/
ignore: /^v2(\.[0-9]+){2}(-.+|[^-.]*)$/
branches:
ignore: /^(main|release-.*|.*build-all.*)$/
- prometheus/build:
name: build_all
parallelism: 12
filters:
branches:
only: /^(main|release-.*|.*build-all.*)$/
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
- mixin:
filters:
tags:
Expand All @@ -138,7 +149,8 @@ workflows:
requires:
- test_frontend
- test
- build
- build_all
docker_version: "20.10.18"
filters:
branches:
only: main
Expand All @@ -147,7 +159,8 @@ workflows:
requires:
- test_frontend
- test
- build
- build_all
docker_version: "20.10.18"
filters:
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
8 changes: 6 additions & 2 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
go:
# Whenever the Go version is updated here, .travis.yml and
# .circle/config.yml should also be updated.
version: 1.17
version: 1.19
repository:
path: github.com/prometheus/alertmanager
build:
Expand All @@ -10,7 +10,11 @@ build:
path: ./cmd/alertmanager
- name: amtool
path: ./cmd/amtool
flags: -a -tags netgo
flags: -a
tags:
all:
- netgo
windows: []
ldflags: |
-X github.com/prometheus/common/version.Version={{.Version}}
-X github.com/prometheus/common/version.Revision={{.Revision}}
Expand Down
37 changes: 36 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
## 0.24.0-rc.0 / 2022-03-10
## 0.25.0 / 2022-12-22

* [CHANGE] Change the default `parse_mode` value from `MarkdownV2` to `HTML` for Telegram. #2981
* [CHANGE] Make `api_url` field optional for Telegram. #2981
* [CHANGE] Use CanonicalMIMEHeaderKey instead of TitleCasing for email headers. #3080
* [CHANGE] Reduce the number of notification logs broadcasted between peers by expiring them after (2 * repeat interval). #2982
* [FEATURE] Add `proxy_url` support for OAuth2 in HTTP client configuration. #3010
* [FEATURE] Reload TLS certificate and key from disk when updated. #3168
* [FEATURE] Add Discord integration. #2948
* [FEATURE] Add Webex integration. #3132
* [ENHANCEMENT] Add `--web.systemd-socket` flag to systemd socket activation listeners instead of port listeners (Linux only). #3140
* [ENHANCEMENT] Add `enable_http2` support in HTTP client configuration. #3010
* [ENHANCEMENT] Add `min_version` support to select the minimum TLS version in HTTP client configuration. #3010
* [ENHANCEMENT] Add `max_version` support to select the maximum TLS version in HTTP client configuration. #3168
* [ENHANCEMENT] Emit warning logs when truncating messages in notifications. #3145
* [ENHANCEMENT] Add `--data.maintenance-interval` flag to define the interval between the garbage collection and snapshotting to disk of the silences and the notification logs. #2849
* [ENHANCEMENT] Support HEAD method for the `/-/healty` and `/-/ready` endpoints. #3039
* [ENHANCEMENT] Truncate messages with the `` ellipsis character instead of the 3-dots string `...`. #3072
* [ENHANCEMENT] Add support for reading global and local SMTP passwords from files. #3038
* [ENHANCEMENT] Add Location support to time intervals. #2782
* [ENHANCEMENT] UI: Add 'Link' button to alerts in list. #2880
* [ENHANCEMENT] Add the `source` field to the PagerDuty configuration. #3106
* [ENHANCEMENT] Add support for reading PagerDuty routing and service keys from files. #3107
* [ENHANCEMENT] Log response details when notifications fail for Webhooks, Pushover and VictorOps. #3103
* [ENHANCEMENT] UI: Allow to choose the first day of the week as Sunday or Monday. #3093
* [ENHANCEMENT] Add support for reading VictorOps API key from file. #3111
* [ENHANCEMENT] Support templating for Opsgenie's responder type. #3060
* [BUGFIX] Fail configuration loading if `api_key` and `api_key_file` are defined at the same time. #2910
* [BUGFIX] Fix the `alertmanager_alerts` metric to avoid counting resolved alerts as active. Also added a new `alertmanager_marked_alerts` metric that retain the old behavior. #2943
* [BUGFIX] Trim contents of Slack API URLs when reading from files. #2929
* [BUGFIX] amtool: Avoid panic when the label value matcher is empty. #2968
* [BUGFIX] Fail configuration loading if `api_url` is empty for OpsGenie. #2910
* [BUGFIX] Fix email template for resolved notifications. #3166
* [BUGFIX] Use the HTML template engine when the parse mode is HTML for Telegram. #3183

## 0.24.0 / 2022-03-24

* [CHANGE] Add the `/api/v2` prefix to all endpoints in the OpenAPI specification and generated client code. #2696
* [CHANGE] Remove the `github.com/prometheus/alertmanager/client` Go package. #2763
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Simon Pasquier <[email protected]> @simonpasquier
* Andrey Kuzmin <[email protected]> @w0rm
* Josue Abreu <[email protected]> @gotjosh
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SWAGGER = docker run \
--user=$(shell id -u $(USER)):$(shell id -g $(USER)) \
--rm \
-v $(shell pwd):/go/src/github.com/prometheus/alertmanager \
-w /go/src/github.com/prometheus/alertmanager quay.io/goswagger/swagger:v0.24.0
-w /go/src/github.com/prometheus/alertmanager quay.io/goswagger/swagger:v0.30.3

api/v2/models api/v2/restapi api/v2/client: api/v2/openapi.yaml
-rm -r api/v2/{client,models,restapi}
Expand Down
84 changes: 17 additions & 67 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,6 @@ GO_VERSION ?= $(shell $(GO) version)
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')

GOVENDOR :=
GO111MODULE :=
ifeq (, $(PRE_GO_111))
ifneq (,$(wildcard go.mod))
# Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
GO111MODULE := on

ifneq (,$(wildcard vendor))
# Always use the local vendor/ directory to satisfy the dependencies.
GOOPTS := $(GOOPTS) -mod=vendor
endif
endif
else
ifneq (,$(wildcard go.mod))
ifneq (,$(wildcard vendor))
$(warning This repository requires Go >= 1.11 because of Go modules)
$(warning Some recipes may not work as expected as the current Go runtime is '$(GO_VERSION_NUMBER)')
endif
else
# This repository isn't using Go modules (yet).
GOVENDOR := $(FIRST_GOPATH)/bin/govendor
endif
endif
PROMU := $(FIRST_GOPATH)/bin/promu
pkgs = ./...

Expand All @@ -78,19 +55,22 @@ ifneq ($(shell which gotestsum),)
endif
endif

PROMU_VERSION ?= 0.13.0
PROMU_VERSION ?= 0.14.0
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz

SKIP_GOLANGCI_LINT :=
GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v1.45.2
GOLANGCI_LINT_VERSION ?= v1.50.1
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
# windows isn't included here because of the path separator being different.
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
# If we're in CI and there is an Actions file, that means the linter
# is being run in Actions, so we don't need to run it here.
ifeq (,$(CIRCLE_JOB))
ifneq (,$(SKIP_GOLANGCI_LINT))
GOLANGCI_LINT :=
else ifeq (,$(CIRCLE_JOB))
GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
else ifeq (,$(wildcard .github/workflows/golangci-lint.yml))
GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
Expand Down Expand Up @@ -150,58 +130,47 @@ common-check_license:
.PHONY: common-deps
common-deps:
@echo ">> getting dependencies"
ifdef GO111MODULE
GO111MODULE=$(GO111MODULE) $(GO) mod download
else
$(GO) get $(GOOPTS) -t ./...
endif
$(GO) mod download

.PHONY: update-go-deps
update-go-deps:
@echo ">> updating Go dependencies"
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
$(GO) get -d $$m; \
done
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
ifneq (,$(wildcard vendor))
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
endif
$(GO) mod tidy

.PHONY: common-test-short
common-test-short: $(GOTEST_DIR)
@echo ">> running short tests"
GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
$(GOTEST) -short $(GOOPTS) $(pkgs)

.PHONY: common-test
common-test: $(GOTEST_DIR)
@echo ">> running all tests"
GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
$(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)

$(GOTEST_DIR):
@mkdir -p $@

.PHONY: common-format
common-format:
@echo ">> formatting code"
GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs)
$(GO) fmt $(pkgs)

.PHONY: common-vet
common-vet:
@echo ">> vetting code"
GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
$(GO) vet $(GOOPTS) $(pkgs)

.PHONY: common-lint
common-lint: $(GOLANGCI_LINT)
ifdef GOLANGCI_LINT
@echo ">> running golangci-lint"
ifdef GO111MODULE
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
# Otherwise staticcheck might fail randomly for some reason not yet explained.
GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
else
$(GOLANGCI_LINT) run $(pkgs)
endif
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
endif

.PHONY: common-yamllint
Expand All @@ -218,28 +187,15 @@ endif
common-staticcheck: lint

.PHONY: common-unused
common-unused: $(GOVENDOR)
ifdef GOVENDOR
@echo ">> running check for unused packages"
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
else
ifdef GO111MODULE
common-unused:
@echo ">> running check for unused/missing packages in go.mod"
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
ifeq (,$(wildcard vendor))
$(GO) mod tidy
@git diff --exit-code -- go.sum go.mod
else
@echo ">> running check for unused packages in vendor/"
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
@git diff --exit-code -- go.sum go.mod vendor/
endif
endif
endif

.PHONY: common-build
common-build: promu
@echo ">> building binaries"
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
$(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)

.PHONY: common-tarball
common-tarball: promu
Expand Down Expand Up @@ -295,12 +251,6 @@ $(GOLANGCI_LINT):
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
endif

ifdef GOVENDOR
.PHONY: $(GOVENDOR)
$(GOVENDOR):
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
endif

.PHONY: precheck
precheck::

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Docker Repository on Quay](https://quay.io/repository/prometheus/alertmanager/status "Docker Repository on Quay")][quay]
[![Docker Pulls](https://img.shields.io/docker/pulls/prom/alertmanager.svg?maxAge=604800)][hub]

The Alertmanager handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct receiver integrations such as email, PagerDuty, or OpsGenie. It also takes care of silencing and inhibition of alerts.
The Alertmanager handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct [receiver integrations](https://prometheus.io/docs/alerting/latest/configuration/#receiver) such as email, PagerDuty, OpsGenie, or many other [mechanisms](https://prometheus.io/docs/operating/integrations/#alertmanager-webhook-receiver) thanks to the webhook receiver. It also takes care of silencing and inhibition of alerts.

* [Documentation](http://prometheus.io/docs/alerting/alertmanager/)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.24.0-rc.0
0.25.0
6 changes: 3 additions & 3 deletions api/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"regexp"
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestAddAlerts(t *testing.T) {

api.addAlerts(w, r)
res := w.Result()
body, _ := ioutil.ReadAll(res.Body)
body, _ := io.ReadAll(res.Body)

require.Equal(t, tc.code, w.Code, fmt.Sprintf("test case: %d, StartsAt %v, EndsAt %v, Response: %s", i, tc.start, tc.end, string(body)))
}
Expand Down Expand Up @@ -282,7 +282,7 @@ func TestListAlerts(t *testing.T) {
w := httptest.NewRecorder()

api.listAlerts(w, r)
body, _ := ioutil.ReadAll(w.Result().Body)
body, _ := io.ReadAll(w.Result().Body)

var res response
err = json.Unmarshal(body, &res)
Expand Down
Loading

0 comments on commit f58105d

Please sign in to comment.