Skip to content

Commit

Permalink
feat: add Runbook URL on alertmanager template (#124)
Browse files Browse the repository at this point in the history
* feat: add Runbook URL on alertmanager template

* docs(terraform-docs): generate docs and write to README.adoc

---------

Co-authored-by: omohammed95 <[email protected]>
  • Loading branch information
omohammed95 and omohammed95 authored May 16, 2024
1 parent c4fd2aa commit dbd2f36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ The following providers are used by this module:

- [[provider_random]] <<provider_random,random>> (>= 3)

- [[provider_null]] <<provider_null,null>> (>= 3)

- [[provider_kubernetes]] <<provider_kubernetes,kubernetes>> (>= 2)

- [[provider_utils]] <<provider_utils,utils>> (>= 1)

- [[provider_argocd]] <<provider_argocd,argocd>> (>= 5)

- [[provider_null]] <<provider_null,null>> (>= 3)

=== Resources

The following resources are used by this module:
Expand Down Expand Up @@ -358,10 +358,10 @@ Description: The admin password for Grafana.
[cols="a,a",options="header,autowidth"]
|===
|Name |Version
|[[provider_random]] <<provider_random,random>> |>= 3
|[[provider_null]] <<provider_null,null>> |>= 3
|[[provider_argocd]] <<provider_argocd,argocd>> |>= 5
|[[provider_kubernetes]] <<provider_kubernetes,kubernetes>> |>= 2
|[[provider_random]] <<provider_random,random>> |>= 3
|[[provider_utils]] <<provider_utils,utils>> |>= 1
|===
Expand Down
39 changes: 21 additions & 18 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,27 @@ locals {

alertmanager_template_files = length(local.alertmanager.slack_routes) > 0 ? {
"slack.tmpl" = <<-EOT
{{ define "slack.title" -}}
[{{ .Status | toUpper }}
{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{- end -}}
] {{ .CommonLabels.alertname }}
{{ end }}
{{ define "slack.text" -}}
{{ range .Alerts }}
*Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
{{- if .Annotations.description }}
*Severity:* `{{ .Labels.severity }}`
*Description:* {{ .Annotations.description }}
{{- end }}
*Graph:* <{{ .GeneratorURL }}|:chart_with_upwards_trend:>
*Labels:*
{{ range .Labels.SortedPairs }} - *{{ .Name }}:* `{{ .Value }}`
{{ end }}
{{ end }}
{{ end }}
{{ define "slack.title" -}}
[{{ .Status | toUpper }}
{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{- end -}}
] {{ .CommonLabels.alertname }}
{{ end }}
{{ define "slack.text" -}}
{{ range .Alerts }}
*Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
{{- if .Annotations.description }}
*Severity:* `{{ .Labels.severity }}`
*Description:* {{ .Annotations.description }}
{{- end }}
*Graph:* <{{ .GeneratorURL }}|:chart_with_upwards_trend:>
*Labels:*
{{ range .Labels.SortedPairs }} - *{{ .Name }}:* `{{ .Value }}`
{{ end }}
{{- if .Annotations.runbook_url }}
*Runbook URL:* <{{ .Annotations.runbook_url }}|Click here>
{{- end }}
{{ end }}
{{ end }}
EOT
} : {}

Expand Down

0 comments on commit dbd2f36

Please sign in to comment.