forked from nixys/nxs-universal-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roman Andreev
committed
Jun 16, 2021
1 parent
dc0e17d
commit 8f5a427
Showing
4 changed files
with
130 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{{- $CJ := dict -}} | ||
{{- if .Values.cronJobs -}} | ||
{{- if kindIs "string" .Values.cronJobs -}} | ||
{{- $CJ = fromYaml .Values.cronJobs -}} | ||
{{- else if kindIs "map" .Values.cronJobs -}} | ||
{{- $CJ = .Values.cronJobs -}} | ||
{{- end -}} | ||
{{- else if .Values.cronJobsFileName -}} | ||
{{- $CJ = fromYaml (.Files.Get .Values.cronJobsFileName) -}} | ||
{{- end -}} | ||
{{- range $CJ.jobs }} | ||
{{- $cronJobName := include "helpers.app.fullname" (dict "name" .name "context" $) }} | ||
{{- if .duration_alert }} | ||
--- | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PrometheusRule | ||
metadata: | ||
name: cronjob-{{ $cronJobName }} | ||
labels: | ||
prometheus: k8s | ||
role: alert-rules | ||
namespace: nxs-monitoring | ||
spec: | ||
groups: | ||
- name: "cronjobs_rules" | ||
interval: 1m # period check for alerts | ||
rules: | ||
- alert: "cronjob-{{ $cronJobName }}-too-long-execution" | ||
expr: '((time() - kube_job_status_start_time{namespace="{{ $.Release.Namespace }}", job_name=~"cronjob-{{ $cronJobName }}-[0-9]{10}"}) and kube_job_status_active{namespace="{{ $.Release.Namespace }}", job_name=~"cronjob-{{ $cronJobName }}-[0-9]{10}"} == 1) > {{ .duration_alert }}' | ||
for: 3m | ||
labels: | ||
severity: warning | ||
annotations: | ||
message: "CronJob {{ $.Release.Namespace }}/cronjob-{{ $cronJobName }} is taking more than {{ .duration_alert }} to complete" | ||
{{- end }} | ||
{{- end }} | ||
--- | ||
{{- $j := dict -}} | ||
{{- if .Values.jobs -}} | ||
{{- if kindIs "string" .Values.jobs -}} | ||
{{- $j = fromYaml .Values.jobs -}} | ||
{{- else if kindIs "map" .Values.jobs -}} | ||
{{- $j = .Values.jobs -}} | ||
{{- end -}} | ||
{{- else if .Values.jobsFileName -}} | ||
{{- $j = fromYaml (.Files.Get .Values.jobsFileName) -}} | ||
{{- end -}} | ||
{{- range $j.jobs }} | ||
{{- $jobName := include "helpers.app.fullname" (dict "name" .name "context" $) }} | ||
{{- if .duration_alert }} | ||
--- | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PrometheusRule | ||
metadata: | ||
name: job-{{ $jobName }} | ||
labels: | ||
prometheus: k8s | ||
role: alert-rules | ||
namespace: nxs-monitoring | ||
spec: | ||
groups: | ||
- name: "jobs_rules" | ||
interval: 1m # period check for alerts | ||
rules: | ||
- alert: "job-{{ $jobName }}-too-long-execution" | ||
expr: '((time() - kube_job_status_start_time{namespace="{{ $.Release.Namespace }}", job_name=~"job-{{ $jobName }}-[0-9]{10}"}) and kube_job_status_active{namespace="{{ $.Release.Namespace }}", job_name=~"job-{{ $jobName }}-[0-9]{10}"} == 1) > {{ .duration_alert }}' | ||
for: 3m | ||
labels: | ||
severity: warning | ||
annotations: | ||
message: "CronJob {{ $.Release.Namespace }}/job-{{ $jobName }} is taking more than {{ .duration_alert }} to complete" | ||
{{- end }} | ||
{{- end }} |
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