Skip to content

Commit

Permalink
bugfix: Update PrometheusAlert version 1.2.0
Browse files Browse the repository at this point in the history
        Update template-dd
  • Loading branch information
dellnoantechnp committed Mar 1, 2024
1 parent 54106aa commit 7349402
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/prometheusalert/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ maintainers:
sources:
- https://github.com/feiyu563/PrometheusAlert
type: application
version: 1.1.6
version: 1.2.0
29 changes: 29 additions & 0 deletions charts/prometheusalert/templates/AlertmanagerConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- with .Values.AlertmanagerConfig }}
{{- if .enabled -}}
{{- $fullName := include "prometheusalert.fullname" $ -}}
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
name: {{ $fullName }}
labels:
{{- include "prometheusalert.labels" $ | nindent 4 }}
{{- if .labels }}
{{ .labels | toYaml }}
{{- end }}
spec:
{{- if .inhibitRules }}
inhibitRules:
{{- .inhibitRules | toYaml | nindent 4 }}
{{- end }}
{{- if .muteTimeIntervals }}
muteTimeIntervals:
{{- .muteTimeIntervals | toYaml | nindent 4 }}
{{- end }}
receivers:
{{- .receivers | toYaml | nindent 4 }}
{{- if .route }}
route:
{{- .route | toYaml | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
9 changes: 7 additions & 2 deletions charts/prometheusalert/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
2.visit it in k8s cluster by:
2. visit it in k8s cluster by:
{{ template "prometheusalert.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.port }}

3. import init.sql to mysql / postgresql on first installation complete:
mysql prometheusalert < kubectl get cm {{ template "prometheusalert.name" . }} -o jsonpath='{.data.init\.sql}'

4.how to use it:
4. how to use it:
Please visit https://github.com/feiyu563/PrometheusAlert to get help!

{{- if .Values.AlertmanagerConfig.enabled }}
5. Check AlertmanagerConfig resource:
kubectl get -n {{ include "AlertmanagerConfig.namespace" }} AlertmanagerConfig {{ template "prometheusalert.fullname" . }} -o yaml
{{- end }}
11 changes: 11 additions & 0 deletions charts/prometheusalert/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
AlertmanagerConfig namespace
*/}}
{{- define "AlertmanagerConfig.namespace" -}}
{{- if .Values.AlertmanagerConfig.namespace }}
{{ .Values.AlertmanagerConfig.namespace }}
{{- else -}}
{{ .Release.Namespace }}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/prometheusalert/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Deployment
metadata:
name: {{ template "prometheusalert.fullname" . }}
labels:
{{ include "prometheusalert.labels" . | indent 4 }}
{{- include "prometheusalert.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
Expand Down
116 changes: 115 additions & 1 deletion charts/prometheusalert/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ image:
pullPolicy: IfNotPresent

nameOverride: ""

fullnameOverride: ""

service:
Expand All @@ -38,11 +39,124 @@ resources:
cpu: 10m
memory: 128Mi

## @param affinity Affinity for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
## Note: podAffinityPreset, podAntiAffinityPreset, and nodeAffinityPreset will be ignored when it's set
##
affinity: {}

## @param nodeSelector Node labels for pod assignment
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector: {}

## @param tolerations Tolerations for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []

affinity: {}
## @param receivers for AlertmanagerConfig receivers
## Ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/user-guides/alerting.md#using-alertmanagerconfig-resources
AlertmanagerConfig:
enabled: false

## @param namespace, if you Crd Alertmanager has alertmanagerConfigNamespaceSelector, you need to set correct namespace.
## if you don't set alertmanagerConfigNamespaceSelector, you need to set prometheus-operator same namespace.
namespace: {}

## @param labels, if you Crd Alertmanager has alertmanagerConfigSelector, you need to set this.
labels: {}

## @param inhibitRules List of inhibition rules. The rules will only apply to alerts matching the resource's namespace.
## Prometheus Ref: https://prometheus.io/docs/alerting/latest/configuration/#inhibit_rule
## Crd Doc Ref: https://doc.crds.dev/github.com/prometheus-operator/kube-prometheus/monitoring.coreos.com/AlertmanagerConfig/v1alpha1@v0.13.0#spec-inhibitRules
## Example:
## - equal:
## - namespace
## - alertname
## sourceMatch:
## - name: severity
## matchType: "="
## value: "high"
## targetMatch:
## - name: severity
## matchType: "="
## value: "warning"
## - name: severity
## matchType: "="
## value: "info"
inhibitRules: []

## @param mutiTimeIntervals List of MuteTimeInterval specifying when the routes should be muted.
## Prometheus Ref: https://prometheus.io/docs/alerting/latest/configuration/#time_interval
## Crd Doc Ref: https://doc.crds.dev/github.com/prometheus-operator/kube-prometheus/monitoring.coreos.com/AlertmanagerConfig/v1alpha1@v0.13.0
## Example:
## - name: holidays
## timeIntervals:
## - daysOfMonth:
## - start: 1
## end: 31
## months:
## - january
## - "may:august"
## - "12" # "1" "2" is permit, "3" is invalid value, regex pattern "december|[1-12]", it's have a bug.
## years:
## - "2020:2022"
## - "2023"
## weekdays:
## - "monday:friday"
## - "wednesday"
## times:
## - startTime: "09:00"
## endTime: "17:00"
muteTimeIntervals: []

## @param receivers List of receivers.
## Ref: https://doc.crds.dev/github.com/prometheus-operator/kube-prometheus/monitoring.coreos.com/AlertmanagerConfig/v1alpha1@v0.13.0#spec-receivers
## Example:
## - name: example-prometheusAlert
## webhookConfigs:
## - url: "http://prometheusalert.monitoring.svc.cluster.local:8080/prometheusalert?type=fs&tpl=prometheus-fs&alertgroup=demo"
## urlSecret:
## name: example-urlSecret
## key: url
## optional: false
## sendResolved: true
## httpConfig:
## followRedirects: true
## basicAuth:
## username:
## key: username
## name: example-auth-secret
## optional: true
## password:
## key: passwd
## name: example-auth-secret
## optional: true
receivers: []

## @param routes The Alertmanager route definition for alerts matching the resource’s namespace. It will be added to the generated Alertmanager configuration as a first-level route.
## Ref: https://doc.crds.dev/github.com/prometheus-operator/kube-prometheus/monitoring.coreos.com/AlertmanagerConfig/v1alpha1@v0.13.0#spec-route
## Example:
## groupBy:
## - namespace
## - alertname
## matchers:
## - name: label-name
## value: label-value
## groupWait: 30s
## groupInterval: 5m
## repeatInterval: 8h
## receiver: example-prometheusAlert
## routes:
## - receiver: example-prometheusAlert
## match:
## severity: warning
## activeTimeIntervals:
## - holidays
## muteTimeIntervals:
## - holidays
route: []

config:
app_conf: |
Expand Down

0 comments on commit 7349402

Please sign in to comment.