Format of prometheusRules in values.yaml for kube-prometheus helm charts

665 views
Skip to first unread message

IBMRob

unread,
Feb 6, 2018, 10:29:51 AM2/6/18
to CoreOS Dev
I am trying to configure my own rules when using the kube-prometheus helm charts. Looking at the charts, our understanding is that if "prometheusRules" is not defined in the override values.yaml then the default rules for that helm chart will be used which in this case means reading in the general.rules.yaml into the ConfigMap.

If we update the chart to support an empty value for prometheusRules we presumed this would result in a ConfigMap with no rules inside it but this does not happen. i.e.:

Code in values.yaml

prometheusRules: {}

Code in configmap.yaml

data:
{{- if .Values.prometheusRules }}
{{- $root := . }}
{{- range $key, $val := .Values.prometheusRules }}
{{ $key }}: |-
{{ $val | indent 4}}
{{- end }}
{{ else }}
general.rules: |-
{{- include "general.rules.yaml.tpl" . | indent 4}}
{{ end }}


This still pulls in the default general.rules.yaml. We are trying to work out what format we should be using for the prometheusRules so that we can supply multiple rule such as 

- alert: FdExhaustionClose
expr: predict_linear(fd_utilization[1h], 3600 * 4) > 1
for: 10m
labels:
severity: warning
annotations:
description: '{{`{{ $labels.job }}`}}: {{`{{ $labels.namespace }}`}}/{{`{{ $labels.pod }}`}} instance
will exhaust in file/socket descriptors within the next 4 hours'
summary: file descriptors soon exhausted
- alert: FdExhaustionClose
expr: predict_linear(fd_utilization[10m], 3600) > 1
for: 10m
labels:
severity: critical
annotations:
description: '{{`{{ $labels.job }}`}}: {{`{{ $labels.namespace }}`}}/{{`{{ $labels.pod }}`}} instance
will exhaust in file/socket descriptors within the next hour'
summary: file descriptors soon exhausted

 (I realise these are rules that are already there but one we get the format we can make the rules what ever we need.)

Anyone able to help us with this?


IBMRob

unread,
Feb 7, 2018, 3:48:52 AM2/7/18
to CoreOS Dev
For reference for anyone else hitting this. To produce an empty but value config file for a specific chart use

exporter-node:
prometheusRules:
exporter-node.rules: |-
groups:
- name: exporter-node.rules
rules: 

The format to put in custom rules into the yaml is as follows:

# default rules are in templates/general.rules.yaml
prometheusRules:
general.rules: |-
groups:
- name: general.rules
rules:
- record: fd_utilization
expr: process_open_fds / process_max_fds
- alert: FdExhaustionClose
expr: predict_linear(fd_utilization[1h], 3600 * 4) > 1
for: 10m
labels:
severity: warning
where: "<location>"
annotations:
description: '{{ $labels.job }}: {{ $labels.namespace }}/{{ $labels.pod }} instance
will exhaust in file/socket descriptors within the next 4 hours' - Playbook appconn#100
Reply all
Reply to author
Forward
0 new messages