Skip to content

Commit

Permalink
Chart: Add Prometheus rules. (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gacko committed Feb 28, 2023
1 parent d16e0f4 commit ea76533
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s
- ConfigMap: Implement `tcp` and `udp`.
- ConfigMap: Implement `controller.config`.
- Chart: Add KEDA resources. ([#413](https://github.com/giantswarm/nginx-ingress-controller-app/pull/413))
- Chart: Add Prometheus rules. ([#414](https://github.com/giantswarm/nginx-ingress-controller-app/pull/414))

### Changed

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if and ( .Values.controller.metrics.enabled ) ( .Values.controller.metrics.prometheusRule.enabled ) ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) -}}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "ingress-nginx.controller.fullname" . }}
{{- if .Values.controller.metrics.prometheusRule.namespace }}
namespace: {{ .Values.controller.metrics.prometheusRule.namespace | quote }}
{{- end }}
labels:
{{- include "ingress-nginx.labels" . | nindent 4 }}
app.kubernetes.io/component: controller
{{- if .Values.controller.metrics.prometheusRule.additionalLabels }}
{{- toYaml .Values.controller.metrics.prometheusRule.additionalLabels | nindent 4 }}
{{- end }}
spec:
{{- if .Values.controller.metrics.prometheusRule.rules }}
groups:
- name: {{ template "ingress-nginx.name" . }}
rules: {{- toYaml .Values.controller.metrics.prometheusRule.rules | nindent 4 }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions helm/nginx-ingress-controller-app/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,23 @@
"portName": {
"type": "string"
},
"prometheusRule": {
"type": "object",
"properties": {
"additionalLabels": {
"type": "object"
},
"enabled": {
"type": "boolean"
},
"namespace": {
"type": "string"
},
"rules": {
"type": "array"
}
}
},
"service": {
"type": "object",
"properties": {
Expand Down
39 changes: 39 additions & 0 deletions helm/nginx-ingress-controller-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,45 @@ controller:
# externalTrafficPolicy: ""
# nodePort: ""

prometheusRule:
enabled: false
additionalLabels: {}
# namespace: ""
rules: []
# # These are just examples rules, please adapt them to your needs
# - alert: NGINXConfigFailed
# expr: count(nginx_ingress_controller_config_last_reload_successful == 0) > 0
# for: 1s
# labels:
# severity: critical
# annotations:
# description: bad ingress config - nginx config test failed
# summary: uninstall the latest ingress changes to allow config reloads to resume
# - alert: NGINXCertificateExpiry
# expr: (avg(nginx_ingress_controller_ssl_expire_time_seconds) by (host) - time()) < 604800
# for: 1s
# labels:
# severity: critical
# annotations:
# description: ssl certificate(s) will expire in less then a week
# summary: renew expiring certificates to avoid downtime
# - alert: NGINXTooMany500s
# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5
# for: 1m
# labels:
# severity: warning
# annotations:
# description: Too many 5XXs
# summary: More than 5% of all requests returned 5XX, this requires your attention
# - alert: NGINXTooMany400s
# expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5
# for: 1m
# labels:
# severity: warning
# annotations:
# description: Too many 4XXs
# summary: More than 5% of all requests returned 4XX, this requires your attention

# controller.resources
resources:

Expand Down

0 comments on commit ea76533

Please sign in to comment.