-
Notifications
You must be signed in to change notification settings - Fork 6
Add rule for Pod (un)readiness and alarm to Slack #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
450dd55
748a5a6
122538b
29f9d36
73f3f55
0f991fd
9cd38a4
1a7676c
0d8deff
58e4117
81044fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
global: | ||
resolve_timeout: 5m | ||
slack_api_url: '' | ||
route: | ||
group_by: ['alertname', 'cluster', 'service', 'deployment', 'namespace'] | ||
group_wait: 30s | ||
group_interval: 5m | ||
repeat_interval: 1h | ||
receiver: default-receiver | ||
routes: | ||
- match: | ||
alertname: DeadMansSwitch | ||
receiver: 'null' | ||
receivers: | ||
- name: 'default-receiver' | ||
slack_configs: | ||
- channel: '#alerts' | ||
title: >- | ||
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] | ||
{{ range .Alerts }} | ||
{{ .Annotations.summary }} | ||
{{ end }} | ||
text: >- | ||
{{ range .Alerts }} | ||
*Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}` | ||
*Description:* {{ .Annotations.description }} | ||
*Graph:* <{{ .GeneratorURL }}|:chart_with_upwards_trend:> *Runbook:* <{{ .Annotations.runbook }}|:spiral_note_pad:> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @solsson Oooo ... nice idea! Are you using SkeltonThatcher's run book template? Do you have any example ones you can share? |
||
*Details:* | ||
{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}` | ||
{{ end }} | ||
{{ end }} | ||
send_resolved: true | ||
- name: 'null' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
if [ -z "${NAMESPACE}" ]; then | ||
NAMESPACE=monitoring | ||
fi | ||
|
||
kctl() { | ||
kubectl --namespace "$NAMESPACE" "$@" | ||
} | ||
|
||
SECRET=alertmanager-main | ||
|
||
kctl create secret generic $SECRET --from-file $DIR/alertmanager.yaml --dry-run -o=yaml \ | ||
| kctl replace secret $SECRET -f - | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does replace work if the secret does not already exist? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
if [ -z "${NAMESPACE}" ]; then | ||
NAMESPACE=monitoring | ||
fi | ||
|
||
kctl() { | ||
kubectl --namespace "$NAMESPACE" "$@" | ||
} | ||
|
||
SECRET=prometheus-custom | ||
|
||
$DIR/k8s-rules-generate.sh | kctl replace -f - |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
groups: | ||
- name: ./yolean.availability.rules | ||
rules: | ||
- alert: AvailabilityCheckFailed | ||
expr: "(kube_deployment_status_replicas_available / kube_deployment_spec_replicas) * 100 < 100" | ||
# NOTE This seems to be optional, thus missing should equal 0 ? | ||
# for: 5s | ||
# NOTE: | ||
# Both labels and annotations support templates: | ||
# https://prometheus.io/docs/alerting/rules/#templating | ||
labels: | ||
severity: critical | ||
annotations: | ||
summary: "{{ $value }}% of {{ $labels.deployment }}[{{ $labels.namespace }}] available" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like Line 25 has an extra space, as it does in the article you and I both copy pasted it from. 😉