├── .gitignore ├── .goreleaser.yml ├── .travis.yml ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── alertmanager └── alertmanager.go ├── cmd └── main.go ├── configmap-examples ├── alertmanager-config.yaml ├── alertmanager-inhibit-rule.yaml ├── alertmanager-recevier.yaml └── alertmanager-route.yaml ├── controller └── controller.go ├── go.mod ├── go.sum └── helm ├── README.md └── charts └── alertmanager ├── Chart.yaml ├── templates ├── _helpers.tpl ├── alertmanager-dummy-config-configmap.yaml ├── alertmanager-empty-config-template-configmap.yaml ├── clusterrole.yaml ├── clusterrolebinding.yaml ├── deployment.yaml ├── ingress.yaml ├── service.yaml └── serviceaccount.yaml └── values.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | .vscode/* 3 | bin/* 4 | dist/* 5 | vendor/* 6 | scripts/saved_objects/* 7 | coverage.txt 8 | alertmanager-config-controller 9 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | --- 2 | project_name: alertmanager-config-controller 3 | 4 | release: 5 | github: 6 | owner: dbsystel 7 | name: alertmanager-config-controller 8 | 9 | builds: 10 | - binary: alertmanager-config-controller 11 | goos: 12 | - darwin 13 | - windows 14 | - linux 15 | goarch: 16 | - amd64 17 | - 386 18 | env: 19 | - CGO_ENABLED=0 20 | main: ./cmd/ 21 | ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} 22 | 23 | archive: 24 | format: tar.gz 25 | wrap_in_directory: true 26 | format_overrides: 27 | - goos: windows 28 | format: zip 29 | name_template: '{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' 30 | files: 31 | - LICENSE 32 | - README.md 33 | 34 | snapshot: 35 | name_template: SNAPSHOT-{{ .Commit }} 36 | 37 | checksum: 38 | name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt' 39 | 40 | changelog: 41 | sort: asc 42 | filters: 43 | exclude: 44 | - '^docs:' 45 | - '^test:' 46 | - '^dev:' 47 | - 'README' 48 | - Merge pull request 49 | - Merge branch 50 | 51 | dockers: 52 | - image_templates: 53 | - "dbsystel/alertmanager-config-controller:latest" 54 | - "dbsystel/alertmanager-config-controller:{{ .Tag }}" 55 | - "dbsystel/alertmanager-config-controller:{{ .Major }}.{{ .Minor }}" 56 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: required 3 | 4 | language: go 5 | go: '1.12.x' 6 | 7 | services: 8 | - docker 9 | 10 | install: 11 | - GOPATH=${TRAVIS_BUILD_DIR}/vendor/go 12 | - make setup 13 | 14 | script: 15 | - make ci 16 | 17 | after_success: 18 | - bash <(curl -s https://codecov.io/bash) 19 | - test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" 20 | 21 | deploy: 22 | - provider: script 23 | skip_cleanup: true 24 | script: curl -sL https://git.io/goreleaser | bash 25 | on: 26 | tags: true 27 | notifications: 28 | email: false 29 | 30 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.2.5 / 2022-02-23 2 | * [BUGFIX] Avoid panic: assignment to entry in nil map with empty config maps for routes 3 | 4 | # 0.2.4 / 2019-06-28 5 | * [BUGFIX] Fixed incorrect indentation in configmap examples 6 | 7 | # 0.2.3 / 2019-06-28 8 | * [BUGFIX] Disabled for now bodyclose checking in linter 9 | * [BUGFIX] Fixed addContinueIfNotExist handling route 10 | 11 | # 0.2.2 / 2019-06-13 12 | * [ENHANCEMENT] Updated ci release handling 13 | 14 | # 0.2.1 / 2019-06-11 15 | * [BUGFIX] Fixed linter errors 16 | 17 | ## 0.2.0 / 2019-06-11 18 | * [ENHANCEMENT] Adds example helm installation charts 19 | * [ENHANCEMENT] Adds test, lint and build setup 20 | * [ENHANCEMENT] Adds automatic releasing with goreleaser and travis 21 | 22 | ## 0.1.3 / 2019-05-14 23 | * [ENHANCEMENT] Automatically add `continue: true` to the first level of route 24 | * [CHANGE] The controller will delete the config, if the annotation in configmap is switched from `true` to `false` 25 | * [CHANGE] Deleted glide dep management; updated to go version 1.12; using now go.mod 26 | 27 | ## 0.1.2 / 2019-04-18 28 | * [BUGFIX] Sometimes if there is a route configuration with undefined receiver, all configurations which are made after this one will be ignored. 29 | 30 | ## 0.1.1 / 2019-03-13 31 | * [BUGFIX] Update of alertmanager.yml doesn't work properly 32 | 33 | ## 0.1.0 / 2019-03-07 34 | * [INITIAL] Initial commit of alertmanager-config-controller 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | RUN apk update \ 4 | && apk add --no-cache curl \ 5 | ca-certificates \ 6 | tzdata \ 7 | && update-ca-certificates 8 | 9 | RUN addgroup -S kube-operator && adduser -S -g kube-operator kube-operator 10 | USER kube-operator 11 | 12 | COPY alertmanager-config-controller /bin/alertmanager-config-controller 13 | 14 | ENTRYPOINT ["/bin/alertmanager-config-controller"] 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019: 190 | Lunjie Zhang, Accenture Technology Solutions GmbH, im Auftrag von PZ Reisendeninformation - Deutsche Bahn AG 191 | Daniel Ulman, DB Systel GmbH, im Auftrag von PZ Reisendeninformation - Deutsche Bahn AG 192 | 193 | Licensed under the Apache License, Version 2.0 (the "License"); 194 | you may not use this file except in compliance with the License. 195 | You may obtain a copy of the License at 196 | 197 | http://www.apache.org/licenses/LICENSE-2.0 198 | 199 | Unless required by applicable law or agreed to in writing, software 200 | distributed under the License is distributed on an "AS IS" BASIS, 201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 202 | See the License for the specific language governing permissions and 203 | limitations under the License. 204 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SOURCE_FILES?=./... 2 | TEST_PATTERN?=. 3 | TEST_OPTIONS?= 4 | BUILD_NAME?=alertmanager-config-controller 5 | 6 | export PATH := ./bin:$(PATH) 7 | export GO111MODULE := on 8 | 9 | # Install all the build and lint dependencies 10 | setup: 11 | curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh 12 | go mod download 13 | .PHONY: setup 14 | 15 | # Run all the tests 16 | test: 17 | go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m 18 | .PHONY: test 19 | 20 | # Run all the tests and opens the coverage report 21 | cover: test 22 | go tool cover -html=coverage.txt 23 | .PHONY: cover 24 | 25 | # gofmt and goimports all go files 26 | fmt: 27 | find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done 28 | .PHONY: fmt 29 | 30 | # Run all the linters 31 | lint: 32 | ./bin/golangci-lint run --tests=false --enable-all --disable=gochecknoglobals,dupl,interfacer,bodyclose ./... 33 | .PHONY: lint 34 | 35 | # Run all the tests and code checks 36 | ci: build-ci test lint 37 | .PHONY: ci 38 | 39 | # Build the controller in ci for alpine image 40 | # Note: output will be the dir root to make it work with travis deploy 41 | build-ci: 42 | GOOS=linux GOARCH=amd64 go build -v -i -o ./$(BUILD_NAME) ./cmd 43 | .PHONY: build-ci 44 | 45 | # Build the controller 46 | build: 47 | go build -v -i -o ./bin/$(BUILD_NAME) ./cmd 48 | .PHONY: build 49 | 50 | # Show to-do items per file. 51 | todo: 52 | @grep \ 53 | --exclude-dir=vendor \ 54 | --exclude=Makefile \ 55 | --text \ 56 | --color \ 57 | -nRo -E ' TODO:.*|SkipNow' . 58 | .PHONY: todo 59 | 60 | .DEFAULT_GOAL := build 61 | 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :warning: The project has been archived and is no longer maintained! 2 | 3 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 4 | [![Build Status](https://travis-ci.org/dbsystel/alertmanager-config-controller.svg)](https://travis-ci.org/dbsystel/alertmanager-config-controller) 5 | 6 | # Config Controller for Alertmanager 7 | 8 | This Config Controller is based on the [Grafana Operator](https://github.com/tsloughter/grafana-operator) project. The Config Controller should be run within [Kubernetes](https://github.com/kubernetes/kubernetes) as a sidecar with the [Prometheus Alertmanager](https://github.com/prometheus/alertmanager). 9 | 10 | It watches for new/updated/deleted *ConfigMaps* and if they define the specified annotations as `true` it will save each resource from ConfigMap to Alertmanagers local storage and reload the Alertmanager. This requires Alertmanager 0.16.x. 11 | 12 | ## ConfigMap Annotations 13 | 14 | 15 | Currently it supports three resources: 16 | 17 | **1. Receiver** 18 | 19 | `alertmanager.net/receiver` with values: `"true"` or `"false"` 20 | 21 | **2. Route** 22 | 23 | `alertmanager.net/route` with values: `"true"` or `"false"` 24 | 25 | **3. Inhibit Rule** 26 | 27 | `alertmanager.net/inhibit_rule` with values `"true"` or `"false"` 28 | 29 | **Config** 30 | 31 | `alertmanager.net/config` with values: `"true"` or `"false"` 32 | 33 | `alertmanager.net/key` with values: `string` 34 | 35 | Alertmanager will start with a provided minimal dummy config, which is definetly valid. Then the Config Controller will load the *ConfigMap* with annotation `alertmanager.net/config: true`, which includes the global Alertmanager configuration. The Config Controller will merge this configuration with the dummy configuration and only if this configuration is valid, Alertmanager will be reloaded. For each Alertmanager Setup there should be only one *ConfigMap* with annotation `alertmanager.net/config: true`. If you want to run e.g. three Alertmanagers in HA mode (replicas = 3), then all three Alertmanager will load the same ConfigMap and have the exact same config. To prevent other "nonadmin" users from misusing of `alertmanager.net/config`, a `key` is used. If and only if the `key` in *ConfigMap* matches the `key` in args of the Alertmanager Controller, the Controller will use the *ConfigMap*. 36 | 37 | **Id** 38 | 39 | `alertmanager.net/id` with values: `"0"` ... `"n"` 40 | 41 | In case of multiple Alertmanager *setups* in same Kubernetes Cluster all the ConfigMaps have to be mapped to the right Alertmanager setup. 42 | So each *ConfigMap* can be additionaly annotated with the `alertmanager.net/id` (if not, the default `id` will be `"0"`) 43 | 44 | You can run e.g. three Alertmanagers in HA mode with id=0 and for an another setup with three Alertmanagers in HA mode with id=1, and so on. 45 | 46 | **Note** 47 | 48 | Mentioned `"true"` values can be also specified with: `"1", "t", "T", "true", "TRUE", "True"` 49 | 50 | Mentioned `"false"` values can be also specified with: `"0", "f", "F", "false", "FALSE", "False"` 51 | 52 | ConfigMap examples can be found [here](configmap-examples). 53 | 54 | ## Usage 55 | ``` 56 | --run-outside-cluster # Uses local ~/.kube/config rather than in cluster configuration 57 | --reloadUrl # Sets the URL to reload Alertmanager 58 | --configPath # Sets the path to use to store config files 59 | --configTemplate # Sets the location of template of the Alertmanager config 60 | --id # Sets the ID, so the Controller knows which ConfigMaps should be watched 61 | --key # Sets the key, so the Controller can recognize the template of config in ConfigMap 62 | ``` 63 | 64 | ## Development 65 | ### Build 66 | ```sh 67 | make build 68 | # to run the linter, tests and build the binary, run 69 | make ci 70 | ``` 71 | To build a docker image out of it, look at provided [Dockerfile](Dockerfile) example which expects the `alertmanager-config-controller` binary in the same directory. 72 | 73 | ## Deployment 74 | Our preferred way to install alertmanager/alertmanager-config-controller is [Helm](https://helm.sh/). See example installation at our [Helm directory](helm) within this repo. 75 | -------------------------------------------------------------------------------- /alertmanager/alertmanager.go: -------------------------------------------------------------------------------- 1 | package alertmanager 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "net/url" 7 | "strings" 8 | "time" 9 | 10 | "github.com/go-kit/kit/log" 11 | "github.com/go-kit/kit/log/level" 12 | ) 13 | 14 | // APIClient of alertmanager 15 | type APIClient struct { 16 | URL *url.URL 17 | ConfigPath string 18 | ConfigTemplate string 19 | HTTPClient *http.Client 20 | ID int 21 | Key string 22 | logger log.Logger 23 | } 24 | 25 | // Config of alertmanager 26 | type Config struct { 27 | Receivers string 28 | Routes string 29 | InhibitRules string 30 | } 31 | 32 | // Reload alertmanager 33 | func (c *APIClient) Reload() (int, error) { 34 | return c.doPost(c.URL.String()) 35 | } 36 | 37 | // do post request 38 | func (c *APIClient) doPost(url string) (int, error) { 39 | req, err := http.NewRequest("POST", url, nil) 40 | if err != nil { 41 | return 0, err 42 | } 43 | resp, err := c.HTTPClient.Do(req) 44 | if err != nil { 45 | for strings.Contains(err.Error(), "connection refused") { 46 | //nolint:errcheck,lll 47 | level.Error(c.logger).Log( 48 | "msg", "Failed to reload alertmanager.yml. Perhaps Alertmanager is not ready. Waiting for 8 seconds and retry again...", 49 | "err", err.Error()) 50 | time.Sleep(8 * time.Second) 51 | resp, err = c.HTTPClient.Do(req) 52 | if err == nil { 53 | break 54 | } 55 | } 56 | } 57 | 58 | defer resp.Body.Close() 59 | if err != nil { 60 | return 0, err 61 | } 62 | if resp.StatusCode != http.StatusOK { 63 | //nolint:lll 64 | return resp.StatusCode, fmt.Errorf("unexpected status code returned from Alertmanager (got: %d, expected: 200, msg:%s)", 65 | resp.StatusCode, resp.Status) 66 | } 67 | return 0, nil 68 | } 69 | 70 | // New return an APIClient 71 | func New(baseURL *url.URL, configPath string, configTemplate string, id int, key string, logger log.Logger) *APIClient { 72 | return &APIClient{ 73 | URL: baseURL, 74 | ConfigPath: configPath, 75 | ConfigTemplate: configTemplate, 76 | HTTPClient: http.DefaultClient, 77 | ID: id, 78 | Key: key, 79 | logger: logger, 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | "os" 7 | "os/signal" 8 | "path/filepath" 9 | "sync" 10 | "syscall" 11 | 12 | "github.com/dbsystel/alertmanager-config-controller/alertmanager" 13 | "github.com/dbsystel/alertmanager-config-controller/controller" 14 | "github.com/dbsystel/kube-controller-dbsystel-go-common/controller/configmap" 15 | "github.com/dbsystel/kube-controller-dbsystel-go-common/kubernetes" 16 | k8sflag "github.com/dbsystel/kube-controller-dbsystel-go-common/kubernetes/flag" 17 | opslog "github.com/dbsystel/kube-controller-dbsystel-go-common/log" 18 | logflag "github.com/dbsystel/kube-controller-dbsystel-go-common/log/flag" 19 | "github.com/go-kit/kit/log/level" 20 | "gopkg.in/alecthomas/kingpin.v2" 21 | ) 22 | 23 | var ( 24 | app = kingpin.New(filepath.Base(os.Args[0]), "Alertmanager Controller") 25 | //Here you can define more flags for your application 26 | configPath = app.Flag("config-path", "The location to save rule and config files to").Required().String() 27 | configTemplate = app.Flag("config-template", "The template of alertmanager.yml").Required().String() 28 | id = app.Flag("id", "The id of Alertmanager").Default("0").Int() 29 | key = app.Flag("key", "The unique key for alertmanager config").String() 30 | reloadURL = app.Flag("reload-url", "The url to issue requests to reload Alertmanager to").Required().String() 31 | ) 32 | 33 | func main() { 34 | //Define config for logging 35 | var logcfg opslog.Config 36 | //Definie if controller runs outside of k8s 37 | var runOutsideCluster bool 38 | //Add two additional flags to application for logging and decision if inside or outside k8s 39 | logflag.AddFlags(app, &logcfg) 40 | k8sflag.AddFlags(app, &runOutsideCluster) 41 | //Parse all arguments 42 | _, err := app.Parse(os.Args[1:]) 43 | if err != nil { 44 | //Received error while parsing arguments from function app.Parse 45 | fmt.Fprintln(os.Stderr, "Catched the following error while parsing arguments: ", err) 46 | app.Usage(os.Args[1:]) 47 | os.Exit(2) 48 | } 49 | //Initialize new logger from opslog 50 | logger, err := opslog.New(logcfg) 51 | if err != nil { 52 | fmt.Fprintln(os.Stderr, err) 53 | app.Usage(os.Args[1:]) 54 | os.Exit(2) 55 | } 56 | //First usage of initialized logger for testing 57 | //nolint:errcheck 58 | level.Debug(logger).Log("msg", "Logging initiated...") 59 | //Initialize new k8s client from common k8s package 60 | k8sClient, err := kubernetes.NewClientSet(runOutsideCluster) 61 | if err != nil { 62 | //nolint:errcheck 63 | level.Error(logger).Log("msg", err.Error()) 64 | app.Usage(os.Args[1:]) 65 | os.Exit(2) 66 | } 67 | 68 | URL, err := url.Parse(*reloadURL) 69 | if err != nil { 70 | //nolint:errcheck 71 | level.Error(logger).Log("msg", "Alertmanager reload URL could not be parsed: "+*reloadURL) 72 | os.Exit(2) 73 | } 74 | 75 | a := alertmanager.New(URL, *configPath, *configTemplate, *id, *key, logger) 76 | 77 | //nolint:errcheck 78 | level.Info(logger).Log("msg", "Starting Alertmanager Controller...") 79 | sigs := make(chan os.Signal, 1) // Create channel to receive OS signals 80 | stop := make(chan struct{}) // Create channel to receive stop signal 81 | 82 | signal.Notify(sigs, os.Interrupt, syscall.SIGTERM, syscall.SIGINT) // Register the sigs channel to receieve SIGTERM 83 | 84 | wg := &sync.WaitGroup{} // Goroutines can add themselves to this to be waited on so that they finish 85 | 86 | //Initialize new k8s configmap-controller from common k8s package 87 | configMapController := &configmap.ConfigMapController{} 88 | configMapController.Controller = controller.New(*a, logger) 89 | configMapController.Initialize(k8sClient) 90 | //Run initiated configmap-controller as go routine 91 | go configMapController.Run(stop, wg) 92 | 93 | <-sigs // Wait for signals (this hangs until a signal arrives) 94 | 95 | //nolint:errcheck 96 | level.Info(logger).Log("msg", "Shutting down...") 97 | 98 | close(stop) // Tell goroutines to stop themselves 99 | wg.Wait() // Wait for all to be stopped 100 | } 101 | -------------------------------------------------------------------------------- /configmap-examples/alertmanager-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: alertmanager-config-template 5 | annotations: 6 | alertmanager.net/config: "true" 7 | alertmanager.net/id: "0" 8 | alertmanager.net/key: "q5!sder6P" 9 | data: 10 | alertmanager.tmpl: |- 11 | global: 12 | resolve_timeout: 5m 13 | smtp_require_tls: true 14 | route: 15 | group_by: 16 | - alertname 17 | - instance 18 | group_interval: 5m 19 | group_wait: 1m 20 | receiver: dummy 21 | repeat_interval: 7d 22 | routes: 23 | {{ .Routes }} 24 | receivers: 25 | - name: dummy 26 | webhook_configs: 27 | - send_resolved: true 28 | url: http://localhost 29 | {{ .Receivers }} 30 | inhibit_rules: 31 | {{ .InhibitRules }} -------------------------------------------------------------------------------- /configmap-examples/alertmanager-inhibit-rule.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ConfigMap 4 | metadata: 5 | name: inhibit-rule 6 | annotations: 7 | alertmanager.net/inhibit_rule: "true" 8 | alertmanager.net/id: "0" 9 | data: 10 | test_inhibit_rule.yaml: |- 11 | - target_match: 12 | test: test 13 | test2: test2 14 | source_match: 15 | label1: label1 16 | label2: label22 -------------------------------------------------------------------------------- /configmap-examples/alertmanager-recevier.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ConfigMap 4 | metadata: 5 | name: receiver 6 | annotations: 7 | alertmanager.net/receiver: "true" 8 | alertmanager.net/id: "0" 9 | data: 10 | test_receiver.yaml: |- 11 | - name: default 12 | webhook_configs: 13 | - send_resolved: true 14 | url: http://localhost 15 | - name: test1 16 | webhook_configs: 17 | - send_resolved: true 18 | url: http://localhost 19 | - name: test2 20 | webhook_configs: 21 | - send_resolved: true 22 | url: http://localhost 23 | - name: test3 24 | webhook_configs: 25 | - send_resolved: true 26 | url: http://localhost 27 | -------------------------------------------------------------------------------- /configmap-examples/alertmanager-route.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: ConfigMap 4 | metadata: 5 | name: route 6 | annotations: 7 | alertmanager.net/route: "true" 8 | alertmanager.net/id: "0" 9 | data: 10 | test_route.yaml: |- 11 | - receiver: default 12 | group_by: 13 | - instance 14 | - alertname 15 | - pod_name 16 | - namespace 17 | - node 18 | - job 19 | routes: 20 | - receiver: test1 21 | match_re: 22 | receiver: .*test1.* 23 | continue: true 24 | - receiver: test2 25 | match_re: 26 | receiver: .*test2.* 27 | continue: true 28 | routes: 29 | - receiver: test3 30 | match_re: 31 | kubernetes_service: .*test3.* -------------------------------------------------------------------------------- /controller/controller.go: -------------------------------------------------------------------------------- 1 | package controller 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "io/ioutil" 7 | "os" 8 | "path/filepath" 9 | "strconv" 10 | "strings" 11 | "text/template" 12 | 13 | "github.com/dbsystel/alertmanager-config-controller/alertmanager" 14 | "github.com/go-kit/kit/log" 15 | "github.com/go-kit/kit/log/level" 16 | alcf "github.com/prometheus/alertmanager/config" 17 | "gopkg.in/yaml.v2" 18 | v1 "k8s.io/api/core/v1" 19 | ) 20 | 21 | var ( 22 | receiverConst = "receiver" 23 | routeConst = "route" 24 | inhibitRuleConst = "inhibit rule" 25 | configConst = "config" 26 | ) 27 | 28 | // Controller wrapper for alertmanager 29 | type Controller struct { 30 | logger log.Logger 31 | a alertmanager.APIClient 32 | } 33 | 34 | // New creates new Controller instance 35 | func New(a alertmanager.APIClient, logger log.Logger) *Controller { 36 | controller := &Controller{} 37 | controller.logger = logger 38 | controller.a = a 39 | return controller 40 | } 41 | 42 | // Create is called when a configmap is created 43 | func (c *Controller) Create(obj interface{}) { 44 | configmapObj := obj.(*v1.ConfigMap) 45 | id := configmapObj.Annotations["alertmanager.net/id"] 46 | route := configmapObj.Annotations["alertmanager.net/route"] 47 | receiver := configmapObj.Annotations["alertmanager.net/receiver"] 48 | inhibitRule := configmapObj.Annotations["alertmanager.net/inhibit_rule"] 49 | config := configmapObj.Annotations["alertmanager.net/config"] 50 | key := configmapObj.Annotations["alertmanager.net/key"] 51 | isAlertmanagerRoute, _ := strconv.ParseBool(route) 52 | isAlertmanagerReceiver, _ := strconv.ParseBool(receiver) 53 | isAlertmanagerInhibitRule, _ := strconv.ParseBool(inhibitRule) 54 | isAlertmanagerConfig, _ := strconv.ParseBool(config) 55 | alertmanagerID, _ := strconv.Atoi(id) 56 | 57 | if alertmanagerID == c.a.ID && 58 | ((isAlertmanagerConfig && key == c.a.Key) || 59 | isAlertmanagerRoute || 60 | isAlertmanagerReceiver || 61 | isAlertmanagerInhibitRule) { 62 | 63 | configType := c.findConfigType(isAlertmanagerRoute, 64 | isAlertmanagerReceiver, 65 | isAlertmanagerInhibitRule, 66 | isAlertmanagerConfig) 67 | 68 | c.createConfig(configmapObj, configType) 69 | 70 | c.checkBackupConfigs() 71 | 72 | err := c.buildConfig() 73 | if err == nil { 74 | _, err = c.a.Reload() 75 | if err != nil { 76 | //nolint:errcheck 77 | level.Error(c.logger).Log( 78 | "msg", "Failed to reload alertmanager.yml", 79 | "err", err.Error(), 80 | "namespace", configmapObj.Namespace, 81 | "name", configmapObj.Name, 82 | ) 83 | } else { 84 | //nolint:errcheck 85 | level.Info(c.logger).Log("msg", "Succeeded: Reloaded Alertmanager") 86 | } 87 | } else if configType != configConst { 88 | if configType == routeConst || configType == receiverConst || configType == inhibitRuleConst { 89 | c.createBackfile(configmapObj, configType) 90 | } 91 | c.deleteConfig(configmapObj) 92 | } 93 | } else { 94 | //nolint:errcheck 95 | level.Debug(c.logger).Log("msg", "Skipping configmap:"+configmapObj.Name) 96 | } 97 | } 98 | 99 | func (c *Controller) findConfigType(isRoute, isReceiver, isInhibitRule, isConfig bool) string { 100 | check := strconv.FormatBool(isRoute) + 101 | "-" + strconv.FormatBool(isReceiver) + 102 | "-" + strconv.FormatBool(isInhibitRule) + 103 | "-" + strconv.FormatBool(isConfig) 104 | switch check { 105 | case "true-false-false-false": 106 | return routeConst 107 | case "false-true-false-false": 108 | return receiverConst 109 | case "false-false-true-false": 110 | return inhibitRuleConst 111 | case "false-false-false-true": 112 | return "config" 113 | default: 114 | return "" 115 | } 116 | } 117 | 118 | func (c *Controller) checkBackupConfigs() { 119 | files, _ := ioutil.ReadDir(c.a.ConfigPath + "/inhibit-rules") 120 | if len(files) > 0 { 121 | //nolint:errcheck 122 | level.Debug(c.logger).Log("msg", "Checking backup inhibit rules for new receiver...") 123 | c.checkBackupInhibitRules() 124 | } 125 | files, _ = ioutil.ReadDir(c.a.ConfigPath + "/backup-routes") 126 | if len(files) > 0 { 127 | //nolint:errcheck 128 | level.Debug(c.logger).Log("msg", "Checking backup routes for new receiver...") 129 | c.checkBackupRoutes() 130 | } 131 | files, _ = ioutil.ReadDir(c.a.ConfigPath + "/backup-receivers") 132 | if len(files) > 0 { 133 | //nolint:errcheck 134 | level.Debug(c.logger).Log("msg", "Checking backup receivers...") 135 | c.checkBackupReceivers() 136 | } 137 | } 138 | 139 | // Delete is called when a configmap is deleted 140 | func (c *Controller) Delete(obj interface{}) { 141 | configmapObj := obj.(*v1.ConfigMap) 142 | id := configmapObj.Annotations["alertmanager.net/id"] 143 | route := configmapObj.Annotations["alertmanager.net/route"] 144 | receiver := configmapObj.Annotations["alertmanager.net/receiver"] 145 | inhibitRule := configmapObj.Annotations["alertmanager.net/inhibit_rule"] 146 | isAlertmanagerRoute, _ := strconv.ParseBool(route) 147 | isAlertmanagerReceiver, _ := strconv.ParseBool(receiver) 148 | isAlertmanagerInhibitRule, _ := strconv.ParseBool(inhibitRule) 149 | alertmanagerID, _ := strconv.Atoi(id) 150 | 151 | if alertmanagerID == c.a.ID && (isAlertmanagerReceiver || isAlertmanagerRoute || isAlertmanagerInhibitRule) { 152 | c.deleteConfig(configmapObj) 153 | if isAlertmanagerRoute { 154 | c.deleteBackupFile(configmapObj, routeConst) 155 | } 156 | if isAlertmanagerReceiver { 157 | c.deleteBackupFile(configmapObj, receiverConst) 158 | } 159 | if isAlertmanagerInhibitRule { 160 | c.deleteBackupFile(configmapObj, inhibitRuleConst) 161 | } 162 | 163 | c.checkBackupConfigs() 164 | 165 | err := c.buildConfig() 166 | if err == nil { 167 | _, err = c.a.Reload() 168 | if err != nil { 169 | //nolint:errcheck 170 | level.Error(c.logger).Log( 171 | "msg", "Failed to reload alertmanager.yml", 172 | "err", err.Error(), 173 | "namespace", configmapObj.Namespace, 174 | "name", configmapObj.Name, 175 | ) 176 | } else { 177 | //nolint:errcheck 178 | level.Info(c.logger).Log("msg", "Succeeded: Reloaded Alertmanager") 179 | } 180 | } 181 | 182 | } else { 183 | //nolint:errcheck 184 | level.Debug(c.logger).Log("msg", "Skipping configmap:"+configmapObj.Name) 185 | } 186 | 187 | } 188 | 189 | // Update is called when a configmap is updated 190 | func (c *Controller) Update(oldobj, newobj interface{}) { 191 | newConfigmapObj := newobj.(*v1.ConfigMap) 192 | oldConfigmapObj := oldobj.(*v1.ConfigMap) 193 | newID := newConfigmapObj.Annotations["alertmanager.net/id"] 194 | oldID := oldConfigmapObj.Annotations["alertmanager.net/id"] 195 | route := newConfigmapObj.Annotations["alertmanager.net/route"] 196 | oldRoute := oldConfigmapObj.Annotations["alertmanager.net/route"] 197 | receiver := newConfigmapObj.Annotations["alertmanager.net/receiver"] 198 | oldReceiver := oldConfigmapObj.Annotations["alertmanager.net/receiver"] 199 | inhibitRule := newConfigmapObj.Annotations["alertmanager.net/inhibit_rule"] 200 | oldInhibitRule := oldConfigmapObj.Annotations["alertmanager.net/inhibit_rule"] 201 | config := newConfigmapObj.Annotations["alertmanager.net/config"] 202 | key := newConfigmapObj.Annotations["alertmanager.net/key"] 203 | isAlertmanagerRoute, _ := strconv.ParseBool(route) 204 | isOldAlertmanagerRoute, _ := strconv.ParseBool(oldRoute) 205 | isAlertmanagerReceiver, _ := strconv.ParseBool(receiver) 206 | isOldAlertmanagerReceiver, _ := strconv.ParseBool(oldReceiver) 207 | isAlertmanagerInhibitRule, _ := strconv.ParseBool(inhibitRule) 208 | isOldAlertmanagerInhibitRule, _ := strconv.ParseBool(oldInhibitRule) 209 | isAlertmanagerConfig, _ := strconv.ParseBool(config) 210 | newAlertmanagerID, _ := strconv.Atoi(newID) 211 | oldAlertmanagerID, _ := strconv.Atoi(oldID) 212 | 213 | if newAlertmanagerID == oldAlertmanagerID && noDifference(oldConfigmapObj, newConfigmapObj) { 214 | //nolint:errcheck 215 | level.Debug(c.logger).Log("msg", "Skipping automatically updated configmap:"+newConfigmapObj.Name) 216 | return 217 | } 218 | if (oldAlertmanagerID == c.a.ID || newAlertmanagerID == c.a.ID) && 219 | (isOldAlertmanagerRoute || 220 | isAlertmanagerRoute || 221 | isOldAlertmanagerReceiver || 222 | isAlertmanagerReceiver || 223 | isOldAlertmanagerInhibitRule || 224 | isAlertmanagerConfig || 225 | isAlertmanagerInhibitRule) { 226 | 227 | if oldAlertmanagerID == c.a.ID { 228 | if isOldAlertmanagerReceiver { 229 | c.deleteConfig(oldConfigmapObj) 230 | c.deleteBackupFile(oldConfigmapObj, receiverConst) 231 | } 232 | if isOldAlertmanagerRoute { 233 | c.deleteConfig(oldConfigmapObj) 234 | c.deleteBackupFile(oldConfigmapObj, routeConst) 235 | } 236 | if isOldAlertmanagerInhibitRule { 237 | c.deleteConfig(oldConfigmapObj) 238 | c.deleteBackupFile(oldConfigmapObj, inhibitRuleConst) 239 | } 240 | } 241 | 242 | newConfigType := c.findConfigType(isAlertmanagerRoute, 243 | isAlertmanagerReceiver, 244 | isAlertmanagerInhibitRule, 245 | isAlertmanagerConfig) 246 | 247 | if newAlertmanagerID == c.a.ID { 248 | if (isAlertmanagerReceiver || 249 | isAlertmanagerRoute || 250 | isAlertmanagerInhibitRule) || 251 | (isAlertmanagerConfig && key == c.a.Key) { 252 | 253 | c.createConfig(newConfigmapObj, newConfigType) 254 | } 255 | } 256 | 257 | c.checkBackupConfigs() 258 | 259 | err := c.buildConfig() 260 | if err == nil { 261 | _, err = c.a.Reload() 262 | if err != nil { 263 | //nolint:errcheck 264 | level.Error(c.logger).Log( 265 | "msg", "Failed to reload alertmanager.yml", 266 | "err", err.Error(), 267 | "namespace", newConfigmapObj.Namespace, 268 | "name", newConfigmapObj.Name, 269 | ) 270 | } else { 271 | //nolint:errcheck 272 | level.Info(c.logger).Log("msg", "Succeeded: Reloaded Alertmanager") 273 | } 274 | } else if newAlertmanagerID == c.a.ID { 275 | if newConfigType != configConst { 276 | if newConfigType == routeConst || newConfigType == receiverConst || newConfigType == inhibitRuleConst { 277 | c.createBackfile(newConfigmapObj, newConfigType) 278 | } 279 | c.deleteConfig(newConfigmapObj) 280 | } 281 | } 282 | } else { 283 | //nolint:errcheck 284 | level.Debug(c.logger).Log("msg", "Skipping configmap:"+newConfigmapObj.Name) 285 | } 286 | } 287 | 288 | // save configs(receivers, routes, inhibitrules, config template) into storage 289 | func (c *Controller) createConfig(configmapObj *v1.ConfigMap, configType string) { 290 | var err error 291 | path := "" 292 | 293 | switch configType { 294 | case routeConst: 295 | path = c.a.ConfigPath + "/routes/" 296 | case receiverConst: 297 | path = c.a.ConfigPath + "/receivers/" 298 | case inhibitRuleConst: 299 | path = c.a.ConfigPath + "/inhibit-rules/" 300 | case configConst: 301 | path = filepath.Dir(c.a.ConfigTemplate) + "/" 302 | default: 303 | return 304 | } 305 | 306 | if _, err = os.Stat(path); os.IsNotExist(err) { 307 | err = os.MkdirAll(path, 0766) 308 | if err != nil { 309 | //nolint:errcheck 310 | level.Error(c.logger).Log("msg", "Failed to create directory", "err", err.Error()) 311 | } 312 | } 313 | 314 | for k, v := range configmapObj.Data { 315 | filename := "" 316 | if configType == configConst { 317 | filename = k 318 | } else { 319 | filename = configmapObj.Namespace + "-" + configmapObj.Name + "-" + k 320 | } 321 | 322 | if configType == routeConst { 323 | v = c.addContinueIfNotExist(v) 324 | } 325 | 326 | //nolint:errcheck 327 | level.Info(c.logger).Log( 328 | "msg", "Creating "+configType+": "+k, 329 | "namespace", configmapObj.Namespace, 330 | "name", configmapObj.Name, 331 | ) 332 | err = ioutil.WriteFile(path+filename, []byte(v), 0644) 333 | if err != nil { 334 | //nolint:errcheck 335 | level.Error(c.logger).Log( 336 | "msg", "Failed to create "+configType+": "+k, 337 | "namespace", configmapObj.Namespace, 338 | "name", configmapObj.Name, 339 | ) 340 | } 341 | } 342 | } 343 | 344 | func (c *Controller) addContinueIfNotExist(routeString string) string { 345 | m := make([]map[string]interface{}, 1) 346 | 347 | err := yaml.Unmarshal([]byte(routeString), &m) 348 | if err != nil { 349 | //nolint:errcheck 350 | level.Error(c.logger).Log("msg", "Format error in route string: "+routeString, "err", err.Error()) 351 | } 352 | 353 | for _, route := range m { 354 | if len(route) == 0 { 355 | level.Warn(c.logger).Log("msg", "One of your route config is empty") 356 | continue 357 | } 358 | route["continue"] = true 359 | } 360 | 361 | v, err := yaml.Marshal(&m) 362 | if err != nil { 363 | //nolint:errcheck 364 | level.Error(c.logger).Log("msg", "Format error in route yaml", "err", err.Error()) 365 | } 366 | 367 | return string(v) 368 | } 369 | 370 | // backup currently unavailable configs for further usage 371 | func (c *Controller) createBackfile(configmapObj *v1.ConfigMap, configType string) { 372 | path := c.a.ConfigPath + "/backup-" + configType + "s/" 373 | var err error 374 | if _, err = os.Stat(path); os.IsNotExist(err) { 375 | err = os.MkdirAll(path, 0766) 376 | if err != nil { 377 | //nolint:errcheck 378 | level.Error(c.logger).Log("msg", "Failed to create backup directory", "err", err.Error()) 379 | } 380 | } 381 | for k, v := range configmapObj.Data { 382 | filename := configmapObj.Namespace + "-" + configmapObj.Name + "-" + k 383 | if configType == routeConst { 384 | v = c.addContinueIfNotExist(v) 385 | } 386 | //nolint:errcheck 387 | level.Debug(c.logger).Log( 388 | "msg", "Backup "+configType+": "+k, 389 | "namespace", configmapObj.Namespace, 390 | "name", configmapObj.Name, 391 | ) 392 | err = ioutil.WriteFile(path+filename, []byte(v), 0644) 393 | if err != nil { 394 | //nolint:errcheck 395 | level.Error(c.logger).Log("msg", "Failed to backup "+configType+": "+k, "err", err.Error()) 396 | } 397 | } 398 | } 399 | 400 | // go through backup routes to check if any of them can be used now 401 | func (c *Controller) checkBackupRoutes() { 402 | routeFiles, err := filepath.Glob(c.a.ConfigPath + "/backup-routes/*") 403 | if err != nil { 404 | //nolint:errcheck 405 | level.Error(c.logger).Log("msg", "Failed to read backup routes", "err", err.Error()) 406 | } 407 | 408 | routes := "" 409 | receivers := c.readConfigs("receivers") 410 | inhibitRules := c.readConfigs("inhibit-rules") 411 | 412 | var alertmanagerConfig alertmanager.Config 413 | alertmanagerConfig.Receivers = receivers 414 | alertmanagerConfig.InhibitRules = inhibitRules 415 | 416 | configTemplate, err := ioutil.ReadFile(c.a.ConfigTemplate) 417 | if err != nil { 418 | //nolint:errcheck 419 | level.Error(c.logger).Log("msg", "Failed to read template: "+c.a.ConfigTemplate, "err", err.Error()) 420 | } 421 | 422 | t, err := template.New("alertmanager.yml").Parse(string(configTemplate)) 423 | if err != nil { 424 | //nolint:errcheck 425 | level.Error(c.logger).Log("msg", "Failed to parse template", "err", err.Error()) 426 | } 427 | 428 | for _, routeFile := range routeFiles { 429 | route, err := ioutil.ReadFile(routeFile) 430 | if err != nil { 431 | //nolint:errcheck 432 | level.Error(c.logger).Log("msg", "Failed to read route: "+routeFile, "err", err.Error()) 433 | } 434 | routes = string(route) 435 | 436 | alertmanagerConfig.Routes = strings.Replace(routes, "\n", "\n ", -1) 437 | 438 | var tpl bytes.Buffer 439 | err = t.Execute(&tpl, alertmanagerConfig) 440 | if err != nil { 441 | //nolint:errcheck 442 | level.Error(c.logger).Log("msg", "Failed to template alertmanager config", "err", err.Error()) 443 | } 444 | _, configErr := alcf.Load(tpl.String()) 445 | if configErr == nil { 446 | c.copyFile(routeFile, c.a.ConfigPath+"/routes/"+filepath.Base(routeFile)) 447 | err = os.Remove(routeFile) 448 | if err != nil { 449 | //nolint:errcheck 450 | level.Error(c.logger).Log("msg", "Failed to delete route: "+routeFile, "err", err.Error()) 451 | } 452 | //nolint:errcheck 453 | level.Debug(c.logger).Log("msg", "Route is available", "route", routeFile) 454 | c.checkBackupConfigs() 455 | break 456 | } else { 457 | //nolint:errcheck 458 | level.Debug(c.logger).Log("msg", "Route is unavailable", "route", routeFile, "err", configErr.Error()) 459 | } 460 | } 461 | } 462 | 463 | // go through backup receivers to check if any of them can be used now 464 | func (c *Controller) checkBackupReceivers() { 465 | receiverPath, err := filepath.Glob(c.a.ConfigPath + "/backup-receivers/*") 466 | if err != nil { 467 | //nolint:errcheck 468 | level.Error(c.logger).Log("msg", "Failed to read backup receivers", "err", err.Error()) 469 | } 470 | 471 | routes := c.readConfigs("routes") 472 | receivers := c.readConfigs("receivers") 473 | inhibitRules := c.readConfigs("inhibit-rules") 474 | 475 | var alertmanagerConfig alertmanager.Config 476 | alertmanagerConfig.Routes = strings.Replace(routes, "\n", "\n ", -1) 477 | alertmanagerConfig.InhibitRules = inhibitRules 478 | 479 | configTemplate, err := ioutil.ReadFile(c.a.ConfigTemplate) 480 | if err != nil { 481 | //nolint:errcheck 482 | level.Error(c.logger).Log("msg", "Failed to read template: "+c.a.ConfigTemplate, "err", err.Error()) 483 | } 484 | 485 | t, err := template.New("alertmanager.yml").Parse(string(configTemplate)) 486 | if err != nil { 487 | //nolint:errcheck 488 | level.Error(c.logger).Log("msg", "Failed to parse template", "err", err.Error()) 489 | } 490 | 491 | for _, receiverFile := range receiverPath { 492 | receiver, err := ioutil.ReadFile(receiverFile) 493 | if err != nil { 494 | //nolint:errcheck 495 | level.Error(c.logger).Log("msg", "Failed to read receiver: "+receiverFile, "err", err.Error()) 496 | } 497 | newReceivers := receivers + string(receiver) 498 | 499 | alertmanagerConfig.Receivers = newReceivers 500 | var tpl bytes.Buffer 501 | err = t.Execute(&tpl, alertmanagerConfig) 502 | if err != nil { 503 | //nolint:errcheck 504 | level.Error(c.logger).Log("msg", "Failed to template alertmanager config", "err", err.Error()) 505 | } 506 | _, configErr := alcf.Load(tpl.String()) 507 | if configErr == nil { 508 | c.copyFile(receiverFile, c.a.ConfigPath+"/receivers/"+filepath.Base(receiverFile)) 509 | err = os.Remove(receiverFile) 510 | if err != nil { 511 | //nolint:errcheck 512 | level.Error(c.logger).Log("msg", "Failed to delete receiver: "+receiverFile, "err", err.Error()) 513 | } 514 | //nolint:errcheck 515 | level.Debug(c.logger).Log("msg", "Receiver is available", "receiver", receiverFile) 516 | c.checkBackupConfigs() 517 | break 518 | } else { 519 | //nolint:errcheck 520 | level.Debug(c.logger).Log("msg", "Route is unavailable", "receiver", receiverFile, "err", configErr.Error()) 521 | } 522 | } 523 | } 524 | 525 | // format config file from routs, receivers, inhibit rules and config template 526 | func (c *Controller) buildConfig() error { 527 | configTemplate, err := ioutil.ReadFile(c.a.ConfigTemplate) 528 | if err != nil { 529 | //nolint:errcheck 530 | level.Error(c.logger).Log("msg", "Failed to read template: "+c.a.ConfigTemplate, "err", err.Error()) 531 | } 532 | 533 | routes := c.readConfigs("routes") 534 | receivers := c.readConfigs("receivers") 535 | inhibitRules := c.readConfigs("inhibit-rules") 536 | var alertmanagerConfig alertmanager.Config 537 | 538 | alertmanagerConfig.Routes = strings.Replace(routes, "\n", "\n ", -1) 539 | alertmanagerConfig.Receivers = receivers 540 | alertmanagerConfig.InhibitRules = inhibitRules 541 | 542 | t, err := template.New("alertmanager.yml").Parse(string(configTemplate)) 543 | if err != nil { 544 | //nolint:errcheck 545 | level.Error(c.logger).Log("msg", "Failed to parse template", "err", err.Error()) 546 | } 547 | 548 | var tpl bytes.Buffer 549 | err = t.Execute(&tpl, alertmanagerConfig) 550 | if err != nil { 551 | //nolint:errcheck 552 | level.Error(c.logger).Log("msg", "Failed to template alertmanager config", "err", err.Error()) 553 | } 554 | _, configErr := alcf.Load(tpl.String()) 555 | if configErr == nil { 556 | f, err := os.Create(c.a.ConfigPath + "/alertmanager.yml") 557 | if err != nil { 558 | //nolint:errcheck 559 | level.Error(c.logger).Log("msg", "Failed to create alertmanager.yml", "err", err.Error()) 560 | } 561 | defer f.Close() 562 | err = t.Execute(f, alertmanagerConfig) 563 | if err != nil { 564 | //nolint:errcheck 565 | level.Error(c.logger).Log("msg", "Failed to template alertmanager config", "err", err.Error()) 566 | } 567 | } else { 568 | //nolint:errcheck 569 | level.Error(c.logger).Log("err", configErr.Error()) 570 | } 571 | return configErr 572 | } 573 | 574 | // read config files from storage 575 | func (c *Controller) readConfigs(style string) string { 576 | configFiles, err := filepath.Glob(c.a.ConfigPath + "/" + style + "/*") 577 | if err != nil { 578 | //nolint:errcheck 579 | level.Error(c.logger).Log("msg", "Failed to read "+style, "err", err.Error()) 580 | } 581 | 582 | configs := "" 583 | for _, configFile := range configFiles { 584 | config, err := ioutil.ReadFile(configFile) 585 | if err != nil { 586 | //nolint:errcheck 587 | level.Error(c.logger).Log("msg", "Failed to read "+style+" file "+configFile, "err", err.Error()) 588 | } 589 | configs = configs + string(config) + "\n" 590 | } 591 | 592 | return configs 593 | } 594 | 595 | // remove config files from storage 596 | func (c *Controller) deleteConfig(configmapObj *v1.ConfigMap) { 597 | var err error 598 | route := configmapObj.Annotations["alertmanager.net/route"] 599 | receiver := configmapObj.Annotations["alertmanager.net/receiver"] 600 | inhibitRule := configmapObj.Annotations["alertmanager.net/inhibit_rule"] 601 | isAlertmanagerRoute, _ := strconv.ParseBool(route) 602 | isAlertmanagerReceiver, _ := strconv.ParseBool(receiver) 603 | isAlertmanagerInhibitRule, _ := strconv.ParseBool(inhibitRule) 604 | path := "" 605 | configType := c.findConfigType(isAlertmanagerRoute, isAlertmanagerReceiver, isAlertmanagerInhibitRule, false) 606 | path = c.a.ConfigPath + "/" + configType + "s/" 607 | 608 | for k := range configmapObj.Data { 609 | filename := configmapObj.Namespace + "-" + configmapObj.Name + "-" + k 610 | //nolint:errcheck 611 | level.Info(c.logger).Log( 612 | "msg", "Deleting "+configType+": "+k, 613 | "namespace", configmapObj.Namespace, 614 | "name", configmapObj.Name, 615 | ) 616 | err = os.Remove(path + filename) 617 | if err != nil { 618 | //nolint:errcheck 619 | level.Error(c.logger).Log( 620 | "msg", "Failed to delete "+configType+": "+k, 621 | "namespace", configmapObj.Namespace, 622 | "name", configmapObj.Name, 623 | "err", err.Error(), 624 | ) 625 | } 626 | } 627 | } 628 | 629 | // remove config files from backup storage 630 | func (c *Controller) deleteBackupFile(configmapObj *v1.ConfigMap, configType string) { 631 | for k := range configmapObj.Data { 632 | filename := configmapObj.Namespace + "-" + configmapObj.Name + "-" + k 633 | //nolint:errcheck 634 | level.Debug(c.logger).Log("mag", "Delete backup "+configType+" if it is existed") 635 | if _, err := os.Stat(c.a.ConfigPath + "/backup-" + configType + "s/" + filename); !os.IsNotExist(err) { 636 | err := os.Remove(c.a.ConfigPath + "/backup-" + configType + "s/" + filename) 637 | if err != nil { 638 | //nolint:errcheck 639 | level.Error(c.logger).Log("msg", "Failed to delete backup "+configType+": "+filename, "err", err.Error()) 640 | } 641 | } else { 642 | //nolint:errcheck 643 | level.Debug(c.logger).Log("msg", "Backup "+configType+" does not exist") 644 | } 645 | } 646 | } 647 | 648 | // are two configmaps same 649 | func noDifference(newConfigMap *v1.ConfigMap, oldConfigMap *v1.ConfigMap) bool { 650 | if len(newConfigMap.Data) != len(oldConfigMap.Data) { 651 | return false 652 | } 653 | for k, v := range newConfigMap.Data { 654 | if v != oldConfigMap.Data[k] { 655 | return false 656 | } 657 | } 658 | if len(newConfigMap.Annotations) != len(oldConfigMap.Annotations) { 659 | return false 660 | } 661 | for k, v := range newConfigMap.Annotations { 662 | if v != oldConfigMap.Annotations[k] { 663 | return false 664 | } 665 | } 666 | return true 667 | } 668 | 669 | // copy file from sourceFile to targetFile 670 | func (c *Controller) copyFile(sourceFile string, targetFile string) { 671 | source, err := os.Open(sourceFile) 672 | if err != nil { 673 | //nolint:errcheck 674 | level.Error(c.logger).Log("msg", "Failed to read file", "file", sourceFile, "err", err.Error()) 675 | } 676 | defer source.Close() 677 | 678 | dest, err := os.Create(targetFile) 679 | if err != nil { 680 | //nolint:errcheck 681 | level.Error(c.logger).Log("msg", "Failed to create file", "file", sourceFile, "err", err.Error()) 682 | } 683 | defer dest.Close() 684 | 685 | _, err = io.Copy(dest, source) 686 | if err != nil { 687 | //nolint:errcheck 688 | level.Error(c.logger).Log("msg", "Failed to copy file", "file", sourceFile, "err", err.Error()) 689 | } 690 | } 691 | 692 | func (c *Controller) checkBackupInhibitRules() { 693 | inhibitRulePath, err := filepath.Glob(c.a.ConfigPath + "/backup-inhibit-rules/*") 694 | if err != nil { 695 | //nolint:errcheck 696 | level.Error(c.logger).Log("msg", "Failed to read backup inhibit rules", "err", err.Error()) 697 | } 698 | 699 | routes := c.readConfigs("routes") 700 | receivers := c.readConfigs("receivers") 701 | inhibitRules := c.readConfigs("inhibit-rules") 702 | 703 | var alertmanagerConfig alertmanager.Config 704 | alertmanagerConfig.Routes = strings.Replace(routes, "\n", "\n ", -1) 705 | alertmanagerConfig.Receivers = receivers 706 | 707 | configTemplate, err := ioutil.ReadFile(c.a.ConfigTemplate) 708 | if err != nil { 709 | //nolint:errcheck 710 | level.Error(c.logger).Log("msg", "Failed to read template: "+c.a.ConfigTemplate, "err", err.Error()) 711 | } 712 | 713 | t, err := template.New("alertmanager.yml").Parse(string(configTemplate)) 714 | if err != nil { 715 | //nolint:errcheck 716 | level.Error(c.logger).Log("msg", "Failed to parse template", "err", err.Error()) 717 | } 718 | 719 | for _, inhibitRuleFile := range inhibitRulePath { 720 | inhibitRule, err := ioutil.ReadFile(inhibitRuleFile) 721 | if err != nil { 722 | //nolint:errcheck 723 | level.Error(c.logger).Log("msg", "Failed to read inhibit rule: "+inhibitRuleFile, "err", err.Error()) 724 | } 725 | newInhibitRules := inhibitRules + string(inhibitRule) 726 | 727 | alertmanagerConfig.InhibitRules = newInhibitRules 728 | var tpl bytes.Buffer 729 | err = t.Execute(&tpl, alertmanagerConfig) 730 | if err != nil { 731 | //nolint:errcheck 732 | level.Error(c.logger).Log("msg", "Failed to template alertmanager config", "err", err.Error()) 733 | } 734 | _, configErr := alcf.Load(tpl.String()) 735 | if configErr == nil { 736 | c.copyFile(inhibitRuleFile, c.a.ConfigPath+"/inhibit-rules/"+filepath.Base(inhibitRuleFile)) 737 | err = os.Remove(inhibitRuleFile) 738 | if err != nil { 739 | //nolint:errcheck 740 | level.Error(c.logger).Log("msg", "Failed to delete inhibitRule: "+inhibitRuleFile, "err", err.Error()) 741 | } 742 | //nolint:errcheck 743 | level.Debug(c.logger).Log("msg", "Inhibit rule is available", "inhibitRule", inhibitRuleFile) 744 | } else { 745 | //nolint:errcheck 746 | level.Debug(c.logger).Log("msg", "Inhibit rule is unavailable", "inhibitRule", inhibitRuleFile, "err", configErr) 747 | } 748 | } 749 | 750 | } 751 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/dbsystel/alertmanager-config-controller 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/dbsystel/kube-controller-dbsystel-go-common v0.0.0-20190307121541-2d8f1275b8b2 7 | github.com/go-kit/kit v0.8.0 8 | github.com/google/gofuzz v1.0.0 // indirect 9 | github.com/googleapis/gnostic v0.2.0 // indirect 10 | github.com/imdario/mergo v0.3.7 // indirect 11 | github.com/json-iterator/go v1.1.6 // indirect 12 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 13 | github.com/modern-go/reflect2 v1.0.1 // indirect 14 | github.com/prometheus/alertmanager v0.17.0 15 | github.com/spf13/pflag v1.0.3 // indirect 16 | golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect 17 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect 18 | gopkg.in/alecthomas/kingpin.v2 v2.2.6 19 | gopkg.in/inf.v0 v0.9.1 // indirect 20 | gopkg.in/yaml.v2 v2.2.2 21 | k8s.io/api v0.0.0-20190313235455-40a48860b5ab 22 | k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1 23 | k8s.io/client-go v11.0.0+incompatible 24 | k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 // indirect 25 | sigs.k8s.io/yaml v1.1.0 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 3 | github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= 4 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= 5 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= 6 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 7 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= 8 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 9 | github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= 10 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 11 | github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= 12 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= 13 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 14 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 15 | github.com/cenkalti/backoff v0.0.0-20181003080854-62661b46c409/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= 16 | github.com/cespare/xxhash v0.0.0-20181017004759-096ff4a8a059/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 17 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 18 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 19 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 20 | github.com/dbsystel/kube-controller-dbsystel-go-common v0.0.0-20190307121541-2d8f1275b8b2 h1:+244SmYIht4eLFjF6SUORGA+zDyzVSWs+KtmYmpolJ4= 21 | github.com/dbsystel/kube-controller-dbsystel-go-common v0.0.0-20190307121541-2d8f1275b8b2/go.mod h1:AxNVhtAiUwmmxpRaPMmWwYdzul07Gb78Oep6ctTzbkY= 22 | github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= 23 | github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= 24 | github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= 25 | github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= 26 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 27 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 28 | github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= 29 | github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= 30 | github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= 31 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 32 | github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2ic= 33 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 34 | github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= 35 | github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= 36 | github.com/go-openapi/analysis v0.17.2/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= 37 | github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= 38 | github.com/go-openapi/errors v0.17.2/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= 39 | github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= 40 | github.com/go-openapi/jsonpointer v0.17.2/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= 41 | github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= 42 | github.com/go-openapi/jsonreference v0.17.2/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= 43 | github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= 44 | github.com/go-openapi/loads v0.17.2/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= 45 | github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= 46 | github.com/go-openapi/runtime v0.18.0/go.mod h1:uI6pHuxWYTy94zZxgcwJkUWa9wbIlhteGfloI10GD4U= 47 | github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= 48 | github.com/go-openapi/spec v0.17.2/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= 49 | github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= 50 | github.com/go-openapi/strfmt v0.17.2/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= 51 | github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= 52 | github.com/go-openapi/swag v0.17.2/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= 53 | github.com/go-openapi/validate v0.17.2/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= 54 | github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= 55 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 56 | github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 57 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 58 | github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= 59 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 60 | github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 61 | github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= 62 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 63 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 64 | github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= 65 | github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= 66 | github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= 67 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 68 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 69 | github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 70 | github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= 71 | github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= 72 | github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= 73 | github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= 74 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 75 | github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= 76 | github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= 77 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 78 | github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= 79 | github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= 80 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 81 | github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= 82 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 83 | github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= 84 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 85 | github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= 86 | github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= 87 | github.com/jessevdk/go-flags v0.0.0-20180331124232-1c38ed7ad0cc/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= 88 | github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= 89 | github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 90 | github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= 91 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 92 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 93 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 94 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 95 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 96 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 97 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 98 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 99 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 100 | github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= 101 | github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 102 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 103 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 104 | github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= 105 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 106 | github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= 107 | github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= 108 | github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= 109 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 110 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 111 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 112 | github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= 113 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 114 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223 h1:F9x/1yl3T2AeKLr2AMdilSD8+f9bvMnNN8VS5iDtovc= 115 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 116 | github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= 117 | github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= 118 | github.com/oklog/ulid v0.0.0-20170117200651-66bb6560562f/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 119 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 120 | github.com/onsi/gomega v0.0.0-20190113212917-5533ce8a0da3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 121 | github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= 122 | github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= 123 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 124 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 125 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 126 | github.com/prometheus/alertmanager v0.17.0 h1:h4EqB7nSCb0zNl8prrb9kX9nO2ZQh//aQkCiemLCw3Q= 127 | github.com/prometheus/alertmanager v0.17.0/go.mod h1:3/vUuD9sDlkVuB2KLczjrlG7aqT09pyK0jfTp/itWS0= 128 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 129 | github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= 130 | github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= 131 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= 132 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 133 | github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 134 | github.com/prometheus/common v0.2.0 h1:kUZDBDTdBVBYBj5Tmh2NZLlF60mfjA27rM34b+cVwNU= 135 | github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 136 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 137 | github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= 138 | github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 139 | github.com/prometheus/prometheus v0.0.0-20180315085919-58e2a31db8de/go.mod h1:oAIUtOny2rjMX0OWN5vPR5/q/twIROJvdqnQKDdil/s= 140 | github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= 141 | github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 142 | github.com/satori/go.uuid v0.0.0-20160603004225-b111a074d5ef/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= 143 | github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= 144 | github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= 145 | github.com/shurcooL/vfsgen v0.0.0-20180825020608-02ddb050ef6b/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= 146 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 147 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 148 | github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= 149 | github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4= 150 | github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 151 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 152 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 153 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 154 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 155 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 156 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 157 | github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= 158 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 159 | golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3 h1:KYQXGkl6vs02hK7pK4eIbw0NpNPedieTSTEiJ//bwGs= 160 | golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 161 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 162 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 163 | golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 164 | golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 165 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 166 | golang.org/x/net v0.0.0-20181201002055-351d144fa1fc h1:a3CU5tJYVj92DY2LaA1kUkrsqD5/3mLDhx2NcNqyW+0= 167 | golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 168 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= 169 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 170 | golang.org/x/net v0.0.0-20190206173232-65e2d4e15006 h1:bfLnR+k0tq5Lqt6dflRLcZiz6UaXCMt3vhYJ1l4FQ80= 171 | golang.org/x/net v0.0.0-20190206173232-65e2d4e15006/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 172 | golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= 173 | golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 174 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 175 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 176 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 177 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 178 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 179 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 180 | golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 181 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5 h1:mzjBh+S5frKOsOBobWIMAbXavqjmgO17k/2puhcFR94= 182 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 183 | golang.org/x/sys v0.0.0-20190312061237-fead79001313 h1:pczuHS43Cp2ktBEEmLwScxgjWsBSzdaQiKzUyf3DTTc= 184 | golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 185 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 186 | golang.org/x/text v0.3.1-0.20180805044716-cb6730876b98 h1:Cf5h/jCzhiiL0W8VrlJhOm+8+YYZPMHXcHsruWXnD40= 187 | golang.org/x/text v0.3.1-0.20180805044716-cb6730876b98/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 188 | golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU= 189 | golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 190 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= 191 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 192 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 193 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 194 | golang.org/x/tools v0.0.0-20190118193359-16909d206f00/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 195 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 196 | gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= 197 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 198 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 199 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 200 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 201 | gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o= 202 | gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 203 | gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= 204 | gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 205 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 206 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 207 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 208 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 209 | k8s.io/api v0.0.0-20190313235455-40a48860b5ab h1:DG9A67baNpoeweOy2spF1OWHhnVY5KR7/Ek/+U1lVZc= 210 | k8s.io/api v0.0.0-20190313235455-40a48860b5ab/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= 211 | k8s.io/api v0.0.0-20190512063542-eae0ddcf85ba h1:IYmhaPVzJwFsamPUTpLT0FoysxqWZr8yzTXS3ayOzKc= 212 | k8s.io/api v0.0.0-20190512063542-eae0ddcf85ba/go.mod h1:DeP5qcf34M/TYz1rYrxG/6501NCcExhEuvHzcoIg7Zk= 213 | k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1 h1:IS7K02iBkQXpCeieSiyJjGoLSdVOv2DbPaWHJ+ZtgKg= 214 | k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= 215 | k8s.io/apimachinery v0.0.0-20190511063452-5b67e417bf61 h1:3uYpc8AbVp4OOlFhtOZh0qC8D2kVRz8KQpf4llsxtNQ= 216 | k8s.io/apimachinery v0.0.0-20190511063452-5b67e417bf61/go.mod h1:5CBnzrKYGHzv9ZsSKmQ8wHt4XI4/TUBPDwYM9FlZMyw= 217 | k8s.io/client-go v11.0.0+incompatible h1:LBbX2+lOwY9flffWlJM7f1Ct8V2SRNiMRDFeiwnJo9o= 218 | k8s.io/client-go v11.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= 219 | k8s.io/klog v0.3.0 h1:0VPpR+sizsiivjIfIAQH/rl8tan6jvWkS7lU+0di3lE= 220 | k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= 221 | k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= 222 | k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 h1:VBM/0P5TWxwk+Nw6Z+lAw3DKgO76g90ETOiA6rfLV1Y= 223 | k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= 224 | sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= 225 | sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= 226 | -------------------------------------------------------------------------------- /helm/README.md: -------------------------------------------------------------------------------- 1 | ### Installing the Chart 2 | 3 | To install the chart with the release name `alertmanager` in namespace `monitoring`: 4 | 5 | ```console 6 | $ helm upgrade alertmanager charts/alertmanager --namespace monitoring --install 7 | ``` 8 | The command deploys alertmanager with alertmanager-controller on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. 9 | 10 | > **Tip**: List all releases using `helm list` 11 | 12 | ### Uninstalling the Chart 13 | 14 | To uninstall/delete the `alertmanager` deployment: 15 | 16 | ```console 17 | $ helm delete alertmanager --purge 18 | ``` 19 | 20 | The command removes all the Kubernetes components associated with the chart and deletes the release. 21 | 22 | ## Configuration 23 | The following table lists the configurable parameters of the alertmanager chart and their default values. 24 | 25 | Parameter | Description | Default 26 | --------- | ----------- | ------- 27 | `replicaCount` | The number of pod replicas | `1` 28 | `init.repository` | init container image repository | `busybox` 29 | `init.tag` | init container image tag | `"1.30"` 30 | `init.resources.limits.cpu` | init container resources limits for cpu | `10m` 31 | `init.resources.limits.memory` | init container resources limits for memory | `10Mi` 32 | `init.resources.requests.cpu` | init container resources limits for cpu | `1m` 33 | `init.resources.requests.memory` | init container resources limits for memory | `5Mi` 34 | `alertmanager.image.repository` | alertmanager container image repository | `prom/alertmanager` 35 | `alertmanager.image.tag` | alertmanager container image tag | `v0.17.0` 36 | `alertmanager.configFile` | Alertmanager config file | `/etc/alertmanager/alertmanager.yml` 37 | `alertmanager.storagePath` | Alertmanager storage path | `/alertmanager` 38 | `alertmanager.meshListenAddress` | Alertmanager mesh listen address | `6783` 39 | `alertmanager.resources.limits.cpu` | alertmanager container resources limits for cpu | `20m` 40 | `alertmanager.resources.limits.memory` | alertmanager container resources limits for memory | `64Mi` 41 | `alertmanager.resources.requests.cpu` | alertmanager container resources limits for cpu | `10m` 42 | `alertmanager.resources.requests.memory` | alertmanager container resources limits for memory | `32Mi` 43 | `alertmanagerConfigController.image.repository` | alertmanager-config-controller container image repository | `dbsystel/alertmanager-config-controller` 44 | `alertmanagerConfigController.image.tag` | alertmanager-config-controller container image tag | `latest` 45 | `alertmanagerConfigController.url` | The url to reload alertmanager | `http://alertmanager:9093/-/reload` 46 | `alertmanagerConfigController.id` | The id to specify alertmanager | `0` 47 | `alertmanagerConfigController.key` | The key to specify alertmanager config template | `q5!sder6P` 48 | `alertmanagerConfigController.configPath` | The path to use to store config files | `/etc/config` 49 | `alertmanagerConfigController.configTemplate` | The location of template of the Alertmanager config | `/etc/alertmanager/alertmanager.tmpl` 50 | `alertmanagerConfigController.logLevel` | The log-level of alertmanager-config-controller | `info` 51 | `service.port` | The port the alertmanager uses | `9093` 52 | `ingress.host` | The host of ingress url | `alertmanager.xxx.yyy` 53 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "0.16.1" 3 | description: "Alertmanager with Config Controller as Sidecar" 4 | name: alertmanager 5 | version: 0.1.0 6 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "alertmanager.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | If release name contains chart name it will be used as a full name. 13 | */}} 14 | {{- define "alertmanager.fullname" -}} 15 | {{- if .Values.fullnameOverride -}} 16 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} 17 | {{- else -}} 18 | {{- $name := default .Chart.Name .Values.nameOverride -}} 19 | {{- if contains $name .Release.Name -}} 20 | {{- .Release.Name | trunc 63 | trimSuffix "-" -}} 21 | {{- else -}} 22 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 23 | {{- end -}} 24 | {{- end -}} 25 | {{- end -}} 26 | 27 | {{/* 28 | Create chart name and version as used by the chart label. 29 | */}} 30 | {{- define "alertmanager.chart" -}} 31 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} 32 | {{- end -}} -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/alertmanager-dummy-config-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: alertmanager-dummy-config 5 | data: 6 | alertmanager.yml: |- 7 | route: 8 | {{ toYaml .Values.route_dummy | indent 6 }} 9 | receivers: 10 | {{ toYaml .Values.receivers_dummy | indent 4 }} 11 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/alertmanager-empty-config-template-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: alertmanager-empty-config 5 | data: 6 | alertmanager.tmpl: |- 7 | route: 8 | {{ toYaml .Values.route_dummy | indent 6 }} 9 | routes: 10 | {{`{{`}} .Routes {{`}}`}} 11 | receivers: 12 | {{ toYaml .Values.receivers_dummy | indent 4 }} 13 | {{`{{`}} .Receivers {{`}}`}} 14 | inhibit_rules: 15 | {{`{{`}} .InhibitRules {{`}}`}} 16 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | kind: ClusterRole 2 | apiVersion: rbac.authorization.k8s.io/v1beta1 3 | metadata: 4 | name: {{ include "alertmanager.fullname" . }} 5 | rules: 6 | - apiGroups: [""] 7 | resources: 8 | - configmaps 9 | verbs: ["get", "watch", "list"] -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | kind: ClusterRoleBinding 2 | apiVersion: rbac.authorization.k8s.io/v1beta1 3 | metadata: 4 | name: {{ include "alertmanager.fullname" . }} 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: {{ include "alertmanager.fullname" . }} 9 | subjects: 10 | - kind: ServiceAccount 11 | name: {{ include "alertmanager.name" . }} 12 | namespace: {{ .Release.Namespace | quote }} -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: {{ template "alertmanager.name" . }} 5 | spec: 6 | updateStrategy: 7 | type: {{ .Values.updateStrategy }} 8 | replicas: {{ .Values.replicaCount }} 9 | serviceName: {{ template "alertmanager.name" . }}-ha 10 | selector: 11 | matchLabels: 12 | app: {{ template "alertmanager.name" . }} 13 | template: 14 | metadata: 15 | name: {{ template "alertmanager.name" . }} 16 | labels: 17 | app: {{ template "alertmanager.name" . }} 18 | spec: 19 | serviceAccountName: {{ template "alertmanager.name" . }} 20 | affinity: 21 | podAntiAffinity: 22 | requiredDuringSchedulingIgnoredDuringExecution: 23 | - labelSelector: 24 | matchExpressions: 25 | - key: app 26 | operator: In 27 | values: 28 | - alertmanager 29 | topologyKey: kubernetes.io/hostname 30 | initContainers: 31 | - name: init-copy-configmap-to-emptydir 32 | image: "{{ .Values.init.image.repository }}:{{ .Values.init.image.tag }}" 33 | args: 34 | - sh 35 | - -c 36 | - | 37 | cp /dummy/alertmanager.yml /start/ ;chmod 666 /start/alertmanager.yml; cp /source/alertmanager.tmpl /config/;chmod 666 /config/alertmanager.tmpl 38 | volumeMounts: 39 | - name: config-volume 40 | mountPath: "/start" 41 | - name: alertmanager-empty-config 42 | mountPath: "/source" 43 | - name: alertmanager-config-emptydir 44 | mountPath: "/config" 45 | - name: alertmanager-dummy-config 46 | mountPath: "/dummy" 47 | resources: 48 | limits: 49 | cpu: {{ .Values.init.resources.limits.cpu }} 50 | memory: {{ .Values.init.resources.limits.memory }} 51 | requests: 52 | cpu: {{ .Values.init.resources.requests.cpu }} 53 | memory: {{ .Values.init.resources.requests.memory }} 54 | containers: 55 | - name: {{ template "alertmanager.name" . }} 56 | image: "{{ .Values.alertmanager.image.repository }}:{{ .Values.alertmanager.image.tag }}" 57 | args: 58 | - --config.file={{ .Values.alertmanager.configFile }} 59 | - --storage.path={{ .Values.alertmanager.storagePath }} 60 | ports: 61 | - name: {{ template "alertmanager.name" . }} 62 | containerPort: {{ .Values.service.port }} 63 | - name: mesh 64 | containerPort: {{ .Values.alertmanager.meshListenAddress }} 65 | volumeMounts: 66 | - name: config-volume 67 | mountPath: /etc/alertmanager 68 | - name: alertmanager 69 | mountPath: /alertmanager 70 | resources: 71 | limits: 72 | cpu: {{ .Values.alertmanager.resources.limits.cpu }} 73 | memory: {{ .Values.alertmanager.resources.limits.memory }} 74 | requests: 75 | cpu: {{ .Values.alertmanager.resources.requests.cpu }} 76 | memory: {{ .Values.alertmanager.resources.requests.memory }} 77 | - name: alertmanager-config-controller 78 | image: "{{ .Values.alertmanagerConfigController.image.repository }}:{{ .Values.alertmanagerConfigController.image.tag }}" 79 | args: 80 | - "--config-path={{ .Values.alertmanagerConfigController.path }}" 81 | - "--config-template={{ .Values.alertmanagerConfigController.template }}" 82 | - "--reload-url={{ .Values.alertmanagerConfigController.url }}" 83 | - "--id={{ .Values.alertmanagerConfigController.id }}" 84 | - "--key={{ .Values.alertmanagerConfigController.key }}" 85 | - "--log-level={{ .Values.alertmanagerConfigController.logLevel }}" 86 | volumeMounts: 87 | - mountPath: {{ .Values.alertmanagerConfigController.path | quote }} 88 | name: config-volume 89 | - mountPath: "/etc/alertmanager" 90 | name: alertmanager-config-emptydir 91 | volumes: 92 | - name: config-volume 93 | emptyDir: {} 94 | - name: alertmanager 95 | emptyDir: {} 96 | - name: alertmanager-config-emptydir 97 | emptyDir: {} 98 | - name: alertmanager-empty-config 99 | configMap: 100 | name: alertmanager-empty-config 101 | - name: alertmanager-dummy-config 102 | configMap: 103 | name: alertmanager-dummy-config 104 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: {{ template "alertmanager.name" . }} 5 | annotations: 6 | kubernetes.io/ingress.class: "nginx" 7 | ingress.kubernetes.io/force-ssl-redirect: "false" 8 | ingress.kubernetes.io/ssl-redirect: "false" 9 | spec: 10 | rules: 11 | - host: {{ .Values.ingress.host }} 12 | http: 13 | paths: 14 | - path: / 15 | backend: 16 | serviceName: {{ template "alertmanager.name" . }} 17 | servicePort: {{ .Values.service.port }} 18 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | annotations: 5 | prometheus.io/scrape: "true" 6 | prometheus.io/path: "/metrics" 7 | prometheus.io/port: {{ .Values.service.port | quote }} 8 | name: {{ template "alertmanager.name" . }} 9 | labels: 10 | name: {{ template "alertmanager.name" . }} 11 | spec: 12 | ports: 13 | - port: {{ .Values.service.port }} 14 | name: {{ template "alertmanager.name" . }} 15 | selector: 16 | app: {{ template "alertmanager.name" . }} 17 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | kind: ServiceAccount 2 | apiVersion: v1 3 | metadata: 4 | name: {{ include "alertmanager.name" . }} 5 | -------------------------------------------------------------------------------- /helm/charts/alertmanager/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for alertmanager. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | replicaCount: 1 6 | 7 | updateStrategy: RollingUpdate 8 | 9 | init: 10 | image: 11 | repository: busybox 12 | tag: "1.30" 13 | resources: 14 | limits: 15 | cpu: 10m 16 | memory: 10Mi 17 | requests: 18 | cpu: 1m 19 | memory: 5Mi 20 | 21 | alertmanager: 22 | image: 23 | repository: prom/alertmanager 24 | tag: v0.17.0 25 | configFile: "/etc/alertmanager/alertmanager.yml" 26 | storagePath: "/alertmanager" 27 | meshListenAddress: 6783 28 | resources: 29 | limits: 30 | cpu: 20m 31 | memory: 64Mi 32 | requests: 33 | cpu: 10m 34 | memory: 32Mi 35 | alertmanagerConfigController: 36 | image: 37 | repository: dbsystel/alertmanager-config-controller 38 | tag: latest 39 | url: "http://localhost:9093/-/reload" 40 | id: "0" 41 | path: "/etc/config" 42 | template: "/etc/alertmanager/alertmanager.tmpl" 43 | logLevel: "info" 44 | key: "q5!sder6P" 45 | 46 | service: 47 | port: 9093 48 | 49 | ingress: 50 | host: alertmanager.xxx.yyy 51 | # alertmanager.ctmpl 52 | # 53 | 54 | route_dummy: 55 | group_by: ['alertname', 'instance'] 56 | group_wait: 1m 57 | group_interval: 5m 58 | repeat_interval: 7d 59 | receiver: dummy 60 | receivers_dummy: 61 | - name: dummy 62 | webhook_configs: 63 | - send_resolved: true 64 | url: "http://localhost" 65 | --------------------------------------------------------------------------------