{"componentChunkName":"component---src-components-mark-down-block-js","path":"/docs/cli-using/","result":{"data":{"markdownRemark":{"html":"<h2 id=\"using-the-command-line-interface-cli\" style=\"position:relative;\"><a href=\"#using-the-command-line-interface-cli\" aria-label=\"using the command line interface cli permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Using The Command Line Interface (CLI)</h2>\n<p>As soon as you <a href=\"/docs/downloading\">download</a> AppScope, you can start using the CLI to explore and gain insight into application behavior. No installation or configuration is required.</p>\n<p>The CLI provides a rich set of capabilities for capturing and managing data from single applications. Data is captured in the local filesystem by default, and you can <a href=\"#invoke-config\">specify</a> a different destination.</p>\n<p>By default, the AppScope CLI redacts binary data from console output. Although in most situations, the default behaviors of the AppScope CLI and library are the same, they differ for binary data: it's omitted in the CLI, and allowed when using the library. To change this, use the <code>allowbinary=true</code> flag. The equivalent environment variable is <code>SCOPE_ALLOW_BINARY_CONSOLE</code>. In the config file, <code>allowbinary</code> is an attribute of the <code>console</code> watch type for events.</p>\n<p>To learn more, see the <a href=\"/docs/cli-reference\">CLI Reference</a>, and/or run <code>scope --help</code> or <code>scope -h</code>. And check out the <a href=\"/docs/examples-use-cases\">Further Examples</a>, which include both CLI and library use cases.</p>\n<h3 id=\"cli-basics\" style=\"position:relative;\"><a href=\"#cli-basics\" aria-label=\"cli basics permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>CLI Basics</h3>\n<p>The basic AppScope CLI command is <code>scope</code>. The following examples progress from simple to more involved. Scoping a running process gets <a href=\"#scope-running\">its own section</a>. The final section explains how to scope an app that generates a large data set, and then <a href=\"#explore-captured\">explore</a> that data.</p>\n<h4 id=\"scope-a-new-process\" style=\"position:relative;\"><a href=\"#scope-a-new-process\" aria-label=\"scope a new process permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Scope a New Process</h4>\n<p>Try scoping some well-known Linux commands, and view the results:</p>\n<pre><code>scope top\n</code></pre>\n<pre><code>scope ls -al\n</code></pre>\n<pre><code>scope curl https://www.google.com\n</code></pre>\n<p>When scoping browsers, we use the <code>--no-sandbox</code> option because virtually all modern browsers incorporate the <a href=\"https://web.dev/browser-sandbox/\">sandbox</a> security mechanism, and some sandbox implementations can interact with AppScope in ways that cause the browser to hang, or not to start.</p>\n<pre><code>scope firefox --no-sandbox\n</code></pre>\n<h4 id=\"scope-a-series-of-shell-commands\" style=\"position:relative;\"><a href=\"#scope-a-series-of-shell-commands\" aria-label=\"scope a series of shell commands permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Scope a Series of Shell Commands</h4>\n<p>In the shell that you open in this example, every command you run will be scoped:</p>\n<pre><code>scope bash\n</code></pre>\n<p>To release a process like <code>scope bash</code> above, <code>exit</code> the process in the shell. If you do this with the bash shell itself, you won't be able to <code>scope bash</code> again in the same terminal session.</p>\n<h4 id=\"scope-cribl-stream\" style=\"position:relative;\"><a href=\"#scope-cribl-stream\" aria-label=\"scope cribl stream permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Scope <a href=\"https://cribl.io/download/\">Cribl Stream</a></h4>\n<p>See what AppScope shows Cribl Stream doing:</p>\n<p><code>scope $CRIBL_HOME/bin/cribl server</code></p>\n<p>You can take the idea of using AppScope to reveal application behavior <a href=\"https://cribl.io/blog/appscope-1-0-changing-the-game-for-infosec-part-2/\">much further</a>. </p>\n<h4 id=\"use-a-custom-http-header-to-mark-your-data\" style=\"position:relative;\"><a href=\"#use-a-custom-http-header-to-mark-your-data\" aria-label=\"use a custom http header to mark your data permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Use a Custom HTTP Header to Mark Your Data</h4>\n<p>When scoping apps that make HTTP requests, you can add the <code>X-Appscope</code> header, setting its content to the string of your choice. </p>\n<p>Here's a trivial example of how this feature might be useful:</p>\n<p>Suppose you want to scope HTTP requests to a weather forecast service, looking at many different cities, but labeling the data by country.</p>\n<p>You could use the <code>X-Appscope</code> header to do your labeling:</p>\n<pre><code>scope curl --header \"X-Appscope: Canada\" wttr.in/calgary\nscope curl --header \"X-Appscope: Canada\" wttr.in/ottawa\n...\n\nscope curl --header \"X-Appscope: Brazil\" wttr.in/recife\nscope curl --header \"X-Appscope: Brazil\" wttr.in/riodejaneiro\n...\n</code></pre>\n<p>In the resulting AppScope events, the <code>body</code> > <code>data</code> element would include an <code>\"x-appscope\"</code> field whose value would be the country named in the request's <code>X-Appscope</code> header.</p>\n<p><span id=\"invoke-config\"></span></p>\n<h4 id=\"invoke-a-config-file-while-scoping-a-new-process\" style=\"position:relative;\"><a href=\"#invoke-a-config-file-while-scoping-a-new-process\" aria-label=\"invoke a config file while scoping a new process permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Invoke a Config File While Scoping a New Process</h4>\n<p>Why create a custom configuration file? One popular reason is to change the destination to which AppScope sends captured data to someplace other than the local filesystem (the default). To learn about the possibilities, read the comments in the default <a href=\"/docs/config-file\">Configuration File</a>.</p>\n<p>This example scopes the <code>echo</code> command while invoking a configuration file named <code>cloud.yml</code>:</p>\n<pre><code>scope run -u cloud.yml -- echo foo\n</code></pre>\n<p><span id=\"scope-running\"></span></p>\n<h3 id=\"scoping-a-running-process\" style=\"position:relative;\"><a href=\"#scoping-a-running-process\" aria-label=\"scoping a running process permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Scoping a Running Process</h3>\n<p>You <a href=\"/docs/cli-reference#attach\">attach</a> AppScope to a process using either a process ID or a process name.</p>\n<h4 id=\"attaching-by-process-id\" style=\"position:relative;\"><a href=\"#attaching-by-process-id\" aria-label=\"attaching by process id permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Attaching by Process ID</h4>\n<p>In this example, we'll start by grepping for process IDs of <code>cribl</code> (Cribl Stream) processes: </p>\n<pre><code>$ ps -ef | grep cribl\nubuntu    1820     1  1 21:03 pts/4    00:00:02 /home/ubuntu/someusername/cribl/4.0.3/m/cribl/bin/cribl server\nubuntu    1838  1820  4 21:03 pts/4    00:00:07 /home/ubuntu/someusername/cribl/4.0.3/m/cribl/bin/cribl /home/ubuntu/someusername/cribl/4.0.3/m/cribl/bin/cribl.js server -r CONFIG_HELPER\nubuntu    1925 30025  0 21:06 pts/3    00:00:00 grep --color=auto cribl\n</code></pre>\n<p>Then, we'll attach to a process of interest:</p>\n<pre><code>ubuntu@ip-127-0-0-1:~/someusername/appscope3$ sudo scope attach 1820\n</code></pre>\n<h4 id=\"attaching-by-process-name\" style=\"position:relative;\"><a href=\"#attaching-by-process-name\" aria-label=\"attaching by process name permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Attaching by Process Name</h4>\n<p>In this example, we try to attach to a Cribl Stream process by its name, which will be <code>cribl</code>. Since there's more than one process, AppScope lists them and prompts us to choose one:</p>\n<pre><code>$ sudo scope attach cribl\nFound multiple processes matching that name...\nID  PID   USER    SCOPED  COMMAND\n1   1820  ubuntu  false   /home/ubuntu/someusername/cribl/4.0.3/m/cribl/bin/cribl server\n2   1838  ubuntu  false   /home/ubuntu/someusername/cribl/4.0.3/m/cribl/bin/cribl /home/ubuntu/someusername/cribl/4.0.3/m/cribl/bin/cribl.js server -r CONFIG_HELPER\nSelect an ID from the list:\n2\nWARNING: Session history will be stored in /home/ubuntu/.scope/history and owned by root\nAttaching to process 1838\n</code></pre>\n<h4 id=\"detaching-from-processes\" style=\"position:relative;\"><a href=\"#detaching-from-processes\" aria-label=\"detaching from processes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Detaching from Processes</h4>\n<p>You can also <a href=\"/docs/cli-reference#detach\">detach</a> AppScope from a process.</p>\n<p>Furthermore, if you want to undo the effects of the <code>scope attach</code>, <code>scope start</code>, and/or <code>scope service</code> commands, run the <code>scope stop</code> <a href=\"/docs/cli-reference#stop\">command</a>. This runs <code>scope detach --all</code>, removes the rules file from the system, and removes <code>scope</code> from service configurations.</p>\n<p>When you detach from a process, AppScope:</p>\n<ul>\n<li>Stops emitting events and metrics for the process.</li>\n<li>Closes relevant connections.</li>\n<li>Removes its interpositions from the process' functions, and/or unhooks from the process' functions, as relevant.</li>\n</ul>\n<p>What AppScope does <strong>not</strong> do is unload its library.</p>\n<h4 id=\"more-about-scoping-running-processes\" style=\"position:relative;\"><a href=\"#more-about-scoping-running-processes\" aria-label=\"more about scoping running processes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>More About Scoping Running Processes</h4>\n<p>To attach AppScope to a running process:</p>\n<ol>\n<li>You must run <code>scope</code> as root, or with <code>sudo</code>.</li>\n<li>If you attach to a shell, AppScope does not automatically scope its child processes. <!-- TBD correct? ask Donn --></li>\n<li>You can attach to a process that is executing within a container context by running <code>scope attach</code> <strong>inside</strong> that container or from the host.</li>\n</ol>\n<p>When you attach AppScope to a process, its child processes are not automatically scoped.</p>\n<p>You cannot attach to a static executable's process.</p>\n<p>No HTTP/1.1 events and headers are emitted when AppScope attaches to a Go process that uses the <code>azure-sdk-for-go</code> package. <!-- TBD still true? ask John  --></p>\n<p>No events are emitted from files or sockets that exist before AppScope attaches to a process.</p>\n<ul>\n<li>\n<p>AppScope events will be produced only for file or socket descriptors opened <strong>after</strong> AppScope is attached.</p>\n<ul>\n<li>For example, suppose a process opens a socket descriptor before AppScope is attached. Subsequent sends and receives on this socket will not produce AppScope events.</li>\n</ul>\n</li>\n</ul>\n<p><span id=\"payloads\"></span></p>\n<h3 id=\"working-with-http-payloads\" style=\"position:relative;\"><a href=\"#working-with-http-payloads\" aria-label=\"working with http payloads permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Working with HTTP Payloads</h3>\n<p>When you scope an app that produces HTTP traffic, you can capture the payloads using the <code>-p</code> or <code>--payloads</code> option. This is AppScope's  <strong>payloads</strong> feature (see the <code>payload</code> section in the AppScope <a href=\"/docs/config\">config file</a>), which is disabled by default, because it can create large amounts of data, and because it captures payloads unencrypted.</p>\n<p>When the <strong>payloads</strong> feature is enabled, setting <code>SCOPE_PAYLOAD_TO_DISK</code> to <code>true</code> guarantees that AppScope will write payloads to the local directory specified in <code>SCOPE_PAYLOAD_DIR</code>.</p>\n<p><span id=\"explore-captured\"></span></p>\n<h3 id=\"exploring-captured-data\" style=\"position:relative;\"><a href=\"#exploring-captured-data\" aria-label=\"exploring captured data permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Exploring Captured Data</h3>\n<p>You can scope apps that generate large data sets, and then use AppScope CLI subcommands and options to monitor and visualize the data. The following extended example introduces this technique.</p>\n<p>Start by scoping the <code>ps</code> command:</p>\n<pre><code>scope run -- ps -ef\n</code></pre>\n<p>Show last session's captured metrics with <code>scope metrics</code>:</p>\n<pre><code>NAME             VALUE      TYPE     UNIT           PID     TAGS\nproc.start       1          Count    process        5470    args: ps -ef,gid: 0,groupname: root,host: ip-10-8-107-15…\nproc.cpu         60898      Count    microsecond    5470    host: my_hostname,proc: ps\nproc.cpu_perc    0.60898    Gauge    percent        5470    host: my_hostname,proc: ps\nproc.mem         67512      Gauge    kibibyte       5470    host: my_hostname,proc: ps\nproc.thread      2          Gauge    thread         5470    host: my_hostname,proc: ps\nproc.fd          6          Gauge    file           5470    host: my_hostname,proc: ps\nproc.child       1          Gauge    process        5470    host: my_hostname,proc: ps\nfs.read          379832     Count    byte           5470    host: my_hostname,proc: ps,summary: true\nnet.rx           401        Count    byte           5470    class: unix_tcp,host: my_hostname,proc: ps,summary: …\nnet.tx           361        Count    byte           5470    class: unix_tcp,host: my_hostname,proc: ps,summary: …\nfs.seek          150        Count    operation      5470    host: my_hostname,proc: ps,summary: true\nfs.stat          136        Count    operation      5470    host: my_hostname,proc: ps,summary: true\n...\n</code></pre>\n<p>Plot a chart of last session's <code>proc.cpu</code> metric with <code>scope metrics -m proc.cpu -g</code>:</p>\n<pre><code> 80000 ┼                   ╭╮\n 76000 ┤                   ││\n 72000 ┤                   ││\n 68000 ┤                   ││\n 64000 ┤                   ││\n 60000 ┤                   ││\n 56000 ┤                   ││\n 52000 ┤                   ││                                     ╭╮                               ╭╮   ╭─\n 48000 ┤                   ││                                     ││                               ││   │\n 44000 ┤                   ││                                     ││                               ││   │\n 40000 ┤ ╭╮                ││                                     ││          ╭╮                ╭─╮││ ╭╮│\n 36000 ┤ ││                ││                                     ││          ││                │ │││ │││\n 32000 ┤ ││╭╮              ││          ╭╮    ╭╮ ╭╮                ││ ╭╮       ││ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮╭╯ ╰╯╰╮│╰╯\n 28000 ┤ ││││              ││          ││    ││ ││                ││ ││       ││ ││ ││ ││ ││ │││     ││\n 24000 ┤ ││││              ││          ││    ││ ││                ││ ││       ││ ││ ││ ││ ││ │││     ││\n 20000 ┤╭╯││╰╮ ╭╮╭╮ ╭──╮╭╮ ││ ╭╮ ╭╮ ╭╮ ││ ╭──╯│ ││╭─╮ ╭╮    ╭───╮ ││╭╯│ ╭╮ ╭╮ │╰╮││ ││ ││ ││ │╰╯     ╰╯\n 16000 ┤│ ││ │ ││││ │  │││ ││ ││ ││ ││ ││ │   │ │││ │ ││    │   │ │││ │ ││ ││ │ │││ ││ ││ ││ │\n 12000 ┤│ ╰╯ ╰─╯╰╯╰─╯  ╰╯│╭╯╰─╯╰─╯│╭╯╰─╯╰─╯   ╰─╯╰╯ ╰─╯╰────╯   │╭╯╰╯ │╭╯╰─╯╰─╯ ╰╯╰─╯│╭╯╰─╯╰─╯\n  8000 ┤│                ││       ││                            ││    ││             ││\n  4000 ┤│                ││       ││                            ││    ││             ││\n     0 ┼╯                ╰╯       ╰╯                            ╰╯    ╰╯             ╰╯\n</code></pre>\n<p>Display the last session's captured events with <code>scope events</code>:</p>\n<pre><code>[EkA1] Jul 12 02:11:15 ps fs fs.open file:/proc/17721/stat\n[OrA1] Jul 12 02:11:15 ps fs fs.close file:/proc/17721/stat file_read_bytes:158 file_read_ops:1 file_write_bytes:0 file_write_ops:0\n[xAA1] Jul 12 02:11:15 ps fs fs.open file:/proc/17721/status\n[LHA1] Jul 12 02:11:15 ps fs fs.close file:/proc/17721/status file_read_bytes:952 file_read_ops:1 file_write_bytes:0 file_write_ops:0\n[vQA1] Jul 12 02:11:15 ps fs fs.open file:/proc/17721/cmdline\n[IXA1] Jul 12 02:11:15 ps fs fs.close file:/proc/17721/cmdline file_read_bytes:0 file_read_ops:1 file_write_bytes:0 file_write_ops:0\n[s6B1] Jul 12 02:11:15 ps fs fs.open file:/proc/17758/stat\n...\n</code></pre>\n<p>Now scope a command which produces HTTP and other kinds of events:</p>\n<pre><code>scope run -- curl https://www.google.com\n</code></pre>\n<p>Filter out everything but <code>http</code> from the last session's events, with <code>scope events -t http</code>:</p>\n<pre><code>[vL1] Jul 12 02:14:07 curl http http.req http_host:www.google.com http_method:GET http_scheme:https http_target:/\n[PU1] Jul 12 02:14:08 curl http http.resp http_host:www.google.com http_method:GET http_target:/\n</code></pre>\n<p>View the history of the current AppScope session with <code>scope history</code>:</p>\n<pre><code>Displaying last 20 sessions\nID  COMMAND CMDLINE                     PID     AGE     DURATION    TOTAL EVENTS\n4   ps      ps -ef                      5464    3m6s    12ms        788\n5   curl    curl https://www.google.…   5492    14s     141ms       20\n</code></pre>\n<p>Scope another command which will produce a variety of events ...</p>\n<pre><code># scope run -- apt update\nHit:1 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic InRelease\nGet:2 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                      \nGet:3 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                    \nHit:4 https://download.docker.com/linux/ubuntu bionic InRelease                                                                                \nGet:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                                    \nHit:6 https://baltocdn.com/helm/stable/debian all InRelease\n...\n</code></pre>\n<p>... Then, show only the last 10 events of sourcetype <code>console</code>, sorted in ascending order by timestamp:</p>\n<pre><code># scope events --sort _time --sourcetype console --last 10 --reverse\n[g2Wg] Jul 12 02:14:49 apt console stdout message:\"                                  0% [Working] 0% [16 Packages store 0 B]                …\"\n[zvUe] Jul 12 02:14:49 apt console stdout message:\"                                  0% [Working] 0% [16 Packages store 0 B]                …\"\n[ucRe] Jul 12 02:14:50 find console stdout message:/var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_bionic-security_universe_binary-amd6…\n[zkRe] Jul 12 02:14:50 dirname console stdout message:/var/lib/update-notifier\n[I0Se] Jul 12 02:14:50 mktemp console stdout message:/var/lib/update-notifier/tmp.ut1sgTEuvb\n[gmUg] Jul 12 02:14:54 python3 console stdout message:\"39 updates can be applied immediately. To see these additional updates run: apt list …\"\n[gZ7h] Jul 12 02:14:54 apt console stdout message:\"Reading package lists... 0%\"\n[1a2i] Jul 12 02:14:54 apt console stdout message:\"Reading package lists... 0%  Reading package lists... 0%  Reading package lists... 3%  Re…\"\n[cp1i] Jul 12 02:14:54 apt console stdout message:\"Reading package lists... 0%  Reading package lists... 0%  Reading package lists... 3%  Re…\"\n[QU2i] Jul 12 02:14:56 apt console stderr message:\"W: An error occurred during the signature verification. The repository is not updated and…\"\n</code></pre>\n<p>Scope a command which reads and writes over the network:</p>\n<pre><code># scope curl wttr.in    \nWeather report: Portland, Oregon, United States\n\n      \\   /     Sunny\n       .-.      93 °F          \n    ― (   ) ―   ↓ 6 mph        \n       `-’      9 mi           \n      /   \\     0.0 in         \n                                                       ┌─────────────┐                                                       \n┌──────────────────────────────┬───────────────────────┤  Mon 11 Jul ├───────────────────────┬──────────────────────────────┐\n│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │\n├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤\n│     \\   /     Sunny          │     \\   /     Sunny          │     \\   /     Sunny          │     \\   /     Clear          │\n│      .-.      68 °F          │      .-.      89 °F          │      .-.      +95(93) °F     │      .-.      78 °F          │\n│   ― (   ) ―   ↓ 5-6 mph      │   ― (   ) ―   ↘ 6-7 mph      │   ― (   ) ―   ↘ 10-11 mph    │   ― (   ) ―   ↘ 8-15 mph     │\n│      `-’      6 mi           │      `-’      6 mi           │      `-’      6 mi           │      `-’      6 mi           │\n│     /   \\     0.0 in | 0%    │     /   \\     0.0 in | 0%    │     /   \\     0.0 in | 0%    │     /   \\     0.0 in | 0%    │\n└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘       \n...\n</code></pre>\n<p>Then, show only events containing the string <code>net_bytes</code>, and display the fields <code>net_bytes_sent</code> and <code>net_bytes_recv</code>, with their values:</p>\n<pre><code># scope events --fields net_bytes_sent,net_bytes_recv --match net_bytes\n[e91] Jul 12 02:15:41 curl net net.close net_bytes_sent:71 net_bytes_recv:8773\n</code></pre>","frontmatter":{"title":"Using the CLI"}}},"pageContext":{"slug":"/cli-using/","id":"a69e5f8a-ca57-5420-b865-2ee7985e1caa"}},"staticQueryHashes":["2787008656","306729481","625673991","640077088"]}