Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prometheus-mysql-exporter] Manual credentials specification for mult… #4485

Merged
merged 2 commits into from Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/prometheus-mysql-exporter/Chart.yaml
@@ -1,7 +1,7 @@
apiVersion: v1
description: A Helm chart for prometheus mysql exporter with cloudsqlproxy
name: prometheus-mysql-exporter
version: 2.5.1
version: 2.5.2
home: https://github.com/prometheus/mysqld_exporter
appVersion: v0.15.1
sources:
Expand Down
35 changes: 21 additions & 14 deletions charts/prometheus-mysql-exporter/README.md
Expand Up @@ -43,37 +43,44 @@ helm upgrade [RELEASE_NAME] [CHART] --install

### Multiple-target probes

mysql_exporter now support multi-target probes using the `/probe` route. To enable this feature, set `serviecMonitor.multipleTarget.enabled` to `true` and define your targets in `serviceMonitor.multipleTarget.targets`.
Credentials for each target should be referenced in the associate config file. Target name should match the entry in the config file.
mysql_exporter now support multi-target probes using the `/probe` route. To enable this feature, set `serviceMonitor.multipleTarget.enabled` to `true` and define your targets in `serviceMonitor.multipleTarget.targets`.
Credentials for each target should be referenced either in targets section or in the associated config file.
As an example, for a config file with two targets:

```yaml
serviceMonitor:
multipleTarget:
enabled: true
targets:
- name: localhost
endpoint: 127.0.0.1
- name: remote
endpoint: 8.8.8.8
- endpoint: mysql1.dns.local
name: mysql1
port: 3307
user: user1
password: password1
- endpoint: mysql2.dns.local
name: mysql2
user: user2
password: password2
```

Config file should have the following entries:
In case of Config file Target name should match the entry in the config file.
Config file example for the above targets:

```cnf
[client]
user=NOT_USED
password=NOT_USED
[client.localhost]
user=localhost_user
password=localhost_password
[client.remote]
user=remote_user
password=remote_password
[client.mysql1]
user=user1
password=password1
[client.mysql2]
user=user2
password=password2
```

The configuration file can be referenced using `mysql.existingConfigSecret`.
The configuration file can be:
- referenced using `mysql.existingConfigSecret`;
- created automatically in case user and password are specified for the target.
If all your target use the same credentials, you can set `serviceMonitor.sharedSecret.enabled` to `true` and define the key name in `serviceMonitor.sharedSecret.name`.

### From 1.x to 2.x
Expand Down
13 changes: 13 additions & 0 deletions charts/prometheus-mysql-exporter/templates/_helpers.tpl
Expand Up @@ -91,6 +91,19 @@ Secret key for config
{{- end -}}
*/}}

{{/* Define a function to iterate over multi scraping targets */}}
{{- define "render_mysql_targets" -}}
{{- if and (.Values.serviceMonitor.multipleTarget.targets) (not .Values.serviceMonitor.multipleTarget.sharedSecret.enabled) -}}
{{- range .Values.serviceMonitor.multipleTarget.targets }}
{{- if and (.user) (.password) }}
[client.{{ .name }}]
user={{ .user }}
password={{ .password }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Define overriding namespace
*/}}
Expand Down
Expand Up @@ -25,4 +25,7 @@ stringData:
{{- range $param := .Values.mysql.additionalConfig}}
{{ $param }}
{{- end }}
{{- if .Values.serviceMonitor.multipleTarget.enabled -}}
{{- template "render_mysql_targets" . -}}
{{- end -}}
{{- end }}
7 changes: 5 additions & 2 deletions charts/prometheus-mysql-exporter/values.yaml
Expand Up @@ -50,13 +50,16 @@ serviceMonitor:
multipleTarget:
enabled: false
targets: []
# target connection information with name (required), endpoint (required) and port (optionnal)
# if sharedSecret is not enabled the name must match an entry client.{{ name }} existing in the secret
# target connection information with name (required), endpoint (required), port (optional), user(optional), password(optional)
# - endpoint: mysql1.dns.local
# name: mysql1
# port: 3307
# user: user1
# password: password1
# - endpoint: mysql2.dns.local
# name: mysql2
# user: user2
# password: password2
# Enable shared credentials for all targets
sharedSecret:
enabled: false
Expand Down