Skip to content

Commit

Permalink
Merge branch 'prometheus:main' into 4xx-error-for-notification-failure
Browse files Browse the repository at this point in the history
  • Loading branch information
qinxx108 authored Jan 20, 2023
2 parents 205b802 + f59460b commit 00b8741
Show file tree
Hide file tree
Showing 159 changed files with 4,961 additions and 1,243 deletions.
10 changes: 6 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.18"
version: "1.19"
- run:
name: Remove generated code
command: make clean
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
test:
docker:
# Whenever the Go version is updated here, .promu.yml should also be updated.
- image: quay.io/prometheus/golang-builder:1.18-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: maildev/maildev:1.1.0
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
mixin:
docker:
# Whenever the Go version is updated here, .promu.yml should also be updated.
- image: quay.io/prometheus/golang-builder:1.18-base
- image: quay.io/prometheus/golang-builder:1.19-base
steps:
- checkout
- run: go install github.com/monitoring-mixins/mixtool/cmd/mixtool@latest
Expand Down Expand Up @@ -139,7 +139,7 @@ workflows:
branches:
only: /^(main|release-.*|.*build-all.*)$/
tags:
only: /^v2(\.[0-9]+){2}(-.+|[^-.]*)$/
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
- mixin:
filters:
tags:
Expand All @@ -150,6 +150,7 @@ workflows:
- test_frontend
- test
- build_all
docker_version: "20.10.18"
filters:
branches:
only: main
Expand All @@ -159,6 +160,7 @@ workflows:
- test_frontend
- test
- build_all
docker_version: "20.10.18"
filters:
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
Expand Down
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.18
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
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
## 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
Expand Down
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
9 changes: 6 additions & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -55,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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.24.0
0.25.0
39 changes: 36 additions & 3 deletions api/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/go-openapi/analysis"
"github.com/go-openapi/loads"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
Expand Down Expand Up @@ -101,9 +102,9 @@ func NewAPI(
}

// Load embedded swagger file.
swaggerSpec, err := loads.Analyzed(restapi.SwaggerJSON, "")
swaggerSpec, swaggerSpecAnalysis, err := getSwaggerSpec()
if err != nil {
return nil, fmt.Errorf("failed to load embedded swagger file: %v", err.Error())
return nil, err
}

// Create new service API.
Expand All @@ -113,7 +114,9 @@ func NewAPI(
// the API itself via RoutesHandler. See:
// https://github.com/go-swagger/go-swagger/issues/1779
openAPI.Middleware = func(b middleware.Builder) http.Handler {
return middleware.Spec("", swaggerSpec.Raw(), openAPI.Context().RoutesHandler(b))
// Manually create the context so that we can use the singleton swaggerSpecAnalysis.
swaggerContext := middleware.NewRoutableContextWithAnalyzedSpec(swaggerSpec, swaggerSpecAnalysis, openAPI, nil)
return middleware.Spec("", swaggerSpec.Raw(), swaggerContext.RoutesHandler(b))
}

openAPI.AlertGetAlertsHandler = alert_ops.GetAlertsHandlerFunc(api.getAlertsHandler)
Expand Down Expand Up @@ -672,3 +675,33 @@ func parseFilter(filter []string) ([]*labels.Matcher, error) {
}
return matchers, nil
}

var (
swaggerSpecCacheMx sync.Mutex
swaggerSpecCache *loads.Document
swaggerSpecAnalysisCache *analysis.Spec
)

// getSwaggerSpec loads and caches the swagger spec. If a cached version already exists,
// it returns the cached one. The reason why we cache it is because some downstream projects
// (e.g. Grafana Mimir) creates many Alertmanager instances in the same process, so they would
// incur in a significant memory penalty if we would reload the swagger spec each time.
func getSwaggerSpec() (*loads.Document, *analysis.Spec, error) {
swaggerSpecCacheMx.Lock()
defer swaggerSpecCacheMx.Unlock()

// Check if a cached version exists.
if swaggerSpecCache != nil {
return swaggerSpecCache, swaggerSpecAnalysisCache, nil
}

// Load embedded swagger file.
swaggerSpec, err := loads.Analyzed(restapi.SwaggerJSON, "")
if err != nil {
return nil, nil, fmt.Errorf("failed to load embedded swagger file: %w", err)
}

swaggerSpecCache = swaggerSpec
swaggerSpecAnalysisCache = analysis.New(swaggerSpec.Spec())
return swaggerSpec, swaggerSpecAnalysisCache, nil
}
35 changes: 23 additions & 12 deletions api/v2/client/alert/alert_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 00b8741

Please sign in to comment.