Answers: <p>You need to probe the exporter in order to get your metric, like this : <code>curl 'http//{IPADRESSE}:9104/probe?auth_module=client.{name}&amp;target={ENDPOINT}:{PORT}'</code></p>
  
Answers: CC BY-SA 4.0
Answers: 2024-01-25T15:44:24.380Z
Answers: 2024-01-25T15:44:24.380Z
Answers: aleveque
Body: <p>I have been trying for a few days to set up a multi-target MySQL exporter (MSE) deployed with Helm inside a k8s cluster. The chart that I am using is the <a href="https://artifacthub.io/packages/helm/prometheus-community/prometheus-mysql-exporter/2.2.0" rel="nofollow noreferrer">https://artifacthub.io/packages/helm/prometheus-community/prometheus-mysql-exporter/2.2.0</a> (latest as of today).
  It works when I try to connect directly to the primary DB without using the multi-target config in <code>values.yaml/serviceMonitor</code> : I can see the data in my grafana.</p>
  <p>I see in the documentation that I can specify multiple targets for my MSE and have filled the <code>values.yaml</code> accordingly (see <code>values.yaml</code> below). I have enabled the multi-target and have specified that the password is not the same for both targets.
  My targets are both MariaDB databases : one is external to the cluster (accessible by IPv4) and the other one is an helm-deployed MariaDB inside the cluster.</p>
  <p>Some attention points :</p>
  <ul>
  <li>exporter user is present on both the primary and the replica, with permission access from everywhere (%) for testing purposes.</li>
  <li><code>my.cnf</code> is deployed as a secret in the cluster and recovered successfully by the mysql-exporter pod in <code>/etc/cnf/my.cnf</code> (see file below)</li>
  </ul>
  <p>What I get when I do <code>helm upgrade</code> is the following, from my pod's logs :
  <code>caller=exporter.go:152 level=error msg=&quot;Error pinging mysqld&quot; err=&quot;dial tcp [::1]:3306: connect: connection refused&quot;</code></p>
  <p>Questions :</p>
  <ul>
  <li><p>Is it a stable feature ?</p>
  </li>
  <li><p>Is the documentation accurate when it says to not use [client] but instead [client.name] ?</p>
  </li>
  <li><p>Can it work if one of both databases connection is not successful ?</p>
  </li>
  <li><p>How to make it work ?</p>
  </li>
  </ul>
  <p><strong>my.cnf</strong></p>
  <pre><code>[client]
  user=NOT_USED
  password=NOT_USED
  [client.mariadb-staging]
  user=exporter
  password=XXXXXXXXX
  [client.replica-1]
  user=exporter
  password=XXXXXXXXXX
  </code></pre>
  <p><strong>values.yaml</strong></p>
  <pre><code>## Default values for prometheus-mysql-exporter.
  ## This is a YAML-formatted file.
  ## Declare variables to be passed into your templates.
  
  ## namespaceOverride overrides the namespace which the resources will be deployed in
  namespaceOverride: &quot;&quot;
  
  ## override release name
  fullnameOverride: &quot;&quot;
  
  replicaCount: 1
  
  image:
    registry: quay.io
    repository: prometheus/mysqld-exporter
    ## if not set charts appVersion var is used
    tag: &quot;&quot;
    pullPolicy: &quot;IfNotPresent&quot;
  
  # imagePullSecrets:
  # - name: secret-name
  imagePullSecrets: []
  
  service:
    labels: {}
    annotations: {}
    name: mysql-exporter
    type: ClusterIP
    externalPort: 9104
    internalPort: 9104
  
  serviceMonitor:
    # enabled should be set to true to enable prometheus-operator discovery of this service
    enabled: true
    # interval is the interval at which metrics should be scraped
    interval: 30s
    # scrapeTimeout is the timeout after which the scrape is ended
    scrapeTimeout: 10s
    namespace: monitoring
    # additionalLabels is the set of additional labels to add to the ServiceMonitor
    additionalLabels: {}
    jobLabel: &quot;&quot;
    targetLabels: []
    podTargetLabels: []
    metricRelabelings: []
    # Set relabel_configs as per https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
    relabelings: []
    # Enable multi target scraping.
        # 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
    multipleTarget:
      enabled: true
      targets:
        - name: mariadb-staging
          endpoint: xx.xxx.xxx.32
          port: 3306
        - name: replica-1
          endpoint: metabase-mariadb.database.svc.cluster.local
          port: 3306
      # Enable shared credentials for all targets
      sharedSecret:
        enabled: false
        name: &quot;&quot;
  
  serviceAccount:
    # Specifies whether a ServiceAccount should be created
    create: false
    # The name of the ServiceAccount to use.
    # If not set and create is true, a name is generated using the fullname template
    name:
    annotations: {}
  
  resources: {}
    # We usually recommend not to specify default resources and to leave this as a conscious
    # choice for the user. This also increases chances charts run on environments with little
    # resources, such as Minikube. If you do want to specify resources, uncomment the following
    # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
    #limits:
    # cpu: 100m
    # memory: 128Mi
    #requests:
    # cpu: 100m
    # memory: 128Mi
  
  nodeSelector: {}
  
  tolerations: []
  
  affinity: {}
  
  podLabels: {}
  
  # Extra Volume Mounts for the mysql exporter container
  extraVolumeMounts: []
  # - name: example
  #   mountPath: /example
  
  # Extra Volumes for the pod
  extraVolumes: []
  # - name: example
  #   configMap:
  #     name: example
  
  podSecurityContext: {}
    # fsGroup: 65534
  
  securityContext: {}
    # capabilities:
    #   drop:
    #   - ALL
    # readOnlyRootFilesystem: true
    # runAsNonRoot: true
    # runAsUser: 65534
  
  annotations:
    prometheus.io/scrape: &quot;true&quot;
    prometheus.io/path: &quot;/metrics&quot;
    prometheus.io/port: &quot;9104&quot;
  
  config: {}
    # Allow to set specifc options on the exporter
    # logLevel: info
    # logFormat: &quot;logger:stderr&quot;
  
  collectors:
    # auto_increment.columns: false
    # binlog_size: false
    engine_innodb_status: true
    # engine_tokudb_status: false
    # global_status: true
    # global_variables: true
    # info_schema.clientstats: false
    # info_schema.innodb_metrics: false
    # info_schema.innodb_tablespaces: false
    # info_schema.innodb_cmp: false
    # info_schema.innodb_cmpmem: false
    # info_schema.processlist: false
    # info_schema.processlist.min_time: 0
    # info_schema.query_response_time: false
    # info_schema.tables: true
    # info_schema.tables.databases: '*'
    # info_schema.tablestats: false
    # info_schema.schemastats: false
    # info_schema.userstats: false
    # perf_schema.eventsstatements: false
    # perf_schema.eventsstatements.digest_text_limit: 120
    # perf_schema.eventsstatements.limit: false
    # perf_schema.eventsstatements.timelimit: 86400
    # perf_schema.eventswaits: false
    # perf_schema.file_events: false
    # perf_schema.file_instances: false
    # perf_schema.indexiowaits: false
    # perf_schema.tableiowaits: false
    # perf_schema.tablelocks: false
    # perf_schema.replication_group_member_stats: false
    slave_status: true
    # slave_hosts: false
    # heartbeat: false
    # heartbeat.database: heartbeat
    # heartbeat.table: heartbeat
  
  # mysql connection params which build the my.cnf config
  mysql:
    db: &quot;&quot;
    host: &quot;&quot;
    ## config my.cnf https://dev.mysql.com/doc/c-api/8.0/en/mysql-options.html
    additionalConfig:
      - connect-timeout=5
      - debug
    pass: &quot;&quot;
    port: &quot;&quot;
    protocol: &quot;&quot;
    user: &quot;&quot;
    # secret with full config my.cnf
    existingConfigSecret:
      name: &quot;config-mysql-exporter&quot;
      key: &quot;my.cnf&quot;
    # secret only containing the password
    #existingSecret: &quot;connection-string-mariadb&quot;
    #existingPasswordSecret:
    #  name: &quot;&quot;
    #  key: &quot;&quot; 
  </code></pre>
  
Tags: <prometheus><kubernetes-helm><mysql>
Title: How to configure MySQL exporter Helm chart for multiple targets (remote & local)?
UserDisplayName: alban boitier
ThreadText: # How to configure MySQL exporter Helm chart for multiple targets (remote & local)?
  
  (Asked by: username_0 on 2024-01-04)
  
  I have been trying for a few days to set up a multi-target MySQL exporter (MSE) deployed with Helm inside a k8s cluster. The chart that I am using is the <https://artifacthub.io/packages/helm/prometheus-community/prometheus-mysql-exporter/2.2.0> (latest as of today).
  It works when I try to connect directly to the primary DB without using the multi-target config in `values.yaml/serviceMonitor` : I can see the data in my grafana.
  
  I see in the documentation that I can specify multiple targets for my MSE and have filled the `values.yaml` accordingly (see `values.yaml` below). I have enabled the multi-target and have specified that the password is not the same for both targets.
  My targets are both MariaDB databases : one is external to the cluster (accessible by IPv4) and the other one is an helm-deployed MariaDB inside the cluster.
  
  Some attention points :
  
  * exporter user is present on both the primary and the replica, with permission access from everywhere (%) for testing purposes.
  * `my.cnf` is deployed as a secret in the cluster and recovered successfully by the mysql-exporter pod in `/etc/cnf/my.cnf` (see file below)
  
  What I get when I do `helm upgrade` is the following, from my pod's logs :
  `caller=exporter.go:152 level=error msg="Error pinging mysqld" err="dial tcp [::1]:3306: connect: connection refused"`
  
  Questions :
  
  * Is it a stable feature ?
  * Is the documentation accurate when it says to not use [client] but instead [client.name] ?
  * Can it work if one of both databases connection is not successful ?
  * How to make it work ?
  
  **my.cnf**
  
  ```
  [client]
  user=NOT_USED
  password=NOT_USED
  [client.mariadb-staging]
  user=exporter
  password=XXXXXXXXX
  [client.replica-1]
  user=exporter
  password=XXXXXXXXXX
  
  ```
  
  **values.yaml**
  
  ```
  ## Default values for prometheus-mysql-exporter.
  ## This is a YAML-formatted file.
  ## Declare variables to be passed into your templates.
  
  ## namespaceOverride overrides the namespace which the resources will be deployed in
  namespaceOverride: ""
  
  ## override release name
  fullnameOverride: ""
  
  replicaCount: 1
  
  image:
    registry: quay.io
    repository: prometheus/mysqld-exporter
    ## if not set charts appVersion var is used
    tag: ""
    pullPolicy: "IfNotPresent"
  
  # imagePullSecrets:
  # - name: secret-name
  imagePullSecrets: []
  
  service:
    labels: {}
    annotations: {}
    name: mysql-exporter
    type: ClusterIP
    externalPort: 9104
    internalPort: 9104
  
  serviceMonitor:
    # enabled should be set to true to enable prometheus-operator discovery of this service
    enabled: true
    # interval is the interval at which metrics should be scraped
    interval: 30s
    # scrapeTimeout is the timeout after which the scrape is ended
    scrapeTimeout: 10s
    namespace: monitoring
    # additionalLabels is the set of additional labels to add to the ServiceMonitor
    additionalLabels: {}
    jobLabel: ""
    targetLabels: []
    podTargetLabels: []
    metricRelabelings: []
    # Set relabel_configs as per https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
    relabelings: []
    # Enable multi target scraping.
        # 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
    multipleTarget:
      enabled: true
      targets:
        - name: mariadb-staging
          endpoint: xx.xxx.xxx.32
          port: 3306
        - name: replica-1
          endpoint: metabase-mariadb.database.svc.cluster.local
          port: 3306
      # Enable shared credentials for all targets
      sharedSecret:
        enabled: false
        name: ""
  
  serviceAccount:
    # Specifies whether a ServiceAccount should be created
    create: false
    # The name of the ServiceAccount to use.
    # If not set and create is true, a name is generated using the fullname template
    name:
    annotations: {}
  
  resources: {}
    # We usually recommend not to specify default resources and to leave this as a conscious
    # choice for the user. This also increases chances charts run on environments with little
    # resources, such as Minikube. If you do want to specify resources, uncomment the following
    # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
    #limits:
    # cpu: 100m
    # memory: 128Mi
    #requests:
    # cpu: 100m
    # memory: 128Mi
  
  nodeSelector: {}
  
  tolerations: []
  
  affinity: {}
  
  podLabels: {}
  
  # Extra Volume Mounts for the mysql exporter container
  extraVolumeMounts: []
  # - name: example
  #   mountPath: /example
  
  # Extra Volumes for the pod
  extraVolumes: []
  # - name: example
  #   configMap:
  #     name: example
  
  podSecurityContext: {}
    # fsGroup: 65534
  
  securityContext: {}
    # capabilities:
    #   drop:
    #   - ALL
    # readOnlyRootFilesystem: true
    # runAsNonRoot: true
    # runAsUser: 65534
  
  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/path: "/metrics"
    prometheus.io/port: "9104"
  
  config: {}
    # Allow to set specifc options on the exporter
    # logLevel: info
    # logFormat: "logger:stderr"
  
  collectors:
    # auto_increment.columns: false
    # binlog_size: false
    engine_innodb_status: true
    # engine_tokudb_status: false
    # global_status: true
    # global_variables: true
    # info_schema.clientstats: false
    # info_schema.innodb_metrics: false
    # info_schema.innodb_tablespaces: false
    # info_schema.innodb_cmp: false
    # info_schema.innodb_cmpmem: false
    # info_schema.processlist: false
    # info_schema.processlist.min_time: 0
    # info_schema.query_response_time: false
    # info_schema.tables: true
    # info_schema.tables.databases: '*'
    # info_schema.tablestats: false
    # info_schema.schemastats: false
    # info_schema.userstats: false
    # perf_schema.eventsstatements: false
    # perf_schema.eventsstatements.digest_text_limit: 120
    # perf_schema.eventsstatements.limit: false
    # perf_schema.eventsstatements.timelimit: 86400
    # perf_schema.eventswaits: false
    # perf_schema.file_events: false
    # perf_schema.file_instances: false
    # perf_schema.indexiowaits: false
    # perf_schema.tableiowaits: false
    # perf_schema.tablelocks: false
    # perf_schema.replication_group_member_stats: false
    slave_status: true
    # slave_hosts: false
    # heartbeat: false
    # heartbeat.database: heartbeat
    # heartbeat.table: heartbeat
  
  # mysql connection params which build the my.cnf config
  mysql:
    db: ""
    host: ""
    ## config my.cnf https://dev.mysql.com/doc/c-api/8.0/en/mysql-options.html
    additionalConfig:
      - connect-timeout=5
      - debug
    pass: ""
    port: ""
    protocol: ""
    user: ""
    # secret with full config my.cnf
    existingConfigSecret:
      name: "config-mysql-exporter"
      key: "my.cnf"
    # secret only containing the password
    #existingSecret: "connection-string-mariadb"
    #existingPasswordSecret:
    #  name: ""
    #  key: "" 
  
  ```
  
  **Tags:** prometheus, kubernetes-helm, mysql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-01-25. Score: 0
  
  You need to probe the exporter in order to get your metric, like this : `curl 'http//{IPADRESSE}:9104/probe?auth_module=client.{name}&target={ENDPOINT}:{PORT}'`
  
  
  ---
  
  