-
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.
feat(application-template): PrometheusRule CR 기능 추가하기 (#17)
* fix: render service monitor CR only the CRD installed * feat: add prometheus rule CR * feat: change rules to alerting_roles * feat: worker, scheduler에 prometheus rule 추가 * feat: trigger actions * feat: update chart version * feat: update readme
- Loading branch information
Showing
7 changed files
with
295 additions
and
5 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
81 changes: 81 additions & 0 deletions
81
charts/application-template/templates/scheduler/prometheus-rule.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,81 @@ | ||
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/PrometheusRule" }} | ||
{{- if and .Values.scheduler.enabled (or .Values.scheduler.observability.prometheus.alerting_rules.enabled .Values.scheduler.observability.prometheus.istio_alerting_rules.enabled) }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PrometheusRule | ||
metadata: | ||
name: {{ template "application.scheduler.name" . }} | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
groups: | ||
{{- if .Values.scheduler.observability.prometheus.alerting_rules.enabled }} | ||
- name: ServiceContainerResourceUsage | ||
alerting_rules: | ||
- alert: "HighServiceContainerCPUUsage" | ||
expr: | | ||
avg( | ||
rate(container_cpu_usage_seconds_total{ container={{ .Values.scheduler.name | quote }} }[2m]) * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.scheduler.name" . | quote }} } | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="cpu", container={{ .Values.scheduler.name | quote }} }) | ||
) | ||
* 100 | ||
> {{ .Values.scheduler.observability.prometheus.alerting_rules.highCpuUsageThreshold }} | ||
for: 5m | ||
labels: | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.scheduler.name" . | title }}] High CPU usage" | ||
description: "[{{ include "application.scheduler.name" . | title }}] 서비스의 최근 CPU 사용량이 {{ .Values.scheduler.observability.prometheus.alerting_rules.highCpuUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
|
||
- alert: HighServiceContainerMemoryUsage | ||
expr: | | ||
avg( | ||
(container_memory_rss{ container={{ .Values.scheduler.name | quote }} } * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.scheduler.name" . | quote }} }) | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="memory", container={{ .Values.scheduler.name | quote }} }) | ||
) * 100 | ||
> {{ .Values.scheduler.observability.prometheus.alerting_rules.highMemoryUsageThreshold }} | ||
for: 5m | ||
labels: | ||
service: {{ include "application.scheduler.name" . | quote }} | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.scheduler.name" . | title }}] High memory usage" | ||
description: "[{{ include "application.scheduler.name" . | title }}] 서비스의 최근 메모리 사용량이 {{ .Values.scheduler.observability.prometheus.alerting_rules.highMemoryUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
{{- end }} | ||
{{- if .Values.scheduler.observability.prometheus.istio_alerting_rules.enabled }} | ||
- name: IstioContainerResourceUsage | ||
alerting_rules: | ||
- alert: "HighIstioContainerCPUUsage" | ||
expr: | | ||
avg( | ||
rate(container_cpu_usage_seconds_total{ container="istio-proxy" }[2m]) * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.scheduler.name" . | quote }} } | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="cpu", container="istio-proxy" }) | ||
) | ||
* 100 | ||
> {{ .Values.scheduler.observability.prometheus.istio_alerting_rules.highCpuUsageThreshold }} | ||
for: 5m | ||
labels: | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.scheduler.name" . | title }}][istio-proxy] High CPU usage" | ||
description: "[{{ include "application.scheduler.name" . | title }}][istio-proxy] 서비스의 최근 CPU 사용량이 {{ .Values.scheduler.observability.prometheus.istio_alerting_rules.highCpuUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
|
||
- alert: HighIstioContainerMemoryUsage | ||
expr: | | ||
avg( | ||
(container_memory_rss{ container="istio-proxy" } * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.scheduler.name" . | quote }} }) | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="memory", container="istio-proxy" }) | ||
) * 100 | ||
> {{ .Values.scheduler.observability.prometheus.istio_alerting_rules.highMemoryUsageThreshold }} | ||
for: 5m | ||
labels: | ||
service: {{ include "application.scheduler.name" . | quote }} | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.scheduler.name" . | title }}][istio-proxy] High memory usage" | ||
description: "[{{ include "application.scheduler.name" . | title }}][istio-proxy] 서비스의 최근 메모리 사용량이 {{ .Values.scheduler.observability.prometheus.istio_alerting_rules.highMemoryUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
81 changes: 81 additions & 0 deletions
81
charts/application-template/templates/server/prometheus-rule.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,81 @@ | ||
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/PrometheusRule" }} | ||
{{- if and .Values.server.enabled (or .Values.server.observability.prometheus.rules.enabled .Values.server.observability.prometheus.istio_rules.enabled) }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PrometheusRule | ||
metadata: | ||
name: {{ template "application.server.name" . }} | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
groups: | ||
{{- if .Values.server.observability.prometheus.rules.enabled }} | ||
- name: ServiceContainerResourceUsage | ||
rules: | ||
- alert: "HighServiceContainerCPUUsage" | ||
expr: | | ||
avg( | ||
rate(container_cpu_usage_seconds_total{ container={{ .Values.server.name | quote }} }[2m]) * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.server.name" . | quote }} } | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="cpu", container={{ .Values.server.name | quote }} }) | ||
) | ||
* 100 | ||
> {{ .Values.server.observability.prometheus.rules.highCpuUsageThreshold }} | ||
for: 5m | ||
labels: | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.server.name" . | title }}] High CPU usage" | ||
description: "[{{ include "application.server.name" . | title }}] 서비스의 최근 CPU 사용량이 {{ .Values.server.observability.prometheus.rules.highCpuUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
|
||
- alert: HighServiceContainerMemoryUsage | ||
expr: | | ||
avg( | ||
(container_memory_rss{ container={{ .Values.server.name | quote }} } * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.server.name" . | quote }} }) | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="memory", container={{ .Values.server.name | quote }} }) | ||
) * 100 | ||
> {{ .Values.server.observability.prometheus.rules.highMemoryUsageThreshold }} | ||
for: 5m | ||
labels: | ||
service: {{ include "application.server.name" . | quote }} | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.server.name" . | title }}] High memory usage" | ||
description: "[{{ include "application.server.name" . | title }}] 서비스의 최근 메모리 사용량이 {{ .Values.server.observability.prometheus.rules.highMemoryUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
{{- end }} | ||
{{- if .Values.server.observability.prometheus.istio_rules.enabled }} | ||
- name: IstioContainerResourceUsage | ||
rules: | ||
- alert: "HighIstioContainerCPUUsage" | ||
expr: | | ||
avg( | ||
rate(container_cpu_usage_seconds_total{ container="istio-proxy" }[2m]) * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.server.name" . | quote }} } | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="cpu", container="istio-proxy" }) | ||
) | ||
* 100 | ||
> {{ .Values.server.observability.prometheus.istio_rules.highCpuUsageThreshold }} | ||
for: 5m | ||
labels: | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.server.name" . | title }}][istio-proxy] High CPU usage" | ||
description: "[{{ include "application.server.name" . | title }}][istio-proxy] 서비스의 최근 CPU 사용량이 {{ .Values.server.observability.prometheus.istio_rules.highCpuUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
|
||
- alert: HighIstioContainerMemoryUsage | ||
expr: | | ||
avg( | ||
(container_memory_rss{ container="istio-proxy" } * on(pod) group_left kube_pod_labels{ label_app_kubernetes_io_name={{ include "application.server.name" . | quote }} }) | ||
/ on(pod) | ||
(kube_pod_container_resource_limits{ resource="memory", container="istio-proxy" }) | ||
) * 100 | ||
> {{ .Values.server.observability.prometheus.istio_rules.highMemoryUsageThreshold }} | ||
for: 5m | ||
labels: | ||
service: {{ include "application.server.name" . | quote }} | ||
severity: critical | ||
annotations: | ||
summary: "[{{ include "application.server.name" . | title }}][istio-proxy] High memory usage" | ||
description: "[{{ include "application.server.name" . | title }}][istio-proxy] 서비스의 최근 메모리 사용량이 {{ .Values.server.observability.prometheus.istio_rules.highMemoryUsageThreshold }}% 이상이 되었습니다. 현재값: {{`{{ .Value | humanize }}`}}%" | ||
{{- end }} | ||
{{- 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
Oops, something went wrong.