{"componentChunkName":"component---src-components-mark-down-block-js","path":"/docs/data-routing/","result":{"data":{"markdownRemark":{"html":"<h2 id=\"data-routing\" style=\"position:relative;\"><a href=\"#data-routing\" aria-label=\"data routing 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>Data Routing</h2>\n<p>AppScope gives you multiple ways to route data. The basic operations are:</p>\n<ul>\n<li>Routing <a href=\"#routing-to-edge\">both events and metrics</a> to <a href=\"https://docs.cribl.io/edge/\">Cribl Edge</a>.</li>\n<li>Routing <a href=\"#routing-to-cloud\">both events and metrics</a> to <a href=\"https://docs.cribl.io/stream\">Cribl Stream</a>.</li>\n<li>Routing <a href=\"#routing-events\">events</a> to a file, local unix socket, network destination, or Cribl Edge.</li>\n<li>Routing <a href=\"#routing-metrics\">metrics</a> to a file, local unix socket, network destination, or Cribl Edge.</li>\n</ul>\n<p>For each of these operations, the CLI has command-line options, the config file has settings, and the AppScope library has environment variables.</p>\n<p>If you plan to use the config file, do take time to <a href=\"/docs/config-file\">read it all the way through</a> - then this page will make more sense!</p>\n<p>If you want to run Cribl Edge and AppScope in a container, and/or scope apps that are running in containers, see <a href=\"#container-with-edge\">these</a> instructions.</p>\n<h3 id=\"routing-to-edge\" style=\"position:relative;\"><a href=\"#routing-to-edge\" aria-label=\"routing to edge 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>Routing to Cribl Edge</h3>\n<p>In a single operation, you can route both events and metrics to Cribl Edge. </p>\n<h4 id=\"routing-to-edge-with-the-cli\" style=\"position:relative;\"><a href=\"#routing-to-edge-with-the-cli\" aria-label=\"routing to edge with the 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>Routing to Edge with the CLI</h4>\n<p>Use the <code>-c</code> or <code>--cribldest</code> option. You need this option because, by default, the CLI routes data to the local filesystem. For example:</p>\n<pre><code>scope run -c edge -- curl https://wttr.in/94105\n</code></pre>\n<p>This usage works with <code>scope run</code>, <code>scope attach</code>, <code>scope watch</code>, <code>scope k8s</code>, and <code>scope service</code>. It does <strong>not</strong> work with <code>scope metrics</code>, where the <code>-c</code> option stands for <code>--cols</code>, telling the CLI to output data in columns instead of rows.</p>\n<h4 id=\"routing-to-edge-with-the-appscope-library\" style=\"position:relative;\"><a href=\"#routing-to-edge-with-the-appscope-library\" aria-label=\"routing to edge with the appscope library 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>Routing to Edge with the AppScope Library</h4>\n<p>Use the <code>SCOPE_CRIBL</code> environment variable to define a unix socket connection to Cribl Edge. For example:</p>\n<pre><code>LD_PRELOAD=./libscope.so SCOPE_CRIBL=edge ls -al\n</code></pre>\n<h4 id=\"routing-to-edge-with-the-config-file\" style=\"position:relative;\"><a href=\"#routing-to-edge-with-the-config-file\" aria-label=\"routing to edge with the config file 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>Routing to Edge with the Config File</h4>\n<p>Complete these steps, paying particular attention to the sub-elements of <code>cribl > transport</code>, which is where you specify routing:</p>\n<ul>\n<li>Verify that <code>cribl > enable</code> is set to <code>true</code>, which enables the <code>cribl</code> backend. (This is the default setting.)</li>\n<li>To route data to Cribl Edge, set <code>cribl > transport > type</code> to <code>edge</code>. (This is the default value.)</li>\n</ul>\n<h3 id=\"routing-to-cloud\" style=\"position:relative;\"><a href=\"#routing-to-cloud\" aria-label=\"routing to cloud 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>Routing to Cribl Stream in the Cloud</h3>\n<p>In a single operation, you can route both events and metrics to Cribl Stream in the Cloud, or Cribl.Cloud for short.</p>\n<h4 id=\"routing-to-criblcloud-with-the-cli\" style=\"position:relative;\"><a href=\"#routing-to-criblcloud-with-the-cli\" aria-label=\"routing to criblcloud with the 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>Routing to Cribl.Cloud with the CLI</h4>\n<p>Use the <code>-c</code> or <code>--cribldest</code> option. You need this option because, by default, the CLI routes data to the local filesystem. For example:</p>\n<pre><code>scope run -c tls://127.0.0.1:10090 -- curl https://wttr.in/94105\n</code></pre>\n<p>This usage works with <code>scope run</code>, <code>scope attach</code>, <code>scope watch</code>, <code>scope k8s</code>, and <code>scope service</code>. It does <strong>not</strong> work with <code>scope metrics</code>, where the <code>-c</code> option stands for <code>--cols</code>, telling the CLI to output data in columns instead of rows.</p>\n<h4 id=\"routing-to-criblcloud-with-the-appscope-library\" style=\"position:relative;\"><a href=\"#routing-to-criblcloud-with-the-appscope-library\" aria-label=\"routing to criblcloud with the appscope library 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>Routing to Cribl.Cloud with the AppScope Library</h4>\n<p>Use the <code>SCOPE_CRIBL_CLOUD</code> environment variable to define a TLS-encrypted connection to Cribl.Cloud. Specify a transport type, a host name or IPv4 address, and a port number, for example:</p>\n<pre><code>LD_PRELOAD=./libscope.so SCOPE_CRIBL_CLOUD=tcp://in.main-default-&#x3C;organization>.cribl.cloud:10090 ls -al\n</code></pre>\n<p>As a convenience, when you set <code>SCOPE_CRIBL_CLOUD</code>, AppScope automatically overrides the defaults of three other environment variables, setting them to the values that Cribl.Cloud via TLS requires. That produces these (and a few <a href=\"/docs/cribl-integration#parameter-overrides\">other</a>) settings:</p>\n<ul>\n<li><code>SCOPE_CRIBL_TLS_ENABLE</code> is set to <code>true</code>.</li>\n<li><code>SCOPE_CRIBL_TLS_VALIDATE_SERVER</code> is set to <code>true</code>.</li>\n<li><code>SCOPE_CRIBL_TLS_CA_CERT_PATH</code> is set to the empty string.</li>\n</ul>\n<p>If you prefer an <strong>unencrypted</strong> connection to Cribl.Cloud, use <code>SCOPE_CRIBL</code>, as described <a href=\"/docs/cribl-integration#cloud-unencrypted\">here</a>.</p>\n<h4 id=\"routing-to-criblcloud-with-the-config-file\" style=\"position:relative;\"><a href=\"#routing-to-criblcloud-with-the-config-file\" aria-label=\"routing to criblcloud with the config file 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>Routing to Cribl.Cloud with the Config File</h4>\n<p>Complete these steps, paying particular attention to the sub-elements of <code>cribl > transport</code>, which is where you specify routing:</p>\n<ul>\n<li>Verify that <code>cribl > enable</code> is set to <code>true</code>, which enables the <code>cribl</code> backend. (This is the default setting.)</li>\n<li>To route data to Cribl.Cloud, set <code>cribl > transport > type</code> to <code>tcp</code>. (The default value is <code>edge</code>.)</li>\n<li>Specify desired values for the rest of the <code>cribl > transport</code> sub-elements, namely <code>host</code>, <code>port</code>, and <code>tls</code>.</li>\n</ul>\n<h3 id=\"routing-events\" style=\"position:relative;\"><a href=\"#routing-events\" aria-label=\"routing events 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>Routing Events</h3>\n<p>You can route events independently of metrics.</p>\n<h4 id=\"routing-events-with-the-cli\" style=\"position:relative;\"><a href=\"#routing-events-with-the-cli\" aria-label=\"routing events with the 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>Routing Events with the CLI</h4>\n<p>Use the <code>-e</code> or <code>--eventdest</code> option. For example:</p>\n<pre><code>scope run -e tcp://localhost:9109 -- curl https://wttr.in/94105\n</code></pre>\n<p>The above example sends events in <a href=\"http://ndjson.org/\">ndjson</a>, the CLI's default output format. To send events in StatsD, you would include <code>--metricformat statsd</code> in the command.</p>\n<h4 id=\"routing-events-with-the-appscope-library\" style=\"position:relative;\"><a href=\"#routing-events-with-the-appscope-library\" aria-label=\"routing events with the appscope library 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>Routing Events with the AppScope Library</h4>\n<p>Use the <code>SCOPE_EVENT_DEST</code> environment variable, and set the <code>SCOPE_CRIBL_ENABLE</code> to <code>false</code>.</p>\n<p>For example:</p>\n<pre><code>LD_PRELOAD=./libscope.so SCOPE_CRIBL_ENABLE=false SCOPE_EVENT_DEST=tcp://localhost:9109 curl https://wttr.in/94105\n</code></pre>\n<p>The above example sends events in StatsD, the AppScope library's default output format.</p>\n<h4 id=\"routing-events-with-the-config-file\" style=\"position:relative;\"><a href=\"#routing-events-with-the-config-file\" aria-label=\"routing events with the config file 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>Routing Events with the Config File</h4>\n<p>Complete these steps, paying particular attention to the sub-elements of <code>event > transport</code>, which is where you specify routing:</p>\n<ul>\n<li>Set <code>cribl > enable</code> to <code>false</code> to disable the <code>cribl</code> backend.</li>\n<li>Set <code>event > enable</code> to <code>true</code> to enable the events backend.</li>\n<li>Specify desired values for the rest of the <code>event</code> elements, namely <code>format</code>, <code>watch</code>, and <code>transport</code>.</li>\n</ul>\n<h3 id=\"routing-metrics\" style=\"position:relative;\"><a href=\"#routing-metrics\" aria-label=\"routing metrics 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>Routing Metrics</h3>\n<p>You can route metrics independently of events.</p>\n<h4 id=\"routing-metrics-with-the-cli\" style=\"position:relative;\"><a href=\"#routing-metrics-with-the-cli\" aria-label=\"routing metrics with the 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>Routing Metrics with the CLI</h4>\n<p>Use the <code>-m</code> or <code>--metricdest</code> option. For example:</p>\n<pre><code>scope run -m udp://localhost:8125 -- curl https://wttr.in/94105\n</code></pre>\n<p>The above example sends events in <a href=\"http://ndjson.org/\">ndjson</a>, the CLI's default output format. To send events in StatsD, you would include <code>--metricformat statsd</code> in the command.</p>\n<h4 id=\"routing-events-with-the-appscope-library-1\" style=\"position:relative;\"><a href=\"#routing-events-with-the-appscope-library-1\" aria-label=\"routing events with the appscope library 1 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>Routing Events with the AppScope Library</h4>\n<p>Use the <code>SCOPE_METRIC_DEST</code> environment variable, and set the <code>SCOPE_CRIBL_ENABLE</code> to <code>false</code>.</p>\n<p>For example:</p>\n<pre><code>LD_PRELOAD=./libscope.so SCOPE_CRIBL_ENABLE=false SCOPE_METRIC_DEST=udp://localhost:8125 curl https://wttr.in/94105\n</code></pre>\n<p>The above example sends events in StatsD, the AppScope library's default output format.</p>\n<p>This sends metrics in StatsD format. Adding <code>SCOPE_METRIC_FORMAT=ndjson</code> would change the format to ndjson.</p>\n<h4 id=\"routing-metrics-with-the-config-file\" style=\"position:relative;\"><a href=\"#routing-metrics-with-the-config-file\" aria-label=\"routing metrics with the config file 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>Routing Metrics with the Config File</h4>\n<p>Complete these steps, paying particular attention to the sub-elements of <code>metric > transport</code>, which is where you specify routing:</p>\n<ul>\n<li>Set <code>cribl > enable</code> to <code>false</code> to disable the <code>cribl</code> backend.</li>\n<li>Set <code>metric > enable</code> to <code>true</code> to enable the metrics backend.</li>\n<li>Specify desired values for the rest of the <code>metric</code> elements, namely <code>format</code>, <code>transport</code>, and optionally, <code>watch</code>.</li>\n</ul>\n<h3 id=\"container-with-edge\" style=\"position:relative;\"><a href=\"#container-with-edge\" aria-label=\"container with edge 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>Running AppScope and Cribl Edge in a Container</h3>\n<p>This section describes one of many possible scenarios involving AppScope, Cribl Edge, and containers. If you are interested in doing something different let us know via the <code>#appscope</code> channel of Cribl's <a href=\"https://cribl-community.slack.com/\">Community Slack</a>.</p>\n<p>You can start Cribl Edge and AppScope together in a container, then use Cribl Edge's <a href=\"https://docs.cribl.io/edge/sources-appscope/\">AppScope Source</a> to \"drive\" AppScope. You'll decide what apps to scope, and work with the resulting events and metrics in Cribl Edge.</p>\n<p>To do this, you can use the <code>docker run</code> command, choosing options based on considerations including whether to mount the host filesystem in read-only or read-write mode. By default, the <code>-v</code> or <code>--volume</code> mounts in read-write mode, for example <code>-v /:/hostfs</code>. For read-only mode, add <code>:ro</code>, for example <code>-v /:/hostfs:ro</code>.</p>\n<p>In the examples below, we use <code>/hostfs</code> to specify the root filesystem mount point; alternatively, you could use a path defined by the environment variable <code>CRIBL_EDGE_FS_ROOT</code>.</p>\n<p>The examples progress from most to least \"locked down.\"</p>\n<h4 id=\"example-1-mount-the-host-filesystem-read-only\" style=\"position:relative;\"><a href=\"#example-1-mount-the-host-filesystem-read-only\" aria-label=\"example 1 mount the host filesystem read only 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>Example 1: Mount the Host Filesystem Read-only</h4>\n<p>The command below mounts the overall host filesystem read-only. It then mounts the <code>scope start</code> command's three mount points in read-write mode, which is required for <code>scope start</code> to work, even when the overall filesystem is read-only.</p>\n<pre><code>docker run -d -e CRIBL_EDGE=1 -p 9420:9420 -v /var/run/appscope:/var/run/appscope -v /var/run/docker.sock:/var/run/docker.sock -v /:/hostfs:ro -v /etc/cron.d/:/hostfs/etc/cron.d/ -v /tmp/:/hostfs/tmp/ -v /usr/lib/:/hostfs/usr/lib/ --restart unless-stopped --name cribl-edge cribl/cribl:4.0.4\n</code></pre>\n<h4 id=\"example-2-mount-the-host-filesystem-read-only-with-the---privileged-flag\" style=\"position:relative;\"><a href=\"#example-2-mount-the-host-filesystem-read-only-with-the---privileged-flag\" aria-label=\"example 2 mount the host filesystem read only with the   privileged flag 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>Example 2: Mount the Host Filesystem Read-Only With the <code>--privileged</code> flag</h4>\n<p>The command below mounts the overall host filesystem read-only, but by adding the <code>--privileged</code> flag, <a href=\"https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities\">gives the container access</a> to processes running outside containers on the host. With this usage, there's no need to specify the <code>scope start</code> mount points.</p>\n<pre><code>docker run -d -e CRIBL_EDGE=1 -p 9420:9420 -v /var/run/appscope:/var/run/appscope -v /var/run/docker.sock:/var/run/docker.sock -v /:/hostfs:ro  --privileged --restart unless-stopped --name cribl-edge cribl/cribl:4.0.4\n</code></pre>\n<p>The <code>--privileged</code> flag should be used with care, because it bestows Linux capabilities – including ptrace, the ability to read the <code>/proc</code> filesystem, and more – on whatever apps run in the container.</p>\n<h4 id=\"example-3-mount-the-host-filesystem-read-write\" style=\"position:relative;\"><a href=\"#example-3-mount-the-host-filesystem-read-write\" aria-label=\"example 3 mount the host filesystem read write 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>Example 3: Mount the Host Filesystem Read-Write</h4>\n<p>The command below mounts the overall host filesystem read-write. With this usage, there's no need to specify the <code>scope start</code> mount points or to add the <code>--privileged</code> flag.</p>\n<pre><code>docker run -d -e CRIBL_EDGE=1 -p 9420:9420 -v /var/run/appscope:/var/run/appscope -v /var/run/docker.sock:/var/run/docker.sock -v /:/hostfs  --restart unless-stopped --name cribl-edge cribl/cribl:4.0.4\n</code></pre>","frontmatter":{"title":"Data Routing"}}},"pageContext":{"slug":"/data-routing/","id":"da6a6d78-653c-5e3e-b6d3-76de2ccc5875"}},"staticQueryHashes":["2787008656","306729481","625673991","640077088"]}