In a previous blog post, I showed how to add external exporters to Percona Monitoring and Management (PMM) and monitor Valkey/Redis. This time, let’s do the same with Readyset.
Readyset is a caching layer that sits between your application and your MySQL or PostgreSQL database. It is wire-compatible with the database, so your application connects to Readyset instead of the database. Readyset serves the cached queries from memory and proxies everything else to the upstream database.
This also means that once you put Readyset in front of your database, it is part of your critical path. If it goes down, or it stops serving queries from the cache, your database will feel it immediately. So you want to see it in the same place where you already monitor your databases: PMM.
The good news is that Readyset already exposes Prometheus metrics, so this time we do not even need a separate exporter. Let’s see how it works.
Readyset has a built-in HTTP endpoint on port 6034 (you can change it with --metrics-address). It serves the Prometheus metrics on /metrics and a health check on /health. In the version I tested, the Prometheus metrics are enabled by default. If you run an older version, start Readyset with --prometheus-metrics (or PROMETHEUS_METRICS=true in Docker).
For this blog post, I started Readyset in Docker in front of a MySQL 8.4 server:
|
1 2 3 4 5 |
> docker run -d --name readyset -p 3307:3307 -p 6034:6034 \ -e UPSTREAM_DB_URL='mysql://{{USER}}:{{PASSWORD}}@mysql-host:3306/testdb' \ -e LISTEN_ADDRESS=0.0.0.0:3307 \ -e STORAGE_DIR=/state \ readysettech/readyset:latest |
The application connects to port 3307, and the metrics are on port 6034. Let’s check them:
|
1 2 3 |
> curl -s http://127.0.0.1:6034/metrics | grep readyset_query_log_execution_count readyset_query_log_execution_count{upstream_db_type="mysql",deployment="rslab",database_type="readyset",query_id="q_8c2f9257a2c7f9f7"} 308584 readyset_query_log_execution_count{upstream_db_type="mysql",deployment="rslab",database_type="upstream",query_id="q_b6da3b41d15621ce"} 1545 |
The database_type label tells you who answered the query: readyset means it was served from the cache, upstream means it was proxied to the database. The query_id is the same ID you see in SHOW CACHES and SHOW PROXIED QUERIES.
One more thing worth knowing: recent Readyset versions create shallow caches by default. These cache the result for a TTL and refresh it from the database. With CACHE_MODE=deep, Readyset creates deep caches, which replicate from the binary log (or WAL on PostgreSQL) and keep the results up to date incrementally. I tested both modes, and they expose a few different metrics. Readyset has dashboards for both.
I used Readyset stable-261022, MySQL 8.4, and PMM 3.10.0 for all the tests.
Now, we have to tell the PMM Client to collect the metrics from port 6034. If you do not have a PMM Server or Client configured yet, please follow this link. On the Readyset server, run:
|
1 2 |
> pmm-admin add external --service-name=readyset --listen-port=6034 --group=readyset Connection check failed: Unexpected exporter's response format: text format parsing error in line 213: second TYPE line for metric name "readyset_query_status_cache_id_to_status_size", or TYPE reported after samples. |
Well, this did not work on the first try. Readyset has two internal metrics, readyset_query_status_cache.id_to_status.size and readyset_query_status_cache_id_to_status_size. Prometheus does not allow dots in metric names, so the dots become underscores, and we end up with the same metric twice on the /metrics page. The connection check in pmm-admin uses a strict parser and refuses it, but the collector in PMM (vmagent) does not mind. So we can simply skip the check:
|
1 2 3 4 5 |
> pmm-admin add external --service-name=readyset --listen-port=6034 --group=readyset --skip-connection-check External Service added. Service ID : e644afbd-acf8-442c-9219-cb2432cd2131 Service name: readyset Group : readyset |
The --group=readyset option adds an external_group="readyset" label to every metric, which will be useful for the alerts later.
Let’s check it:
|
1 2 3 4 5 6 7 8 9 |
> pmm-admin list Service type Service name Address and port Service ID External:readyset readyset e644afbd-acf8-442c-9219-cb2432cd2131 Agent type Status Metrics Mode Agent ID Service ID Port pmm_agent Connected e131e7e0-9e65-4de3-b45a-6b3fba24f4a0 0 node_exporter Running push 332240dd-8e63-4698-b1c7-5890ddc1f8f5 42000 external-exporter Unknown push 938d3163-e786-4fff-94fd-5fab90ea3035 e644afbd-acf8-442c-9219-cb2432cd2131 6034 vmagent Running push 8150b3ee-e0f6-4938-a086-e17cff32472a 42001 |
In my test, the external exporter status stayed Unknown, but the metrics arrived without any problem. With this command, PMM collected 113 different Readyset metrics.
Now, let’s visualize the data we collect. For Valkey/Redis, we simply imported a dashboard from the Grafana website. For Readyset, there is a better place: Readyset keeps its dashboards in its own repository, in build/docker/grafana/dashboards. These are the dashboards of Readyset’s own Grafana image, and they use the current metric names. Download them from the tag that matches your Readyset version (I used stable-261022). There is also a Readyset dashboard on grafana.com, but it is from February 2024 and uses old metric names, so I would not use that one.
The dashboards work in PMM.
Two dashboards also run SQL commands on Readyset: Query Metrics runs SHOW CACHES and SHOW PROXIED QUERIES, and the Uptime panel runs SHOW READYSET STATUS. For these, add a MySQL data source in PMM that points to Readyset (port 3307 in my example), and name it DS_READYSET, like in Readyset’s own Grafana, because the dashboards find it by this name. The quickest way is to open https://<your-pmm-server>/graph/connections/datasources/new and choose MySQL. I only tested this with MySQL.
Now, to load a dashboard into PMM, navigate to All dashboards -> New -> Import, upload the JSON file, and select Metrics for DS_PROMETHEUS (and DS_READYSET for DS_READYSET on the Query Metrics dashboard). Then pick your Readyset deployment in the deployment drop-down. This is the DEPLOYMENT setting of Readyset, and it is readyset.db if you did not set it.

These are the dashboards I found the most useful:
ops.json): the overview, with the query hit ratio, queries per second, connections, memory, and uptime.adapter_metrics.json): queries per second and p50/p99 latency, separately for cached and proxied queries, plus connections and query parsing errors.query_overview.json): a table of the cached and proxied queries with their query text, counts, and latencies.shallow_caching.json): hits, misses, and refreshes of shallow caches.The folder also has dashboards for benchmarking, ProxySQL, and Readyset internals (perf_debugging.json), which you do not need for day-to-day monitoring. I also skipped Specific Query (query_specific.json), because some of its panels did not work in my test.


The Prometheus metrics only have the query ID, not the query text. This is why the Query Metrics dashboard needs the DS_READYSET data source: it takes the query text from SHOW CACHES and SHOW PROXIED QUERIES, and the numbers from the metrics. Readyset also has a verbose query log mode that adds the query text as a label, but that creates a lot more time series.
In my test, the cached query took about 2 µs on average with a shallow cache and 4.5 µs with a deep cache. When the same query was a cache miss and went to MySQL, it took about 97 µs. These are numbers from a small test on my laptop, so your numbers will be different, but you can see the difference right away.
We also want an alert if Readyset is unavailable. PMM creates an up metric for every exporter: it is 1 if PMM can collect the metrics, and 0 if it cannot. Follow these steps to set up the alert:
max by (service_name, node_name) (max_over_time(up{external_group="readyset"}[1m]))
The max_over_time returns 0 only if every collection failed in the last minute, so a single slow scrape will not wake you up at night.
The second alert I recommend is when Readyset cannot reach the database. Readyset checks the upstream database every 10 seconds and sets readyset_upstream_server_up to 0 if it is down. Create a second rule the same way with this query, and leave the no data handling on Normal (if Readyset itself is down, the first rule covers it):
|
1 |
min by (service_name, server) (readyset_upstream_server_up{external_group="readyset"}) |
Of course, I wanted to see them working, so I paused the Readyset container and stopped MySQL. Both alerts fired within about two minutes, and they went back to normal after I started everything again.

If you use deep caches, an alert on readyset_replicator_replication_lag is also a good idea. Just be careful with the threshold: the value is in bytes for PostgreSQL and for MySQL with file-based positions, and in transactions for MySQL with GTID.
Readyset exposes more than 100 metrics, and most of them are about its internals.
If you want to build your own panels or alerts, you can find a short description of each metric in the metric directory of the Readyset source code.
The Readyset dashboards are made for Readyset’s own Grafana, so in PMM, three small things look wrong. The Uptime panel shows an error, because it uses a fixed data source ID. The links at the top of each dashboard list every PMM dashboard. And the rate() graphs look like barcodes, because PMM collects external exporters every 10 seconds, but its Metrics data source has a 1-second scrape interval. This loop downloads the dashboards and fixes all three with sed and jq:
|
1 2 3 4 5 |
> for f in ops query_overview adapter_metrics shallow_caching replication_performance memory evictions; do curl -sL https://raw.githubusercontent.com/readysettech/readyset/stable-261022/build/docker/grafana/dashboards/$f.json \ | sed 's/PC9D4D8333A565E9C/DS_READYSET/' \ | jq '(.. | objects | select(has("targets")) | .interval) = "1m" | .links = []' > $f.json done |
Monitoring Readyset with PMM is even simpler than Valkey/Redis, because Readyset already has a Prometheus endpoint, and there is no exporter to install. The only surprise was the connection check that needs --skip-connection-check. With Readyset’s own dashboards and the two alerts above, you can see how much load Readyset takes off your database, and you will know right away if it stops doing that.
Percona Monitoring and Management is a best-of-breed open source database monitoring solution tool for MySQL, PostgreSQL, MongoDB, and the servers on which they run. It allows you to monitor, manage, and improve the performance of your databases, no matter where they are located or deployed.
Resources
RELATED POSTS