- Home
- About Pixie
- Installing Pixie
- Using Pixie
- Tutorials
- Reference
Service performance issues often turn out to be the result of slow database queries. With Pixie, you can easily monitor the performance of your database requests to ensure they do not impact service health.
MySQL requests are featured in this tutorial, but Pixie can trace a number of different database protocols including Cassandra, PostgreSQL, and Redis. See the full list here.
This tutorial will demonstrate how to use Pixie to monitor MySQL:
You will need a Kubernetes cluster with Pixie installed. If you do not have a cluster, you can create a minikube cluster and install Pixie using one of our install guides.
You will need to install the demo microservices application, using Pixie's CLI:
- Install the Pixie CLI.
- Run
px demo deploy px-sock-shop
to install Weavework's Sock Shop demo app.- Run
kubectl get pods -n px-sock-shop
to make sure all pods are ready before proceeding. The demo app can take up to 5 minutes to deploy.
To see MySQL latency, error, and throughput rate for all pods in your cluster, we’ll use the px/mysql_stats
script:
px/mysql_stats
from the script
drop-down menu.This script shows latency, error and throughput over time for all MySQL requests in the cluster.
Let’s use the optional
pod
script input argument to filter to a particular pod.
pod
argument, type px-sock-shop/catalogue
, and press Enter to re-run the script.The graph should update to show stats just for the requests made to/from the
catalogue
pod.
pod
value by selecting the drop-down arrow and pressing Enter.Pixie can automatically cluster your SQL queries so that you can analyze similar queries as a single group.
For example, the following two queries:
SELECT * FROM Socks WHERE Socks.Color ='Green'
SELECT * FROM Socks WHERE Socks.Color ='Blue'
would be clustered together into the normalized query:
SELECT * FROM Socks WHERE Socks.Color =?
A normalized query means that constants, such as a sock color, have been replaced with placeholders.
Let's see this feature in action for our demo application:
px/sql_queries
from the script
drop-down menu.This live view calculates the latency, error, and throughput over time for each normalized SQL query.
Let's examine one of the normalized SQL queries.
For longer queries, it's often easier to view the data in JSON form.
>
that appears to expand the row.Inspect the query and you'll see that the
sock_id
values have been replaced with the?
placeholder.
>
to close the row.Next, let's view latency, error and throughput for the constants passed to this normalized query.
>
, click the actual query text (SELECT sock.sock_id AS...
) for the same row.This script shows latency, error, and throughput for each individual parameter for the given normalized SQL query.
The Summary table shows the individual parameters passed to
sock_id
in the normalized query.
Pixie captures all network traffic that passes through your cluster (it supports both server and client-side tracing). For supported protocols, this traffic is parsed into messages that are paired with their responses.
Let's inspect the most recent MySQL requests flowing through your cluster, including the full request and response bodies.
px/mysql_data
from the script
drop-down menu at the top of the page.This script shows the most recent MySQL requests flowing through your cluster, including the full request and response bodies.
Pixie is able capture any request that flows through the cluster, as long as at least one endpoint is within the cluster.
For requests with longer message bodies, it's often easier to view the data in JSON form.
Click on a table row to see the row data in JSON format. Scroll through the JSON data to find the resp_body
key.
Click the table row again to collapse the JSON view.
Scroll to the last column of the table to see latency data for the individual requests.
Click on the LATENCY
column title to sort the table by descending latency.
This tutorial demonstrated a few of Pixie's community scripts. For more insight into your database queries, check out the following scripts.