Skip to content

Commit

Permalink
feat: upgrade prometheus-Alert application.
Browse files Browse the repository at this point in the history
  • Loading branch information
dellnoantechnp committed Jun 22, 2024
1 parent 33fc769 commit 830886f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 37 deletions.
10 changes: 8 additions & 2 deletions charts/prometheusalert/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ annotations:
- name: Chart Source
url: https://github.com/dellnoantechnp.github.io/tree/main/charts/xxl-job-admin
apiVersion: v2
appVersion: 4.9
appVersion: 4.9.1
name: prometheusalert
description: A Alert-Center for Prometheus Grafana and Graylog, alert message deliver to Wechat/Feishu/Lark/email/DingTalk/workWechat/webhook/telegram ...
home: https://github.com/feiyu563/PrometheusAlert
Expand All @@ -18,4 +18,10 @@ maintainers:
sources:
- https://github.com/feiyu563/PrometheusAlert
type: application
version: 1.2.3
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
tags:
- bitnami-common
version: 2.x.x
version: 1.3.0
11 changes: 11 additions & 0 deletions charts/prometheusalert/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ AlertmanagerConfig namespace
{{- else -}}
{{ .Release.Namespace }}
{{- end -}}
{{- end -}}


{{/*
Return true if a configmap object should be created on values
*/}}
{{- define "app.primary.createConfigmap" -}}
{{- if and .Values.config.app_conf }}
{{- true -}}
{{- else -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/prometheusalert/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
data:
{{- if .Values.config.app_conf }}
app.conf: |
{{ .Values.config.app_conf | indent 4 }}
{{- include "common.tplvalues.render" (dict "value" .Values.config.app_conf "context" $ ) | indent 4 }}
{{- end -}}

{{- if .Values.config.init_sql }}
Expand Down
30 changes: 10 additions & 20 deletions charts/prometheusalert/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
value: "Asia/Shanghai"
ports:
- name: http
containerPort: 8080
containerPort: {{ .Values.pod.containerPort }}
protocol: TCP
volumeMounts:
- name: prometheus-alert-center-conf
Expand All @@ -44,26 +44,16 @@ spec:
- name: prometheus-alert-center-conf
mountPath: /app/db/init.sql
subPath: init.sql
livenessProbe:
httpGet:
path: /health
port: http
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /health
port: http
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 3
{{- if .Values.pod.livenessProbe }}
livenessProbe: {{ toYaml .Values.pod.livenessProbe | nindent 12 }}
{{- end }}
{{- if .Values.pod.readinessProbe }}
readinessProbe: {{ toYaml .Values.pod.readinessProbe | nindent 12 }}
{{- end }}
{{- if or (hasKey .Values.pod.resources "requests") (hasKey .Values.pod.resources "limits") }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- toYaml .Values.pod.resources | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
52 changes: 38 additions & 14 deletions charts/prometheusalert/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@ nameOverride: ""

fullnameOverride: ""

pod:
containerPort: 8000

livenessProbe:
httpGet:
path: /health
port: http
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /health
port: http
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 3

resources: {}
#resources:
# limits:
# cpu: 500m
# memory: 512Mi
# requests:
# cpu: 10m
# memory: 128Mi

service:
type: ClusterIP
port: 8080
Expand All @@ -31,13 +62,6 @@ ingress:
paths: ["/"]
tls: []

resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 10m
memory: 128Mi

## @param affinity Affinity for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
Expand Down Expand Up @@ -194,7 +218,7 @@ config:
#监听地址
httpaddr = "0.0.0.0"
#监听端口
httpport = 8080
httpport = {{ .Values.pod.containerPort | default "8000" }}
# 运行模式 dev|prod
runmode = dev
#设置代理 proxy = http://123.123.123.123:8080
Expand All @@ -218,7 +242,7 @@ config:
#故障恢复是否启用电话通知0为关闭,1为开启
phonecallresolved=0
#是否前台输出file or console
logtype=file
logtype=console
#日志文件路径
logpath=logs/prometheusalertcenter.log
#转换Prometheus,graylog告警消息的时区为CST时区(如默认已经是CST时区,请勿开启)
Expand Down Expand Up @@ -490,16 +514,16 @@ config:
INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (1, 'dd', 'Prometheus', 'prometheus-dd', '{{ $var := .externalURL}}
{{ range $k,$v:=.alerts }}
{{if eq $v.status "resolved"}}
## <font color="#3FB950">**Prometheus 恢复通知**</font>
## <font color="#16a329">**Prometheus 恢复通知**</font>
---
* 🟡【告警名称】{{$v.labels.alertname}}
* 🚨【告警级别】{{ $v.labels.severity}}
* ✅【告警状态】{{$v.status}}
* 🧭【开始时间】{{GetCSTtime $v.startsAt}}
* 🧭【结束时间】{{GetCSTtime $v.endsAt}}
* 🏷️【命名空间】{{$v.labels.namespace}}
* 📡【实例名称】{{$v.labels.host}}{{$v.labels.pod}}{{$v.labels.job}}{{$v.labels.deployment}}{{$v.labels.statefulset}}
* 📝【告警详情】{{ $v.annotations.message }}{{ $v.annotations.description}};{{$v.annotations.summary}}
* 📡【实例名称】{{$v.labels.host}}/{{$v.labels.pod}}/{{$v.labels.job}}/{{$v.labels.deployment}}/{{$v.labels.statefulset}}
* 📝【告警详情】{{ $v.annotations.message }}/{{ $v.annotations.description}};{{$v.annotations.summary}}
{{else}}
## <font color="#FF0000">**Prometheus 告警通知**</font>
---
Expand All @@ -508,8 +532,8 @@ config:
* 🔥【告警状态】{{$v.status}}
* 🧭【开始时间】{{GetCSTtime $v.startsAt}}
* 🏷️【命名空间】{{$v.labels.namespace}}
* 📡【实例名称】{{$v.labels.host}}{{$v.labels.pod}}{{$v.labels.job}}{{$v.labels.deployment}}{{$v.labels.statefulset}}
* 📝【告警详情】{{ $v.annotations.message }}{{ $v.annotations.description}};{{$v.annotations.summary}}
* 📡【实例名称】{{$v.labels.host}}/{{$v.labels.pod}}/{{$v.labels.job}}/{{$v.labels.deployment}}/{{$v.labels.statefulset}}
* 📝【告警详情】{{ $v.annotations.message }}/{{ $v.annotations.description}};{{$v.annotations.summary}}
{{ end }}
{{ end }}
{{ $urimsg:="" }}
Expand Down

0 comments on commit 830886f

Please sign in to comment.