Skip to content

Commit

Permalink
Merge pull request #178 from lusson-luo/dev-support-config-customize-…
Browse files Browse the repository at this point in the history
…template

helm 支持通过配置文件新增模版
  • Loading branch information
feiyu563 committed Jan 10, 2022
2 parents 1743f9f + e6a367a commit eb64398
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apk del tzdata && \
apk update && apk upgrade && apk add --no-cache sqlite-libs curl
apk update && apk upgrade && apk add --no-cache sqlite-libs curl sqlite

HEALTHCHECK --start-period=10s --interval=20s --timeout=3s --retries=3 \
CMD curl -fs http://localhost:8080/health || exit 1
Expand Down
3 changes: 3 additions & 0 deletions example/helm/prometheusalert/config/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO `prometheus_alert_d_b` VALUES ('50', 'wx', 'Prometheus', 'prometheus-wx-2', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}\r\n{{if eq $v.status \"resolved\"}}\r\n[Prometheus恢复信息]($v.generatorURL}})\r\n>**[{{$v.labels.alertname}}]({{$var}})**\r\n>告警级别: {{$v.labels.level}}\r\n开始时间: {{$v.startsAt}}\r\n结束时间: {{$v.endsAt}}\r\n故障主机IP: {{$v.labels.instance}}\r\n**{{$v.annotations.description}}**\r\n{{else}}\r\n[Prometheus告警信息]($v.generatorURL}})\r\n>**[{{$v.labels.alertname}}]({{$var}})**\r\n>告警级别: {{$v.labels.level}}\r\n开始时间: {{$v.startsAt}}\r\n结束时间: {{$v.endsAt}}\r\n故障主机IP: {{$v.labels.instance}}\r\n**{{$v.annotations.description}}**\r\n{{end}}\r\n{{ end }}', '2020-12-22 03:07:19');


6 changes: 6 additions & 0 deletions example/helm/prometheusalert/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ['sh', '-c', "sqlite3 /app/db/PrometheusAlertDB.db '.read /app/db/init.sql' && /app/PrometheusAlert"]
env:
- name: TZ
value: "Asia/Shanghai"
Expand All @@ -38,6 +39,9 @@ spec:
- name: prometheus-alert-center-conf
mountPath: /app/user.csv
subPath: user.csv
- name: prometheus-alert-center-conf
mountPath: /app/db/init.sql
subPath: init.sql
livenessProbe:
httpGet:
path: /health
Expand Down Expand Up @@ -79,3 +83,5 @@ spec:
path: app.conf
- key: user.csv
path: user.csv
- key: init.sql
path: init.sql
1 change: 1 addition & 0 deletions example/helm/prometheusalert/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ global:
replicaCount: 1

image:
# 支持配置自定义模版需要重出镜像,或者使用本人构建镜像:lusson/prometheusalert:v1.0
repository: feiyu563/prometheus-alert:latest
pullPolicy: IfNotPresent

Expand Down

0 comments on commit eb64398

Please sign in to comment.