Skip to content

Commit

Permalink
[stable/prometheus-operator] Add custom PrometheusRules (helm#11266)
Browse files Browse the repository at this point in the history
This commit allows the specification of custom PrometheusRule
resources via alertmanager.additionalPrometheusRules.

To assist the implementation, the ServiceMonitor manifest has also been
updated to remove the v1 List type, which was subsequently clobbered.

Signed-off-by: Ash Caire <[email protected]>
  • Loading branch information
acaire authored and k8s-ci-robot committed Feb 18, 2019
1 parent dab07b1 commit 7de3fa9
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
2 changes: 1 addition & 1 deletion stable/prometheus-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: prometheus-operator
sources:
- https://github.com/coreos/prometheus-operator
- https://coreos.com/operators/prometheus
version: 2.2.3
version: 2.2.4
appVersion: 0.26.0
home: https://github.com/coreos/prometheus-operator
keywords:
Expand Down
1 change: 1 addition & 0 deletions stable/prometheus-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ The following tables lists the configurable parameters of the prometheus-operato
| `alertmanager.service.externalIPs` | List of IP addresses at which the Alertmanager server service is available | `[]` |
| `alertmanager.service.loadBalancerIP` | Alertmanager Loadbalancer IP | `""` |
| `alertmanager.service.loadBalancerSourceRanges` | Alertmanager Load Balancer Source Ranges | `[]` |
| `alertmanager.additionalPrometheusRules` | List of `prometheusRule` objects to create. See https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusrulespec | `[]` |
| `alertmanager.config` | Provide YAML to configure Alertmanager. See https://prometheus.io/docs/alerting/configuration/#configuration-file. The default provided works to suppress the DeadMansSwitch alert from `defaultRules.create` | `{"global":{"resolve_timeout":"5m"},"route":{"group_by":["job"],"group_wait":"30s","group_interval":"5m","repeat_interval":"12h","receiver":"null","routes":[{"match":{"alertname":"DeadMansSwitch"},"receiver":"null"}]},"receivers":[{"name":"null"}]}` |
| `alertmanager.alertmanagerSpec.podMetadata` | Standard object’s metadata. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata Metadata Labels and Annotations gets propagated to the prometheus pods. | `{}` |
| `alertmanager.alertmanagerSpec.image.tag` | Tag of Alertmanager container image to be deployed. | `v0.15.3` |
Expand Down
8 changes: 8 additions & 0 deletions stable/prometheus-operator/ci/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ alertmanager:
##
additionalPeers: []

additionalPrometheusRules: []
# - name: my_rule_file
# groups:
# - name: my_group
# rules:
# - record: my_record
# expr: 100 * my_record

## Using default values from https://github.com/helm/charts/blob/master/stable/grafana/values.yaml
##
grafana:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if and .Values.alertmanager.enabled .Values.alertmanager.additionalPrometheusRules }}
{{- range .Values.alertmanager.additionalPrometheusRules }}
apiVersion: {{ printf "%s/v1" ($.Values.prometheusOperator.crdApiGroup | default "monitoring.coreos.com") }}
kind: PrometheusRule
metadata:
name: {{ template "prometheus-operator.name" $ }}-{{ .name }}
labels:
app: {{ template "prometheus-operator.name" $ }}
{{ include "prometheus-operator.labels" $ | indent 4 }}
{{- if .additionalLabels }}
{{ toYaml .additionalLabels | indent 4 }}
{{- end }}
spec:
groups:
{{ toYaml .groups| indent 4 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
{{- if and .Values.prometheus.enabled .Values.prometheus.additionalServiceMonitors }}
apiVersion: v1
kind: List
items:
{{- range .Values.prometheus.additionalServiceMonitors }}
- apiVersion: {{ printf "%s/v1" ($.Values.prometheusOperator.crdApiGroup | default "monitoring.coreos.com") }}
kind: ServiceMonitor
metadata:
name: {{ .name }}
labels:
app: {{ template "prometheus-operator.name" $ }}-prometheus
{{ include "prometheus-operator.labels" $ | indent 8 }}
{{- if .additionalLabels }}
{{ toYaml .additionalLabels | indent 8 }}
{{- end }}
spec:
endpoints:
{{ toYaml .endpoints | indent 8 }}
{{- if .jobLabel }}
jobLabel: {{ .jobLabel }}
apiVersion: {{ printf "%s/v1" ($.Values.prometheusOperator.crdApiGroup | default "monitoring.coreos.com") }}
kind: ServiceMonitor
metadata:
name: {{ template "prometheus-operator.name" $ }}-{{ .name }}
labels:
app: {{ template "prometheus-operator.name" $ }}-prometheus
{{ include "prometheus-operator.labels" $ | indent 4 }}
{{- if .additionalLabels }}
{{ toYaml .additionalLabels | indent 4 }}
{{- end }}
{{- if .namespaceSelector }}
namespaceSelector:
{{ toYaml .namespaceSelector | indent 8 }}
{{- end }}
selector:
{{ toYaml .selector | indent 8 }}
spec:
endpoints:
{{ toYaml .endpoints | indent 4 }}
{{- if .jobLabel }}
jobLabel: {{ .jobLabel }}
{{- end }}
{{- if .namespaceSelector }}
namespaceSelector:
{{ toYaml .namespaceSelector | indent 4 }}
{{- end }}
selector:
{{ toYaml .selector | indent 4 }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions stable/prometheus-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ alertmanager:
##
additionalPeers: []

additionalPrometheusRules: []
# - name: my_rule_file
# groups:
# - name: my_group
# rules:
# - record: my_record
# expr: 100 * my_record

## Using default values from https://github.com/helm/charts/blob/master/stable/grafana/values.yaml
##
grafana:
Expand Down

0 comments on commit 7de3fa9

Please sign in to comment.