As with many applications, there's an exporter for memcached.

To demonstrate, let's get a memcached up and running using Docker so you don't have to compile it by hand:

docker run -p11211:11211 -d memcached:1.5.16

You can see the stats it provides with:

echo stats | nc localhost 11211

To get this into a format usable by Prometheus, you can use the memcached_exporter:

wget https://github.com/prometheus/memcached_exporter/releases/download/v0.5.0/memcached_exporter-0.5.0.linux-amd64.tar.gz tar -xzf memcached_exporter-0.5.0.linux-amd64.tar.gz cd memcached_exporter-0.5.0.linux-amd64/ ./memcached_exporter

Which will expose metrics on http://localhost:9150/metrics. Now you can run a Prometheus to scrape this:

wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz tar -xzf prometheus-2.10.0.linux-amd64.tar.gz cd prometheus-* cat <<'EOF' > prometheus.yml global: scrape_interval: 10s evaluation_interval: 10s scrape_configs: - job_name: 'memcached' static_configs: - targets: - localhost:9150 EOF ./prometheus &

From there you can go to http://localhost:9090/graph and plot expressions such as rate(memcached_commands_total[1m]) to get the query rate.

Have questions about monitoring applications with Prometheus? Contact us.