You've already forked prometheus-postgres-exporter
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
7ea826a2a1
|
|||
aa8c279fe0
|
|||
dfd4c1f991
|
|||
d6c2e4f992
|
|||
ae7652a335
|
|||
16cfa36fda
|
|||
94fbc5e38f
|
|||
dcc7bae921
|
|||
503c622df5
|
63
README.md
63
README.md
@ -2,19 +2,19 @@
|
||||
|
||||
[](https://drone.cryptic.systems/volker.raschek/prometheus-postgres-exporter)
|
||||
|
||||
> [!NOTE]
|
||||
> This is not the official *community* helm chart of the Prometheus metric exporter for PostgreSQL databases. You can
|
||||
> find the official community chart [here](https://github.com/prometheus-community/helm-charts).
|
||||
|
||||
This helm chart enables the deployment of a Prometheus metrics exporter for PostgreSQL databases and allows the
|
||||
individual configuration of additional containers/initContainers, mounting of volumes, defining additional environment
|
||||
variables, apply a user-defined web-config.yaml and much more.
|
||||
variables, apply a user-defined `webConfig.yaml` and much more.
|
||||
|
||||
Chapter [configuration and installation](#helm-configuration-and-installation) describes the basics how to configure helm
|
||||
and use it to deploy the exporter. It also contains further configuration examples.
|
||||
|
||||
Furthermore, this helm chart unit tests to detect regressions and stabilize the deployment. Additionally, this helm
|
||||
chart is tested for deployment scenarios with ArgoCD.
|
||||
|
||||
> [!NOTE]
|
||||
> This is not the official *community* helm chart of the Prometheus metric exporter for PostgreSQL databases. You can
|
||||
> find the official community chart [here](https://github.com/prometheus-community/helm-charts).
|
||||
Furthermore, this helm chart contains unit tests to detect regressions and stabilize the deployment. Additionally, this
|
||||
helm chart is tested for deployment scenarios with **ArgoCD**.
|
||||
|
||||
## Helm: configuration and installation
|
||||
|
||||
@ -31,7 +31,7 @@ chart is tested for deployment scenarios with ArgoCD.
|
||||
```bash
|
||||
helm repo add prometheus-exporters https://charts.cryptic.systems/prometheus-exporters
|
||||
helm repo update
|
||||
helm install prometheus-exporters/prometheus-postgres-exporter prometheus-postgres-exporter \
|
||||
helm install prometheus-postgres-exporter prometheus-exporters/prometheus-postgres-exporter \
|
||||
--set 'config.database.secret.databaseUsername=postgres' \
|
||||
--set 'config.database.secret.databasePassword=postgres' \
|
||||
--set 'config.database.secret.databaseConnectionUrl="postgres.example.local:5432/postgres?ssl=disable"' \
|
||||
@ -71,7 +71,7 @@ certification will be skipped by Prometheus.
|
||||
> `tls.key` and `tls.crt` of the secret can be mounted into the container filesystem for TLS authentication / encryption.
|
||||
|
||||
```bash
|
||||
helm install prometheus-exporters/prometheus-postgres-exporter prometheus-postgres-exporter \
|
||||
helm install prometheus-postgres-exporter prometheus-exporters/prometheus-postgres-exporter \
|
||||
--set 'config.database.secret.databaseUsername=postgres' \
|
||||
--set 'config.database.secret.databasePassword=postgres' \
|
||||
--set 'config.database.secret.databaseConnectionUrl="postgres.example.local:5432/postgres?ssl=disable"' \
|
||||
@ -94,7 +94,7 @@ certificate for the metrics exporter - TLS certificate verification can be enabl
|
||||
replaced:
|
||||
|
||||
```diff
|
||||
helm install prometheus-exporters/prometheus-postgres-exporter prometheus-postgres-exporter \
|
||||
helm install prometheus-postgres-exporter prometheus-exporters/prometheus-postgres-exporter \
|
||||
--set 'config.database.secret.databaseUsername=postgres' \
|
||||
--set 'config.database.secret.databasePassword=postgres' \
|
||||
--set 'config.database.secret.databaseConnectionUrl="postgres.example.local:5432/postgres?ssl=disable"' \
|
||||
@ -126,25 +126,25 @@ replaced:
|
||||
|
||||
### Configuration
|
||||
|
||||
| Name | Description | Value |
|
||||
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
||||
| `config.database.existingSecret.enabled` | Mount an existing secret containing the application specific `DATA_SOURCE_` prefixed environment variables. | `false` |
|
||||
| `config.database.existingSecret.secretName` | Name of the existing secret containing the application specific `DATA_SOURCE_` prefixed environment variables. | `""` |
|
||||
| `config.database.secret.annotations` | Additional annotations of the secret containing the database credentials. | `{}` |
|
||||
| `config.database.secret.labels` | Additional labels of the secret containing the database credentials. | `{}` |
|
||||
| `config.database.secret.databaseUsername` | Database username. Will be defined as env `DATA_SOURCE_USER` as part of a secret. | `""` |
|
||||
| `config.database.secret.databasePassword` | Database password. Will be defined as env `DATA_SOURCE_PASS` as part of a secret. | `""` |
|
||||
| `config.database.secret.databaseConnectionUrl` | Complex database connection URL. Will be defined as env `DATA_SOURCE_URI` as part of a secret. | `""` |
|
||||
| `config.exporterConfig.existingSecret.enabled` | Mount an existing secret containing the key `exporterConfig.yaml`. | `false` |
|
||||
| `config.exporterConfig.existingSecret.secretName` | Name of the existing secret containing the key `exporterConfig.yaml`. | `""` |
|
||||
| `config.exporterConfig.secret.annotations` | Additional annotations of the secret containing the `exporterConfig.yaml`. | `{}` |
|
||||
| `config.exporterConfig.secret.labels` | Additional labels of the secret containing the `exporterConfig.yaml`. | `{}` |
|
||||
| `config.exporterConfig.secret.exporterConfig` | Content of the `exporterConfig.yaml`. Further information can be found [here](https://prometheus.io/docs/prometheus/latest/configuration/https/). | `{}` |
|
||||
| `config.webConfig.existingSecret.enabled` | Mount an existing secret containing the key `webConfig.yaml`. | `false` |
|
||||
| `config.webConfig.existingSecret.secretName` | Name of the existing secret containing the key `webConfig.yaml`. | `""` |
|
||||
| `config.webConfig.secret.annotations` | Additional annotations of the secret containing the `webConfig.yaml`. | `{}` |
|
||||
| `config.webConfig.secret.labels` | Additional labels of the secret containing the `webConfig.yaml`. | `{}` |
|
||||
| `config.webConfig.secret.webConfig` | Content of the `webConfig.yaml`. Further information can be found [here](https://prometheus.io/docs/prometheus/latest/configuration/https/). | `{}` |
|
||||
| Name | Description | Value |
|
||||
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
||||
| `config.database.existingSecret.enabled` | Mount an existing secret containing the application specific `DATA_SOURCE_` prefixed environment variables. | `false` |
|
||||
| `config.database.existingSecret.secretName` | Name of the existing secret containing the application specific `DATA_SOURCE_` prefixed environment variables. | `""` |
|
||||
| `config.database.secret.annotations` | Additional annotations of the secret containing the database credentials. | `{}` |
|
||||
| `config.database.secret.labels` | Additional labels of the secret containing the database credentials. | `{}` |
|
||||
| `config.database.secret.databaseUsername` | Database username. Will be defined as env `DATA_SOURCE_USER` as part of a secret. | `""` |
|
||||
| `config.database.secret.databasePassword` | Database password. Will be defined as env `DATA_SOURCE_PASS` as part of a secret. | `""` |
|
||||
| `config.database.secret.databaseConnectionUrl` | Complex database connection URL. Will be defined as env `DATA_SOURCE_URI` as part of a secret. | `""` |
|
||||
| `config.exporterConfig.existingSecret.enabled` | Mount an existing secret containing the key `exporterConfig.yaml`. | `false` |
|
||||
| `config.exporterConfig.existingSecret.secretName` | Name of the existing secret containing the key `exporterConfig.yaml`. | `""` |
|
||||
| `config.exporterConfig.secret.annotations` | Additional annotations of the secret containing the `exporterConfig.yaml`. | `{}` |
|
||||
| `config.exporterConfig.secret.labels` | Additional labels of the secret containing the `exporterConfig.yaml`. | `{}` |
|
||||
| `config.exporterConfig.secret.exporterConfig` | Content of the `exporterConfig.yaml`. Further information can be found [here](https://github.com/prometheus-community/postgres_exporter?tab=readme-ov-file#multi-target-support-beta). | `{}` |
|
||||
| `config.webConfig.existingSecret.enabled` | Mount an existing secret containing the key `webConfig.yaml`. | `false` |
|
||||
| `config.webConfig.existingSecret.secretName` | Name of the existing secret containing the key `webConfig.yaml`. | `""` |
|
||||
| `config.webConfig.secret.annotations` | Additional annotations of the secret containing the `webConfig.yaml`. | `{}` |
|
||||
| `config.webConfig.secret.labels` | Additional labels of the secret containing the `webConfig.yaml`. | `{}` |
|
||||
| `config.webConfig.secret.webConfig` | Content of the `webConfig.yaml`. Further information can be found [here](https://prometheus.io/docs/prometheus/latest/configuration/https/). | `{}` |
|
||||
|
||||
### Deployment
|
||||
|
||||
@ -221,7 +221,7 @@ replaced:
|
||||
| `prometheus.metrics.enabled` | Enable of scraping metrics by Prometheus. | `true` |
|
||||
| `prometheus.metrics.podMonitor.enabled` | Enable creation of a podMonitor. Excludes the existence of a serviceMonitor resource. | `false` |
|
||||
| `prometheus.metrics.podMonitor.annotations` | Additional podMonitor annotations. | `{}` |
|
||||
| `prometheus.metrics.podMonitor.enableHttp2` | Enable HTTP2. | `false` |
|
||||
| `prometheus.metrics.podMonitor.enableHttp2` | Enable HTTP2. | `true` |
|
||||
| `prometheus.metrics.podMonitor.followRedirects` | FollowRedirects configures whether scrape requests follow HTTP 3xx redirects. | `false` |
|
||||
| `prometheus.metrics.podMonitor.honorLabels` | Honor labels. | `false` |
|
||||
| `prometheus.metrics.podMonitor.labels` | Additional podMonitor labels. | `{}` |
|
||||
@ -234,12 +234,11 @@ replaced:
|
||||
| `prometheus.metrics.serviceMonitor.enabled` | Enable creation of a serviceMonitor. Excludes the existence of a podMonitor resource. | `false` |
|
||||
| `prometheus.metrics.serviceMonitor.annotations` | Additional serviceMonitor annotations. | `{}` |
|
||||
| `prometheus.metrics.serviceMonitor.labels` | Additional serviceMonitor labels. | `{}` |
|
||||
| `prometheus.metrics.serviceMonitor.enableHttp2` | Enable HTTP2. | `false` |
|
||||
| `prometheus.metrics.serviceMonitor.enableHttp2` | Enable HTTP2. | `true` |
|
||||
| `prometheus.metrics.serviceMonitor.followRedirects` | FollowRedirects configures whether scrape requests follow HTTP 3xx redirects. | `false` |
|
||||
| `prometheus.metrics.serviceMonitor.honorLabels` | Honor labels. | `false` |
|
||||
| `prometheus.metrics.serviceMonitor.interval` | Interval at which metrics should be scraped. If not specified Prometheus' global scrape interval is used. | `60s` |
|
||||
| `prometheus.metrics.serviceMonitor.path` | HTTP path for scraping Prometheus metrics. | `/metrics` |
|
||||
| `prometheus.metrics.serviceMonitor.port` | HTTP port for scraping Prometheus metrics. | `9187` |
|
||||
| `prometheus.metrics.serviceMonitor.relabelings` | RelabelConfigs to apply to samples before scraping. Prometheus Operator automatically adds relabelings for a few standard Kubernetes fields. | `[]` |
|
||||
| `prometheus.metrics.serviceMonitor.scrapeTimeout` | Timeout after which the scrape is ended. If not specified, global Prometheus scrape timeout is used. | `30s` |
|
||||
| `prometheus.metrics.serviceMonitor.scheme` | HTTP scheme to use for scraping. For example `http` or `https`. | `http` |
|
||||
|
@ -52,15 +52,15 @@
|
||||
{{/* volumeMounts */}}
|
||||
|
||||
{{- define "prometheus-postgres-exporter.deployment.volumeMounts" -}}
|
||||
{{- $volumeMounts := dict "volumeMounts" (.Values.deployment.postgresExporter.volumeMounts | default (list) ) }}
|
||||
{{- $volumeMounts = merge $volumeMounts (dict "volumeMounts" (list (dict "name" "config.d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" ))) }}
|
||||
{{ toYaml $volumeMounts }}
|
||||
{{- $volumeMounts := .Values.deployment.postgresExporter.volumeMounts | default list }}
|
||||
{{- $volumeMounts = concat $volumeMounts (list (dict "name" "config-d" "mountPath" "/etc/prometheus-postgres-exporter/config.d" )) }}
|
||||
{{ toYaml (dict "volumeMounts" $volumeMounts) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* volumes */}}
|
||||
|
||||
{{- define "prometheus-postgres-exporter.deployment.volumes" -}}
|
||||
{{- $volumes := dict "volumes" (.Values.deployment.volumes | default (list) ) }}
|
||||
{{- $volumes := .Values.deployment.volumes | default list }}
|
||||
|
||||
{{- $exporterSecretName := .Values.config.exporterConfig.existingSecret.secretName -}}
|
||||
{{- if not .Values.config.exporterConfig.existingSecret.enabled }}
|
||||
@ -72,8 +72,8 @@
|
||||
{{- $webConfigSecretName = printf "%s-web-config" (include "prometheus-postgres-exporter.fullname" . ) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $volumes = merge $volumes (dict "volumes" (list (dict "name" "config.d" "projected" (dict "defaultMode" "0444" "sources" (list (dict "secret" (dict "name" $exporterSecretName)) (dict "secret" (dict "name" $webConfigSecretName))))))) }}
|
||||
{{- $volumes = concat $volumes (list (dict "name" "config-d" "projected" (dict "defaultMode" 444 "sources" (list (dict "secret" (dict "name" $exporterSecretName)) (dict "secret" (dict "name" $webConfigSecretName)))))) }}
|
||||
|
||||
{{ toYaml $volumes }}
|
||||
{{ toYaml (dict "volumes" $volumes) }}
|
||||
|
||||
{{- end -}}
|
@ -16,7 +16,7 @@ metadata:
|
||||
spec:
|
||||
{{- with .Values.prometheus.rules }}
|
||||
groups:
|
||||
- name: {{ template "prometheus-postgres-exporter.name" $ }}
|
||||
- name: {{ template "prometheus-postgres-exporter.fullname" $ }}
|
||||
rules:
|
||||
{{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
|
@ -11,7 +11,7 @@ metadata:
|
||||
labels:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
name: {{ include "prometheus-postgres-exporter.fullname" . }}-webconfig
|
||||
name: {{ include "prometheus-postgres-exporter.fullname" . }}-web-config
|
||||
namespace: {{ .Release.Namespace }}
|
||||
stringData:
|
||||
webConfig.yaml: |
|
||||
|
@ -25,7 +25,7 @@ spec:
|
||||
{{- toYaml . | nindent 6 }}
|
||||
{{- end }}
|
||||
scrapeTimeout: {{ required "The scrape timeout of the serviceMonitor is not defined!" .Values.prometheus.metrics.serviceMonitor.scrapeTimeout }}
|
||||
scheme: {{ required "The scheme of the serviceMonitor is not defined!" .Values.prometheus.metrics.serviceMonitor.scheme}}
|
||||
scheme: {{ required "The scheme of the serviceMonitor is not defined!" .Values.prometheus.metrics.serviceMonitor.scheme }}
|
||||
targetPort: {{ required "The port of the service is not defined!" .Values.services.http.port }}
|
||||
{{- with .Values.prometheus.metrics.serviceMonitor.tlsConfig }}
|
||||
tlsConfig:
|
||||
|
@ -42,13 +42,13 @@ tests:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
||||
name: config.d
|
||||
name: config-d
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: config.d
|
||||
- name: config-d
|
||||
projected:
|
||||
defaultMode: "0444"
|
||||
defaultMode: 444
|
||||
sources:
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-exporter-config
|
||||
@ -143,13 +143,13 @@ tests:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
||||
name: config.d
|
||||
name: config-d
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: config.d
|
||||
- name: config-d
|
||||
projected:
|
||||
defaultMode: "0444"
|
||||
defaultMode: 444
|
||||
sources:
|
||||
- secret:
|
||||
name: exporter-config-secret
|
||||
@ -165,13 +165,13 @@ tests:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
value:
|
||||
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
||||
name: config.d
|
||||
name: config-d
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
value:
|
||||
- name: config.d
|
||||
- name: config-d
|
||||
projected:
|
||||
defaultMode: "0444"
|
||||
defaultMode: 444
|
||||
sources:
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-exporter-config
|
||||
@ -352,14 +352,24 @@ tests:
|
||||
hostPath:
|
||||
path: /usr/lib/prometheus-postgres-exporter/data
|
||||
asserts:
|
||||
- contains:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content:
|
||||
name: data
|
||||
value:
|
||||
- name: data
|
||||
mountPath: /usr/lib/prometheus-postgres-exporter/data
|
||||
- contains:
|
||||
- name: config-d
|
||||
mountPath: /etc/prometheus-postgres-exporter/config.d
|
||||
- equal:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: data
|
||||
value:
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /usr/lib/prometheus-postgres-exporter/data
|
||||
path: /usr/lib/prometheus-postgres-exporter/data
|
||||
- name: config-d
|
||||
projected:
|
||||
defaultMode: 444
|
||||
sources:
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-exporter-config
|
||||
- secret:
|
||||
name: prometheus-postgres-exporter-unittest-web-config
|
@ -58,7 +58,7 @@ tests:
|
||||
helm.sh/chart: prometheus-postgres-exporter-0.1.0
|
||||
- equal:
|
||||
path: spec.podMetricsEndpoints[0].enableHttp2
|
||||
value: false
|
||||
value: true
|
||||
- equal:
|
||||
path: spec.podMetricsEndpoints[0].followRedirects
|
||||
value: false
|
||||
@ -119,7 +119,7 @@ tests:
|
||||
set:
|
||||
prometheus.metrics.enabled: true
|
||||
prometheus.metrics.podMonitor.enabled: true
|
||||
prometheus.metrics.podMonitor.enableHttp2: true
|
||||
prometheus.metrics.podMonitor.enableHttp2: false
|
||||
prometheus.metrics.podMonitor.followRedirects: true
|
||||
prometheus.metrics.podMonitor.honorLabels: true
|
||||
prometheus.metrics.podMonitor.interval: "180s"
|
||||
@ -137,7 +137,7 @@ tests:
|
||||
count: 1
|
||||
- equal:
|
||||
path: spec.podMetricsEndpoints[0].enableHttp2
|
||||
value: true
|
||||
value: false
|
||||
- equal:
|
||||
path: spec.podMetricsEndpoints[0].followRedirects
|
||||
value: true
|
||||
|
@ -15,7 +15,7 @@ tests:
|
||||
- containsDocument:
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
name: prometheus-postgres-exporter-unittest-webconfig
|
||||
name: prometheus-postgres-exporter-unittest-web-config
|
||||
namespace: testing
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
|
@ -59,7 +59,7 @@ tests:
|
||||
helm.sh/chart: prometheus-postgres-exporter-0.1.0
|
||||
- equal:
|
||||
path: spec.endpoints[0].enableHttp2
|
||||
value: false
|
||||
value: true
|
||||
- equal:
|
||||
path: spec.endpoints[0].followRedirects
|
||||
value: false
|
||||
@ -121,7 +121,7 @@ tests:
|
||||
set:
|
||||
prometheus.metrics.enabled: true
|
||||
prometheus.metrics.serviceMonitor.enabled: true
|
||||
prometheus.metrics.serviceMonitor.enableHttp2: true
|
||||
prometheus.metrics.serviceMonitor.enableHttp2: false
|
||||
prometheus.metrics.serviceMonitor.followRedirects: true
|
||||
prometheus.metrics.serviceMonitor.honorLabels: true
|
||||
prometheus.metrics.serviceMonitor.interval: "180s"
|
||||
@ -139,7 +139,7 @@ tests:
|
||||
count: 1
|
||||
- equal:
|
||||
path: spec.endpoints[0].enableHttp2
|
||||
value: true
|
||||
value: false
|
||||
- equal:
|
||||
path: spec.endpoints[0].followRedirects
|
||||
value: true
|
||||
|
@ -38,7 +38,7 @@ config:
|
||||
|
||||
## @param config.exporterConfig.secret.annotations Additional annotations of the secret containing the `exporterConfig.yaml`.
|
||||
## @param config.exporterConfig.secret.labels Additional labels of the secret containing the `exporterConfig.yaml`.
|
||||
## @param config.exporterConfig.secret.exporterConfig Content of the `exporterConfig.yaml`. Further information can be found [here](https://prometheus.io/docs/prometheus/latest/configuration/https/).
|
||||
## @param config.exporterConfig.secret.exporterConfig Content of the `exporterConfig.yaml`. Further information can be found [here](https://github.com/prometheus-community/postgres_exporter?tab=readme-ov-file#multi-target-support-beta).
|
||||
## @skip config.exporterConfig.secret.exporterConfig Skip individual postgres exporter configuration.
|
||||
secret:
|
||||
annotations: {}
|
||||
@ -313,7 +313,7 @@ prometheus:
|
||||
podMonitor:
|
||||
enabled: false
|
||||
annotations: {}
|
||||
enableHttp2: false
|
||||
enableHttp2: true
|
||||
followRedirects: false
|
||||
honorLabels: false
|
||||
labels: {}
|
||||
@ -341,7 +341,7 @@ prometheus:
|
||||
enabled: false
|
||||
annotations: {}
|
||||
labels: {}
|
||||
enableHttp2: false
|
||||
enableHttp2: true
|
||||
followRedirects: false
|
||||
honorLabels: false
|
||||
interval: "60s"
|
||||
|
Reference in New Issue
Block a user