How Prometheus collect MySQL QPS please?

1,526 views
Skip to first unread message

jwang...@gmail.com

unread,
Sep 29, 2016, 6:10:40 AM9/29/16
to Prometheus Developers
From which MySQL system table it get the information please?

Thanks a lot in advance

Ben Kochie

unread,
Sep 29, 2016, 6:18:46 AM9/29/16
to jwang...@gmail.com, Prometheus Developers

The mysqld_exporter exposes several metrics from different MySQL subsystems.

The basic server QPS data is collected from SHOW GLOBAL STAUS.

Take a look at the mysql_global_status_commands_total metric.

There are also detailed per query digest metrics in performance schema.  These are disabled by default, as they are only available in MySQL 5.6 and newer.


On Sep 29, 2016 12:10, <jwang...@gmail.com> wrote:
From which MySQL system table it get the information please?

Thanks a lot in advance

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jwang...@gmail.com

unread,
Sep 29, 2016, 6:31:26 AM9/29/16
to Prometheus Developers, jwang...@gmail.com
show global status like '%quer%';

Queries | 463542292

seams only the total queries since server started.
also, can prometheus show what are these queries please? e.g. inserts/updates/deletes/selects et al

Thanks

Ben Kochie

unread,
Sep 29, 2016, 6:34:44 AM9/29/16
to jwang...@gmail.com, Prometheus Developers

MySQL calls these commands, hence the metric I mentioned.  They are broken down by command type.


jwang...@gmail.com

unread,
Sep 29, 2016, 6:57:58 AM9/29/16
to Prometheus Developers, jwang...@gmail.com
Please forgive my blunder-ness, how do i get the mysql_global_status_commands_total metric please?

Please elaborate a bit more.
Thanks a lot in advance

Julius Volz

unread,
Sep 29, 2016, 8:03:05 AM9/29/16
to jwang...@gmail.com, Prometheus Developers
Check out the README for setting up the mysqld_exporter:


It's an exporter which Prometheus can scrape and in the background (during the scrape), it fetches lots of useful metrics from a MySQL daemon.

george....@kkbox.com

unread,
Sep 30, 2016, 5:42:09 AM9/30/16
to Prometheus Developers, jwang...@gmail.com

george....@kkbox.com

unread,
Sep 30, 2016, 5:46:04 AM9/30/16
to Prometheus Developers, jwang...@gmail.com, george....@kkbox.com

your prometheus.yml file should look like this

global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['prometheus_ip:9090']
- job_name: grafana-1-linux
static_configs:
- targets: ['prometheus_ip:9100']
labels:
alias: prometheus-server
- job_name: db-linux
static_configs:
- targets: ['db_ip:9100']
labels:
alias: db-name
- job_name: db-mysql
static_configs:
- targets: ['db_ip:9104']
labels:
alias: db-name

jwang...@gmail.com

unread,
Sep 30, 2016, 7:18:09 AM9/30/16
to Prometheus Developers, jwang...@gmail.com, george....@kkbox.com
Thanks a lot.

However, form my experience there is no way to collect QPS from "GLOBAL STATUS" - you may get how many rows affected.

Thanks

Ben Kochie

unread,
Sep 30, 2016, 7:26:12 AM9/30/16
to jwang...@gmail.com, Prometheus Developers, george....@kkbox.com

Yes, it is totally possible. Like I said originally, the mysqld_exporter exposes the GLOBAL STAUS Com_% counters as a metric.

Prometheus collects this and allows you to apply a rate function.

For example, rate(mysql_global_status_commands_total[5m])

This returns the per-second rate with a 5 minute rolling average.


--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.

jwang...@gmail.com

unread,
Sep 30, 2016, 9:40:42 AM9/30/16
to Prometheus Developers, jwang...@gmail.com, george....@kkbox.com
I remember it wrong. Com_* is queries not row affected.
http://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Com_xxx

Thanks a lot, All

Ben Kochie

unread,
Oct 1, 2016, 11:30:11 AM10/1/16
to jwang...@gmail.com, Prometheus Developers, george....@kkbox.com

Yup. You can get good rows affected/examined/sent from performance schema events statements.  One of the more useful things Prometheus can handle that many monitoring systems can't. ;-)


--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
To post to this group, send email to prometheus-developers@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages