diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 12800fd3..1c02f023 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: sql-exporter description: Database-agnostic SQL exporter for Prometheus type: application -version: 0.10.2 +version: 0.11.0 appVersion: 0.17.0 keywords: - exporter diff --git a/helm/README.md b/helm/README.md index 7fdd9261..1be09c8b 100644 --- a/helm/README.md +++ b/helm/README.md @@ -1,6 +1,8 @@ # sql-exporter -![Version: 0.10.2](https://img.shields.io/badge/Version-0.10.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.17.0](https://img.shields.io/badge/AppVersion-0.17.0-informational?style=flat-square) + + +![Version: 0.11.0](https://img.shields.io/badge/Version-0.11.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.17.0](https://img.shields.io/badge/AppVersion-0.17.0-informational?style=flat-square) Database-agnostic SQL exporter for Prometheus @@ -14,6 +16,9 @@ Database-agnostic SQL exporter for Prometheus | ---- | ------ | --- | | Nikolai Rodionov | | | + + + ## Installing the Chart To install the chart with the release name `sql-exporter`: @@ -86,6 +91,7 @@ as an example. | logFormat | string | `"logfmt"` | Set log format (logfmt if unset) | | reloadEnabled | bool | `false` | Enable reload collector data handler (endpoint /reload) | + ### Prometheus ServiceMonitor | Key | Type | Default | Description | @@ -101,6 +107,7 @@ as an example. | Key | Type | Default | Description | |-----|------|---------|-------------| +| config | object | `{"global":{"max_connections":3,"max_idle_connections":3,"min_interval":"0s","scrape_error_drop_interval":"0s","scrape_timeout":"10s","scrape_timeout_offset":"500ms"}}` | SQL Exporter configuration, can be a dictionary, or a template yaml string. | | config.global.scrape_timeout | string | `"10s"` | Scrape timeout | | config.global.scrape_timeout_offset | string | `"500ms"` | Scrape timeout offset. Must be strictly positive. | | config.global.scrape_error_drop_interval | string | `"0s"` | Interval between dropping scrape_errors_total metric: by default the metric is persistent. | diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index cda797f2..5596a167 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -1,7 +1,8 @@ +{{- $conf := include "sql_exporter.config.yaml" . | fromYaml -}} ------------------------------ Hello there! -{{- if and (not .Values.config.target ) (not .Values.config.jobs)}} +{{- if and (not $conf.target ) (not $conf.jobs)}} ------------------------------ It seems like you haven't configured the target, please check the example here: @@ -14,7 +15,7 @@ In case you need to have multiple targets, you can confiure jobs instead, have a {{- end}} -{{- if and (not .Values.config.collectors) (not .Values.config.collectorFiles)}} +{{- if and (not $conf.collectors) (not $conf.collectorFiles)}} ------------------------------ You need to configure either collectors or collectorFiles (or both), please have a look at the example here: diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 6744e028..46543999 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -77,3 +77,17 @@ Create the name of the service account to use {{- false | quote -}} {{- end -}} {{- end -}} + +{{- define "sql_exporter.config.yaml" -}} +{{- $conf := "" -}} +{{- if typeIsLike "string" .Values.config -}} +{{- $conf = (tpl .Values.config .) | fromYaml -}} +{{- else -}} +{{- $conf = .Values.config -}} +{{- end -}} +{{- /* +Do the wired "fromYaml | toYaml" to reformat the config. +Reformat '100s' to 100s for example. +*/ -}} +{{- tpl ($conf | toYaml ) . | fromYaml | toYaml -}} +{{- end -}} diff --git a/helm/templates/configmap.collectors.yaml b/helm/templates/configmap.collectors.yaml index 30cff052..dedeb155 100644 --- a/helm/templates/configmap.collectors.yaml +++ b/helm/templates/configmap.collectors.yaml @@ -8,6 +8,13 @@ metadata: data: {{- range $k, $v := .Values.collectorFiles }} {{ $k }}: |- - {{- toYaml $v | nindent 4}} + {{- if typeIsLike "string" $v -}} + {{- $v = (tpl $v $ | fromYaml) -}} + {{- end -}} + {{- /* + Do the wired "fromYaml | toYaml" to reformat the config. + Reformat '100s' to 100s for example. + */ -}} + {{- tpl (toYaml $v) $ | fromYaml | toYaml | nindent 4}} {{- end}} {{- end }} diff --git a/helm/templates/secret.configuration.yaml b/helm/templates/secret.configuration.yaml index 8501957c..33366421 100644 --- a/helm/templates/secret.configuration.yaml +++ b/helm/templates/secret.configuration.yaml @@ -11,5 +11,5 @@ metadata: type: Opaque stringData: sql_exporter.yml: |- - {{- toYaml .Values.config | nindent 4 }} + {{- include "sql_exporter.config.yaml" . | nindent 4 }} {{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index 274437c4..f65b6b78 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -147,6 +147,7 @@ logLevel: debug logFormat: logfmt # -- Enable reload collector data handler (endpoint /reload) reloadEnabled: false +# -- SQL Exporter configuration, can be a dictionary, or a template yaml string. config: global: # -- Scrape timeout @@ -192,6 +193,7 @@ config: # - "*.collector.yml" # --------------------------------------------------------------------- # -- Collector Files +# (can be dictionaries or yaml string templates) # --------------------------------------------------------------------- # -- Collector files are mounted to /etc/sql_exporter/collectors dir # ---------------------------------------------------------------------