Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: sql-exporter
description: Database agnostic SQL exporter for Prometheus
type: application
version: 0.2.5
version: 0.3.0
appVersion: 0.13.1
keywords:
- exporter
Expand Down
5 changes: 4 additions & 1 deletion helm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sql-exporter

![Version: 0.2.5](https://img.shields.io/badge/Version-0.2.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.13.1](https://img.shields.io/badge/AppVersion-0.13.1-informational?style=flat-square)
![Version: 0.3.0](https://img.shields.io/badge/Version-0.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.13.1](https://img.shields.io/badge/AppVersion-0.13.1-informational?style=flat-square)

Database agnostic SQL exporter for Prometheus

Expand Down Expand Up @@ -43,6 +43,7 @@ helm install sql_exporter/sql-exporter
| podLabels | object | `{}` | Pod labels |
| podAnnotations | object | `{}` | Pod annotations |
| podSecurityContext | object | `{}` | Pod security context |
| createConfig | bool | `true` | |

### Prometheus ServiceMonitor

Expand All @@ -66,6 +67,8 @@ helm install sql_exporter/sql-exporter
| jobs | list | `nil` | Check documentation. Mutually exclusive with `target` |
| collector_files | list | `[]` | Check documentation |

To generate the config as a part of a helm release, please set the `.Values.createConfig` to true, and define a config under the `.Values.config` property.

To configure `target`, `jobs`, `collector_files` please refer to the [documentation](https://github.com/burningalchemist/sql_exporter/blob/master/documentation/sql_exporter.yml) in the source repository. These values are not set by default.

It's also possible to define collectors (i.e. metrics and queries) in separate files, and specify the filenames in the `collector_files` list. For that we can use `CollectorFiles` field (check `values.yaml` for the available example).
Expand Down
2 changes: 2 additions & 0 deletions helm/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ helm install sql_exporter/sql-exporter
| jobs | list | `nil` | Check documentation. Mutually exclusive with `target` |
| collector_files | list | `[]` | Check documentation |

To generate the config as a part of a helm release, please set the `.Values.createConfig` to true, and define a config under the `.Values.config` property.

To configure `target`, `jobs`, `collector_files` please refer to the [documentation](https://github.com/burningalchemist/sql_exporter/blob/master/documentation/sql_exporter.yml) in the source repository. These values are not set by default.

It's also possible to define collectors (i.e. metrics and queries) in separate files, and specify the filenames in the `collector_files` list. For that we can use `CollectorFiles` field (check `values.yaml` for the available example).
Expand Down
10 changes: 10 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,13 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "sql-exporter.volumes" -}}
{{- if or .Values.createConfig .Values.collectorFiles -}}
{{- true | quote -}}
{{- else if .Values.extraVolumes -}}
{{- true | quote -}}
{{- else -}}
{{- false | quote -}}
{{- end -}}
{{- end -}}
20 changes: 20 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,51 @@ spec:
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if eq (include "sql-exporter.volumes" .) "\"true\"" }}
volumes:
{{- if .Values.createConfig }}
- name: sql-exporter
secret:
secretName: {{ include "sql-exporter.fullname" . }}
{{- end }}
{{- if .Values.collectorFiles }}
- name: sql-collector
configMap:
name: {{ include "sql-exporter.fullname" . }}
{{- end }}
{{- end }}
{{- range $v := .Values.extraVolumes }}
- name: {{ $v.name }}
{{- toYaml $v.volume | nindent 10 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: ["-config.file=/etc/sql_exporter/sql_exporter.yml"]
{{- if eq (include "sql-exporter.volumes" .) "\"true\"" }}
volumeMounts:
{{- if .Values.createConfig }}
- name: sql-exporter
readOnly: true
mountPath: /etc/sql_exporter/
{{- end }}
{{- if .Values.collectorFiles }}
- name: sql-collector
readOnly: true
mountPath: /etc/sql_exporter/collectors/
{{- end }}
{{- range $v := .Values.extraVolumes }}
- name: {{ $v.name }}
{{- toYaml $v.mount | nindent 14 }}
{{- end }}
{{- end }}
{{- with .Values.envFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.env }}
env:
{{- range $key, $value := .Values.env }}
Expand Down
2 changes: 2 additions & 0 deletions helm/templates/secret.configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ---------------------------------------------------------------------
# -- This secret holds the config file of sql_exporter
# ---------------------------------------------------------------------
{{- if .Values.createConfig }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -11,3 +12,4 @@ type: Opaque
stringData:
sql_exporter.yml: |-
{{- toYaml .Values.config | nindent 4 }}
{{- end }}
19 changes: 18 additions & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ serviceMonitor:
# kind: Secret
# name: sql_exporter_secret
# key: CONNECTION_STRING
# envFrom:
# - configMapRef:
# name: env-configmap
# - secretRef:
# name: env-secrets
# extraVolumes:
# - name: configmap-mount
# volume:
# configMap:
# name: log-config
# items:
# - key: log_level
# path: log_level
# mount:
# readOnly: true
# mountPath: /etc/config
# Set to true to create a config as a part of the helm chart
createConfig: true
config:
global:
# -- Scrape timeout
Expand Down Expand Up @@ -118,7 +136,6 @@ config:
# GROUP BY datname, usename, state;
# collector_files:
# - "*.collector.yml"

# ---------------------------------------------------------------------
# -- Collector Files
# ---------------------------------------------------------------------
Expand Down