-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from DFE-Digital/feature/1661-add-pod-cpu-ale…
…rt-rule Added high pod cpu usage alert
- Loading branch information
Showing
20 changed files
with
184 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
cluster/terraform_kubernetes/config/prometheus/alertmanager-config.yaml
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
cluster/terraform_kubernetes/config/prometheus/alertmanager-slack.yaml
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
cluster/terraform_kubernetes/config/prometheus/alertmanager/alertmanager-slack.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ define "slack.devops.text" }} | ||
{{range .Alerts}}{{.Annotations.DESCRIPTION}} | ||
{{end}} | ||
{{ end }} | ||
|
||
{{ define "slack.alert.text" }} | ||
{{ range .Alerts }} | ||
*Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}` | ||
*Description:* {{ .Annotations.description }} | ||
*Details:* | ||
{{ range .Labels.SortedPairs }} - *{{ .Name }}:* `{{ .Value }}` | ||
{{ end }} | ||
{{ end }} | ||
{{ end }} | ||
|
||
{{ define "slack.alert.title" }} | ||
{{ with index .Alerts 0 }} | ||
{{ .Annotations.summary }} | ||
{{ end }} | ||
{{ end }} |
50 changes: 50 additions & 0 deletions
50
cluster/terraform_kubernetes/config/prometheus/alertmanager/alertmanager.yml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
global: | ||
resolve_timeout: 1m | ||
%{ if slack_url != "" ~} | ||
slack_api_url: '${slack_url}' | ||
%{ endif ~} | ||
|
||
route: | ||
# The default route, this will be used if the matcher(s) of any of the child routes are not satisfied | ||
receiver: 'slack-notifications' | ||
group_interval: 1m | ||
repeat_interval: 1h | ||
group_by: [period] | ||
routes: | ||
- receiver: 'slack-notifications' | ||
group_interval: 24h | ||
repeat_interval: 24h | ||
match: | ||
period: 'daily' | ||
- receiver: 'slack-notifications' | ||
group_interval: 1m | ||
repeat_interval: 1h | ||
match: | ||
period: 'out-of-hours' | ||
%{ for receiver, webhook in slack_receivers ~} | ||
- receiver: ${ receiver } | ||
group_interval: 1m | ||
repeat_interval: 1h | ||
match: | ||
receiver: '${ receiver }' | ||
%{ endfor ~} | ||
|
||
templates: | ||
- /etc/alertmanager-templates/*.tmpl | ||
|
||
receivers: | ||
- name: slack-notifications | ||
%{ if slack_url != "" ~} | ||
slack_configs: | ||
- send_resolved: true | ||
text: '{{ template "slack.alert.text" . }}' | ||
title: '{{ template "slack.alert.title" . }}' | ||
%{ endif ~} | ||
%{ for receiver, webhook in slack_receivers ~} | ||
- name: ${ receiver } | ||
slack_configs: | ||
- api_url: ${ webhook } | ||
send_resolved: true | ||
text: '{{ template "slack.alert.text" . }}' | ||
title: '{{ template "slack.alert.title" . }}' | ||
%{ endfor ~} |
24 changes: 24 additions & 0 deletions
24
cluster/terraform_kubernetes/config/prometheus/alertmanager/app_alert.rules.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
groups: | ||
- name: Container restarts | ||
rules: | ||
- alert: High number of restarted containers | ||
expr: sum(kube_pod_container_status_restarts_total) > 1000 | ||
for: 5m | ||
labels: | ||
severity: high | ||
annotations: | ||
summary: High number of restarted containers | ||
- name: High CPU | ||
rules: | ||
%{ for instance in apps ~} | ||
- alert: High CPU Alert for ${instance.app_name} | ||
expr: avg(rate(container_cpu_usage_seconds_total{namespace="${instance.namespace}",pod=~"${instance.app_name}-[a-z0-9]+-[a-z0-9]+",container!=""}[5m])) by (namespace,container,image) > ${instance.max_cpu} | ||
for: 5m | ||
annotations: | ||
summary: High CPU Alert for ${instance.app_name} | ||
description: "Average pod CPU usage has been above {{ ${instance.max_cpu} | humanizePercentage }} in the last 5 minutes (current value: {{ $value | humanizePercentage }})" | ||
labels: | ||
severity: high | ||
app: ${instance.app_name} | ||
%{ if instance.receiver != null }receiver: ${instance.receiver}%{ endif } | ||
%{ endfor ~} |
16 changes: 0 additions & 16 deletions
16
cluster/terraform_kubernetes/config/prometheus/development.prometheus.rules
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
cluster/terraform_kubernetes/config/prometheus/platform-test.prometheus.rules
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
cluster/terraform_kubernetes/config/prometheus/production.prometheus.rules
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
cluster/terraform_kubernetes/config/prometheus/test.prometheus.rules
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data "azurerm_key_vault" "key_vault" { | ||
name = var.cluster_kv | ||
resource_group_name = var.resource_group_name | ||
} | ||
|
||
data "azurerm_key_vault_secrets" "main" { | ||
key_vault_id = data.azurerm_key_vault.key_vault.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.