usage of multiple mysql db instances with openshift

57 views
Skip to first unread message

sneha

unread,
Sep 4, 2023, 5:15:06 AM9/4/23
to Prometheus Users
hi,

i tried adding multiple db instance in .my.cnf file with mysql exporter version 0.15.0 but it only scrape DB instance only.
is there any sample to use mutliple DB instance for single exporter and how to distinguish scrape data is of which instance.

thanks,
sneha

Brian Candler

unread,
Sep 4, 2023, 6:35:47 AM9/4/23
to Prometheus Users
On Monday, 4 September 2023 at 10:15:06 UTC+1 sneha wrote:
i tried adding multiple db instance in .my.cnf file with mysql exporter version 0.15.0 but it only scrape DB instance only.
is there any sample to use mutliple DB instance for single exporter

Yes, there is an example Prometheus config at
(see under "On the prometheus side ... ")

It sets the `target` parameter for each scrape to the DB of interest, whilst setting __address__ to point to the exporter itself.

Before doing this, make sure you're able to scrape the exporter directly using curl, i.e.

and how to distinguish scrape data is of which instance.

In a label.  The example config that I linked above copies "__param_target" to "instance", so the "instance" label tells you which DB target was being scraped.

sneha

unread,
Sep 8, 2023, 10:37:14 AM9/8/23
to Prometheus Users
Hi Brian,

thanks it worked , using curl i am able to scrape individual database.
any idea that is it possible in openshift to distinguish that metrics is of which instance.

Regards,
Sneha

Brian Candler

unread,
Sep 8, 2023, 11:36:33 AM9/8/23
to Prometheus Users
Prometheus adds "job" and "instance" labels to all scraped metrics.

Therefore, show some examples of your metrics once they have been stored in Prometheus: what is in the "instance" label? Does it not already distinguish them?

If not, then show your Prometheus scrape job configuration.

sneha

unread,
Sep 9, 2023, 12:00:21 PM9/9/23
to Prometheus Users
two instances are there but one of the instance get name from service in this case http, and other instance is without this name. unless i check with the target query i cant differentiate .
there are two parts one is service which looks like this 

apiVersion: v1
kind: Service
metadata:
    name: mysqld-exporter
    labels:
      app: mysqld-exporter
spec:
  type: ClusterIP
  ports:
   - port: 9104
     protocol: TCP
     name: http
  selector:
   app: mysqld-exporter

and other is service monitor which is like this 

kind: ServiceMonitor
metadata:
   name: mysqld-exporter
spec:
  endpoints:
    interval: 5s
    targetPort: 9104
namespaceSelector:
 matchNames:
  - default
selector:
  matchLabels:
   app: mysqld-exporter



Brian Candler

unread,
Sep 9, 2023, 3:50:12 PM9/9/23
to Prometheus Users
Please show what the metrics look like once scraped into Prometheus.

If you're only looking at "curl" output then you won't see these labels. They are added by Prometheus itself.

And if it still doesn't look right, show the actual Prometheus scrape job (i.e. from prometheus.yml; if that's built by some Kubernetes operator then show the file it builds)

Reply all
Reply to author
Forward
0 new messages