diff --git a/prometheus/templates/configmap-etc.yaml b/prometheus/templates/configmap-etc.yaml index 57d9a0caf..0f203faea 100644 --- a/prometheus/templates/configmap-etc.yaml +++ b/prometheus/templates/configmap-etc.yaml @@ -16,6 +16,18 @@ limitations under the License. {{- if .Values.manifests.configmap_etc }} {{- $envAll := . }} + +{{- if empty $envAll.Values.conf.prometheus.scrape_configs.rule_files -}} +{{- $_ := set $envAll.Values "__rule_files" ( list ) }} +{{- $rulesKeys := keys $envAll.Values.conf.prometheus.rules -}} +{{- range $rule := $rulesKeys }} +{{- $rulesFile := printf "/etc/config/rules/%s.rules" $rule }} +{{- $__rule_files := append $envAll.Values.__rule_files $rulesFile }} +{{- $_ := set $envAll.Values "__rule_files" $__rule_files }} +{{ end }} +{{- set .Values.conf.prometheus.scrape_configs "rule_files" $envAll.Values.__rule_files | quote | trunc 0 -}} +{{- end -}} + --- apiVersion: v1 kind: ConfigMap diff --git a/prometheus/values.yaml b/prometheus/values.yaml index 10fffb584..14e41f894 100644 --- a/prometheus/values.yaml +++ b/prometheus/values.yaml @@ -200,13 +200,6 @@ conf: global: scrape_interval: 60s evaluation_interval: 60s - rule_files: - - /etc/config/rules/alertmanager.rules - - /etc/config/rules/etcd3.rules - - /etc/config/rules/kubernetes.rules - - /etc/config/rules/kube_apiserver.rules - - /etc/config/rules/kube_controller_manager.rules - - /etc/config/rules/kubelet.rules scrape_configs: - job_name: kubelet scheme: https