Skip to content

Commit

Permalink
feat: multiple alert endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurice Faber committed Nov 29, 2020
1 parent adbf699 commit b5aa63c
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 38 deletions.
7 changes: 6 additions & 1 deletion .demo/env/secrets.settings.yaml
Expand Up @@ -23,8 +23,13 @@ google:
home:
slack:
url: https://hooks.slack.com/services/id
email:
criticals: admins@yourdoma.in
alerts:
slack:
url: https://hooks.slack.com/services/id
email:
to: admins@yourdoma.in
smtp:
smarthost: some.smtp.host:587
nonCriticals: admins@yourdoma.in
criticals: admins@yourdoma.in
3 changes: 3 additions & 0 deletions .demo/env/secrets.teams.yaml
@@ -1,6 +1,9 @@
teamConfig:
teams:
demo:
alerts:
email:
critical: admins@yourdoma.in
oidc:
groupMapping: somesecretvalue
password: somesecretvalue
3 changes: 0 additions & 3 deletions .demo/env/settings.yaml
@@ -1,8 +1,5 @@
alerts:
drone: slack
email:
from: admins@your.cloud
smarthost: some.smtp.host
receivers:
- slack
- email
Expand Down
3 changes: 3 additions & 0 deletions .demo/env/teams.yaml
@@ -1,6 +1,9 @@
teamConfig:
teams:
demo:
alerts:
receivers:
- email
id: demo
clusters:
- aws/demo
Expand Down
23 changes: 11 additions & 12 deletions helmfile.d/snippets/alertmanager.gotmpl
Expand Up @@ -6,12 +6,13 @@ global:
slack_api_url: {{ .instance | get "alerts.slack.url" (.root | get "alerts.slack.url" (.root | get "home.slack.url" nil)) }}
{{- end }}
{{- if or (has "email" $receivers) (and .root.otomi.isHomeMonitored (has "email" $homeReceivers)) }}
smtp_smarthost: {{ .instance | get "alerts.email.smarthost" (.root | get "alerts.email.smarthost" (.root | get "home.email.smarthost" nil)) }}
smtp_hello: {{ .instance | get "alerts.email.hello" (.root | get "alerts.email.hello" .root.cluster.domain) }}
smtp_auth_username: {{ .instance | get "alerts.email.auth_username" (.root | get "alerts.email.auth_username" (.root | get "home.email.auth_username" nil)) }}
smtp_auth_password: {{ .instance | get "alerts.email.auth_password" (.root | get "alerts.email.auth_password" (.root | get "home.email.auth_password" nil)) }}
smtp_auth_secret: {{ .instance | get "alerts.email.auth_secret" (.root | get "alerts.email.auth_secret" (.root | get "home.email.auth_secret" nil)) }}
smtp_auth_identity: {{ .instance | get "alerts.email.auth_identity" (.root | get "alerts.email.auth_identity" (.root | get "home.email.auth_identity" nil)) }}
smtp_smarthost: {{ .instance | get "alerts.email.smtp.smarthost" (.root | get "alerts.email.smtp.smarthost" (.root | get "home.email.smtp.smarthost" nil)) }}
smtp_hello: {{ .instance | get "alerts.email.smtp.hello" (.root | get "alerts.email.smtp.hello" .root.cluster.domain) }}
smtp_from: {{ .instance | get "alerts.email.smtp.from" (.root | get "alerts.email.smtp.from" (print "alerts@" .root.cluster.domain)) }}
smtp_auth_username: {{ .instance | get "alerts.email.smtp.auth_username" (.root | get "alerts.email.smtp.auth_username" (.root | get "home.email.smtp.auth_username" nil)) }}
smtp_auth_password: {{ .instance | get "alerts.email.smtp.auth_password" (.root | get "alerts.email.smtp.auth_password" (.root | get "home.email.smtp.auth_password" nil)) }}
smtp_auth_secret: {{ .instance | get "alerts.email.smtp.auth_secret" (.root | get "alerts.email.smtp.auth_secret" (.root | get "home.email.smtp.auth_secret" nil)) }}
smtp_auth_identity: {{ .instance | get "alerts.email.smtp.auth_identity" (.root | get "alerts.email.smtp.auth_identity" (.root | get "home.email.smtp.auth_identity" nil)) }}
{{- end }}
route:
receiver: default
Expand Down Expand Up @@ -62,17 +63,15 @@ receivers:
send_resolved: true
{{- end }}
{{- if has "email" $receivers }}
{{- $to := .instance | get "alerts.email.to" (.root | get "alerts.email.to") }}
{{- $from := .instance | get "alerts.email.from" (.root | get "alerts.email.from" (print "alerts@" .root.cluster.domain)) }}
{{- $criticalTo := .instance | get "alerts.email.critical" (.root | get "alerts.email.critical") }}
{{- $nonCriticalTo := .instance | get "alerts.email.nonCritical" (.root | get "alerts.email.nonCritical") }}
- name: default
email_configs:
- to: {{ $to }}
from: {{ $from }}
- to: {{ $nonCriticalTo }}
send_resolved: true
- name: critical
email_configs:
- to: {{ $to }}
from: {{ $from }}
- to: {{ $criticalTo }}
send_resolved: true
{{- end }}
{{- if .root.otomi.isHomeMonitored }}
Expand Down
59 changes: 38 additions & 21 deletions values-schema.yaml
Expand Up @@ -18,6 +18,12 @@ definitions:
type: string
clientSecretValue:
type: string
email:
type: string
pattern: ^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$
hostPort:
type: string
pattern: ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]):()([1-9]|[1-5]?[0-9]{2,4}|6[1-4][0-9]{3}|65[1-4][0-9]{2}|655[1-2][0-9]|6553[1-5])$
registry:
type: string
pattern: ^[a-z0-9]+(?:[._-][a-z0-9]+)*$
Expand Down Expand Up @@ -174,6 +180,10 @@ definitions:
url:
type: string
pattern: ^(https:\/\/)([\w\-])+\.{1}([a-zA-Z]{2,63})([\/\w-]*)*\/?\??([^#\n\r]*)?#?([^\n\r]*)$
repoUrl:
type: string
description: Path to a remote git repo without protocol. Will use https to access.
pattern: ^(.+@)*([\w\d\.]+)(:[\d]+){0,1}/*(.*)$
alerts:
type: object
properties:
Expand Down Expand Up @@ -230,24 +240,31 @@ definitions:
email:
type: object
properties:
from:
type: string
to:
type: string
smarthost:
type: string
hello:
type: string
auth_username:
type: string
auth_password:
type: string
auth_secret:
type: string
auth_identity:
type: string
required: [smarthost, to]
required: [receivers]
nonCritical:
description: One or more email addresses (comma separated) for non-critical events.
'$ref': '#/definitions/email'
critical:
description: One or more email addresses (comma separated) for critical events.
'$ref': '#/definitions/email'
smtp:
properties:
from:
description: The "from" address. Defaults to alerts@$clusterDomain.
'$ref': '#/definitions/email'
smarthost:
description: The smtp host:port combination.
'$ref': '#/definitions/hostPort'
hello:
type: string
auth_username:
type: string
auth_password:
type: string
auth_secret:
type: string
auth_identity:
type: string
required: [smarthost]
azureMonitor:
type: object
properties:
Expand Down Expand Up @@ -577,7 +594,7 @@ properties:
azureClientSecret:
type: string
email:
type: string
'$ref': '#/definitions/email'
provider:
type: object
additionalProperties: false
Expand Down Expand Up @@ -1077,13 +1094,13 @@ properties:
branch:
type: string
email:
type: string
'$ref': '#/definitions/email'
localPath:
type: string
password:
type: string
repoUrl:
type: string
'$ref': '#/definitions/repoUrl'
user:
type: string
image:
Expand Down
2 changes: 1 addition & 1 deletion values/otomi-api/otomi-api.gotmpl
Expand Up @@ -27,7 +27,7 @@ secrets:
{{- end }}

env:
DEBUG: '*'
# DEBUG: '*'
GIT_REPO_URL: {{ $o.git.repoUrl }}
GIT_BRANCH: {{ $o | get "git.branch" "master" }}
CLUSTER_ID: {{ printf "%s/%s" $c.provider $c.name }}
Expand Down

0 comments on commit b5aa63c

Please sign in to comment.