MySQL scraper for shared-instance database

15 views
Skip to first unread message

Alexandra Hilzinger

unread,
Feb 20, 2023, 5:22:04 AM2/20/23
to Prometheus Users
Hi All

We have the situation that we have shared-instances, so a DB-host with different DBs on it from different projects.
In our current setup we are only able to collect metrics from the whole instance with Prometheus.
However, we have the case that we need to break down the data to individual DBs.
Is there an option with a scraper or similar?
I haven't really found anything on the internet.

I am thankful for any advice.

Kind Regards
Alex

Matthias Rampke

unread,
Feb 22, 2023, 5:18:40 PM2/22/23
to Alexandra Hilzinger, Prometheus Users
What per-database metrics are you interested in? How does MySQL itself make them available?

The mysqld_exporter has collectors that are off by default, but that you can enable. Some include per-schema (database) and per-table statistics, but the data still comes from the server-wide information_schema and performance_schema, so you will need access to that. The exporter does *not* support filtering these for a specific schema though. If need be, you can do this on the Prometheus side using metric relabel configuration.

Each collector corresponds to a set of metrics. Turning off the collector also stops the exporter from running the underlying queries, so if you run into a lack of permissions turning off the corresponding collector can help. You will have to experiment and/or look at the exporter code for details.

Alternatively, if you can formulate SQL for the metrics you want to collect, you can use any of the generic SQL exporters to turn those into Prometheus metrics. If your needs go beyond that, writing your own exporter is not terribly complicated – I often find it easier to express my specific needs in my own code than to adapt a generic solution.

Best,
Matthias 

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/bd8c36fe-310d-4296-a13c-4b42d534ac4an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages