[stable/nginx-ingress] Add prometheus rule (#16370)

* Added prometheusRules support

- Bump Charts.yaml
- Added prometheusRules resource template
- Added new variables in README
- Added new variables default values in values.yaml

Signed-off-by: Alejandro Garrido Mota <garridomota@gmail.com>

* Removed trailing space in order to pass helm lint, my local helm
lint didn't detect it :-(

Signed-off-by: Alejandro Garrido Mota <garridomota@gmail.com>

* Bump it to 1.16.0 because is a new feature

Signed-off-by: Alejandro Garrido Mota <garridomota@gmail.com>
This commit is contained in:
Alejandro Garrido Mota
2019-08-16 09:30:11 -07:00
committed by Kubernetes Prow Robot
parent 12754f06ce
commit 0303c6ca1a
4 changed files with 53 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
apiVersion: v1
name: nginx-ingress
version: 1.15.1
version: 1.16.0
appVersion: 0.25.1
home: https://github.com/kubernetes/ingress-nginx
description: An nginx Ingress controller that uses ConfigMap to store the nginx configuration.
+4
View File
@@ -138,6 +138,10 @@ Parameter | Description | Default
`controller.metrics.serviceMonitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | `{}`
`controller.metrics.serviceMonitor.namespace` | namespace where servicemonitor resource should be created | `the same namespace as nginx ingress`
`controller.metrics.serviceMonitor.honorLabels` | honorLabels chooses the metric's labels on collisions with target labels. | `false`
`controller.metrics.prometheusRule.enabled` | Set this to `true` to create prometheusRules for Prometheus operator | `false`
`controller.metrics.prometheusRule.additionalLabels` | Additional labels that can be used so prometheusRules will be discovered by Prometheus | `{}`
`controller.metrics.prometheusRule.namespace` | namespace where prometheusRules resource should be created | `the same namespace as nginx ingress`
`controller.metrics.prometheusRule.rules` | [rules](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/) to be prometheus in YAML format, check values for an example. | `[]`
`controller.customTemplate.configMapName` | configMap containing a custom nginx template | `""`
`controller.customTemplate.configMapKey` | configMap key containing the nginx template | `""`
`controller.addHeaders` | configMap key:value pairs containing [custom headers](https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#add-headers) added before sending response to the client | `{}`
@@ -0,0 +1,24 @@
{{- if and .Values.controller.metrics.enabled .Values.controller.metrics.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "nginx-ingress.controller.fullname" . }}
{{- if .Values.controller.metrics.prometheusRule.namespace }}
namespace: {{ .Values.controller.metrics.prometheusRule.namespace }}
{{- end }}
labels:
app: {{ template "nginx-ingress.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
component: "{{ .Values.controller.name }}"
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.controller.metrics.prometheusRule.additionalLabels }}
{{ toYaml .Values.controller.metrics.prometheusRule.additionalLabels | indent 4 }}
{{- end }}
spec:
{{- with .Values.controller.metrics.prometheusRule.rules }}
groups:
- name: {{ template "nginx-ingress.name" $ }}
rules: {{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
+24
View File
@@ -334,6 +334,30 @@ controller:
namespace: ""
# honorLabels: true
prometheusRule:
enabled: false
additionalLabels: {}
namespace: ""
rules: []
# # These are just examples rules, please adapt them to your needs
# - alert: TooMany500s
# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5
# for: 1m
# labels:
# severity: critical
# annotations:
# description: Too many 5XXs
# summary: More than 5% of the all requests did return 5XX, this require your attention
# - alert: TooMany400s
# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5
# for: 1m
# labels:
# severity: critical
# annotations:
# description: Too many 4XXs
# summary: More than 5% of the all requests did return 4XX, this require your attention
lifecycle: {}
priorityClassName: ""