EXPAND ALL
  • Home

Using the CLI

PxL scripts can be run in Pixie's web based Live UI or CLI tool. To learn about the Live UI, check out this tutorial.

Setup

Pixie needs to be installed on your Kubernetes cluster. If it is not already installed, please consult our install guides.

Pixie's Open Source Scripts

Run the following command to list all of Pixie's open source scripts.

px run -l # list pre-built scripts

Running your first PxL Script

You can run any PxL script using:

px run <script_name> # run a pxl script

Let's try run Pixie'spx/namespaces script:

px run px/namespaces # run the pre-built px/namespace script
Output of the px/namespaces script in the CLI.

This script outputs two tables. The first table lists the namespaces on the current cluster and their pod and service counts. The second table lists the high-level resource consumption by namespace.

Selecting the Cluster

If Pixie is installed on multiple clusters, Pixie will use the cluster in the current kubectl context. To specify a different cluster, pass the cluster_ID with the -c flag.

px get viziers # display cluster IDs for all clusters with Pixie installed
px run <script_name> -c <cluster_ID> # run a script on a specific cluster

Passing Arguments to a Script

To show a the input arguments for any PxL script:

px run <script_name> -- --help # show the arguments for a script.
px run <script_name> -- --arg_name val # pass arguments to a script

Pixie's px/namespace script gives a top-level summary of the pods and services for a specific namespace. This script takes two arguments. If you don't provide arguments, the script will output an empty table (Pixie will soon enforce required arguments).

px run px/namespace -- --help # show the arguments for a script.
px run px/namespace -- --namespace pl # pl is the namespace that Pixie is installed to (by default)
Output of the px/namespace script in the CLI.

This script outputs three tables and the output is difficult to view in the terminal.

Different Ways of Viewing a Script's Output

For scripts with verbose output (like the px/namespace script you ran above), we recommend the following ways of interacting with the output.

Output in a Different Format

Pixie supports json and csv output using the -o flag, making it easy to consume the script's output using other CLI tools.

px run <script_name> -o csv > table_data.csv # output in csv format and redirect to a file
px run <script_name> -o json | jq # output in json format and pipe to jq

Use the Live CLI

The Live CLI provides interactive views for output tables. To run the Live CLI, use px live instead of px run.

px live <script_name> # run a script using the Live CLI
px live px/namespace -- --namespace pl # run Pixie's px/namespace script

The px/namespace script outputs three tables, one per tab at the bottom left of the terminal window.

Output of the px/namespace script in the Live CLI.

You can interact with the Live CLI output:

  • To switch between the output tables, use the number keys (or a mouse click) to select the table tabs listed at the bottom left of the terminal.
  • To sort a column, click on a column title.
  • To navigate the table cells, use your arrow keys (or click with your mouse).
  • To expand a truncated table cell, use ctrl+enter or ctrl+click.
  • To display/hide the script, use ctrl+v.
  • To run a different PxL script, use ctrl+k.

Switch to the Live View

PxL has support for building visualizations (graphs, charts, etc), which can be viewed in Pixie's Live UI. A link to the Live UI view of a particular script is included in each script output in the CLI.

The Live UI link appears at the bottom of the output of any px run <script_name> output.

Linking to the Live UI view of a script from the CLI.

And at the top of the Live CLI output.

Linking to the Live UI view of a script from the Live CLI.

Running a Custom PxL Script

To learn how to write custom PxL scripts, check out this tutorial.

To run your own PxL script using the CLI, use the -f flag to provide the script's filename.

px run -f <script.pxl> # Use Pixie's CLI to run the pxl script with the provided filename
px live -f <script.pxl> # Use Pixie's Live CLI to run the pxl script with the provided filename

Debugging Pixie using the CLI

Use the following commands to show the status of Pixie on your cluster:

px get viziers # shows the registered K8s clusters that are running Pixie and thier current status
px get pems # shows the current status of the Pixie Edge Modules. Also, usable as `px run px/agent_status`
px collect-logs # collect Pixie logs on the cluster

To view all available Pixie CLI commands:

px --help
This site uses cookies to provide you with a better user experience. By using Pixie, you consent to our use of cookies.