This episode equips you to see inside the cluster: Prometheus metrics from VTGate, VTTablet, and Topology Service, reading logs and slow queries, tracing queries across components, and diagnosing shards and replication with vtctlclient.

You won't dare change anything in production without being able to see what's happening. Episode 7 builds your observability capability: collecting metrics, reading logs, tracing queries, and diagnosing problems. In the distributed world of Vitess, debugging without observability is like repairing an airplane blindfolded.
Episode 7 roadmap: metrics and monitoring with Prometheus, log patterns and slow queries, query tracing, then diagnosing shards and replication with vtctlclient. By the end, you'll have a debugging toolkit you can use immediately.
Every Vitess component exposes metrics in Prometheus format at the /metrics endpoint. The most important ones to monitor:
The easiest way to see metrics directly is to curl the endpoint (via port-forward):
kubectl port-forward -n vitess svc/vtgate 15001:15001 &
curl -s http://localhost:15001/metrics | grep vtgatecurl -s http://localhost:15001/metrics displays all VTGate metrics. In production, you don't need to curl manually — Prometheus scrapes this endpoint automatically.
For a quick lab setup, install the kube-prometheus-stack:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/kube-prometheus-stackWith the bundled Grafana, you can build dashboards from VTGate and VTTablet metrics. There are Vitess community dashboards you can import, but building your own from scratch is also great practice.
Vitess logs are structured and carry context: query identity, source tablet, and duration. Patterns you'll often look for:
deadline exceeded or primary not serving.To find slow queries, Vitess provides the query log feature at VTGate and a slow query log at the MySQL level. At the MySQL level, enable the slow query log through tablet configuration. A practical alternative: query the sys database tables for statistics:
SELECT db, query, exec_count, avg_latency
FROM sys.statement_analysis
ORDER BY avg_latency DESC
LIMIT 10The SELECT ... FROM sys.statement_analysis command lists the slowest queries by average latency — a great starting point for performance investigation.
Info
The key to Vitess debugging: always start from VTGate. VTGate logs and metrics give you the big picture (which shard is slow), then you drill down to VTTablet and the specific shard's MySQL. Diving straight into per-shard MySQL is often confusing because you don't know which shard is the problem.
One query passes through VTGate, VTTablet, and MySQL — to understand where time is being spent, you need distributed tracing. Vitess supports OpenTracing/Jaeger to follow a single query through every component.
To enable it, configure tracing in VTGate and VTTablet. In the lab, run Jaeger via Docker:
docker run -d --name jaeger -p 16686:16686 -p 6831:6831/udp jaegertracing/all-in-oneThen set the tracing env variables in the VTGate/VTTablet deployments and open the Jaeger UI at http://localhost:16686 to see a flame graph of each query. Tracing is the most powerful tool for finding bottlenecks that aren't visible in aggregate numbers.
vtctlclient is Vitess's Swiss Army knife. For diagnosis, the most commonly used commands:
vtctlclient ListShardHealth
vtctlclient ListAllTablets
vtctlclient GetTablet <tablet-alias>
vtctlclient GetShardReplication <keyspace/shard>ListShardHealth displays the health status of each shard.GetTablet gives details for one tablet: type, address, and status.GetShardReplication shows the replication map — which tablets are members of a shard.To see a tablet's replication position, use SQL via the mysql client to that tablet:
SHOW REPLICA STATUSSHOW REPLICA STATUS shows columns like Seconds_Behind_Source — the replication lag number that's the primary health indicator. If this number keeps growing, the primary is overwhelmed or the network between tablets has issues.
In this episode 7 you were equipped to see inside the Vitess cluster: Prometheus metrics from VTGate and VTTablet, log patterns and slow queries, distributed tracing with Jaeger, and diagnosing shards and replication with vtctlclient and SQL.
Key takeaways:
/metrics.ListShardHealth, GetTablet, and GetShardReplication are core diagnostic tools.In the next episode, episode 8, we design schemas: schema management and vindexes — configuring vindexes for routing, the difference between global and local vindexes, and designing schemas for sharded and unsharded tables. See you there!