Skip to main content

Command Line

Canarytrace is distributed as a docker image and is run from command line. Behavior and functions are set using options. Some options are mandatory and some are optional. Canarytrace is based on WDIO v7 and therefore some options are described on WDIO CLI Options page.

What you’ll learn#

  • How to run Canarytrace from the command line
  • Options for Canarytrace settings
  • All options are environment variables and they are used when running in both the docker and the kubernetes

How to run Canarytrace#

Examples below shows how to run Canarytrace in minimal configuration. Minimal configuration means, that Canarytrace will be run with default configuration.

Docker compose#

The easiest way to run Canarytrace is to use a docker compose

version: "3.8"
image: selenium/standalone-chrome:4.1.1-20211217
network_mode: "host"
- /dev/shm:/dev/shm
- browser
network_mode: "host"

In this example are only options BASE_URL which contain target URL and LICENSE.

You can run a command using docker-compose up


Use Kubernetes CronJob for production use and for non-stop monitoring.

apiVersion: batch/v1beta1
kind: CronJob
name: smoke-mobile
namespace: canarytrace
concurrencyPolicy: Replace
failedJobsHistoryLimit: 2
schedule: "*/3 * * * *"
- name: canarytrace
- name: BASE_URL
value: ""
- name: PT_AUDIT
value: "allow"
value: "mobileRegular3G"
- name: LABELS
value: "mobile, smoke"
- name: LICENSE
value: "XXXXX-YYYYY-Z4WG5-5363C-CF0CB-A8647"
value: ""
value: "elastic:password"

This example isn't complete, but contains more options as environment variable ELASTIC_CLUSTER, PT_AUDIT, PT_AUDIT_THROTTLING or LABELS. Some of them are mandatory and some are optional.

Mode smoke#

How to read this documentation#

Mandatory options#

Mode smoke is a default.

  • BASE_URL add more URLs, e.g. BASE_URL=;

  • LICENSE add your license key.


If you want use live logging to Elasticsearch and visualize data in a Kibana, you must use this options.

  • ELASTIC_CLUSTER URI of elasticsearch cluster. E.g. ELASTIC_CLUSTER="http://localhost:9200" This option activate live reporting all data to elasticsearch. If left blank, documents will be printed to stdout.

  • ELASTIC_HTTP_AUTH Basic authentication in format username:password . E.g. ELASTIC_HTTP_AUTH=elastic:1fKP17UklmiI14rekO6iCx9r

  • MIN_PTIME Print requests to elasticsearch if is exceeded transactions time. Default min processing time is 300ms.

  • ELASTIC_OBSERVABILITY Use allow for print settings of elasticsearch and all requests and responses to stdout.

  • INDEX_PREFIX - Default is c.

  • USE_ELASTIC_DOC_TYPE_BY_INDEX_NAME Default is false and will be used type _doc. If you true will be used name of index just type.

  • ELASTIC_REQUEST_COMPRESSION Use allow for use compression.

  • ELASTIC_TIMEOUT Default is 5000ms.

Performance audit#


Configuration is on separate page. Performance audit configuration


  • PAUSE_BETWEEN_SMOKE Default is 0ms. Pause between every tested URL.

Mode user-journey#

it('open home page', async () => {
await browser.url('/');
await expect(browser).toHaveTitle(title, {message: 'Element title not found. The page couldn\'t be loaded in time.'})

Mandatory options#

  • MODE - switch mode of Canarytrace on user journey MODE="user-journey"

  • SPEC - is file with your test case / monitor script, e.g. SPEC="test/specs/example.e2e.js"




  • GIT_REVISION - fd29508 revision of your test case. Canarytrace perform git checkout before run test.


  • USER username for TC, which use login to app. E.g. USER=CYBERTRUCK

  • PASS password for TC, which use login to app. E.g. PASS=Cybertruck@250Mil

How to use in your test case

it('fill login and password inputs', async () => {
const userNameElm = await $(userNameInput)
await userNameElm.waitForClickable({timeoutMsg: 'Username input not exist.'})
await userNameElm.setValue(browser.config.username);
const passwordElm = await $(passwordInput)
await passwordElm.waitForClickable({timeoutMsg: 'Password button not exist.'})
await passwordElm.setValue(browser.config.password);


These options are not mandatory and are available for both mode.

  • LABELS is optional metainformation, which is stored in the elastic to each record in each index, e.g. 'relesease=7, environment=dev'

  • SPEC is path and name of testcase / monitor script. E.g. SPEC=tesla/smoke.js

  • ENGINE - default is wdio for Webdriver.IO v7.5 and no need change it

  • ENV_PRINT - Print all environment variables. Print all environment variables before execution of monitor script. All environment variables will be saved to Elasticsearch index c.env-*

It's useful for debugging but use with caution. This command print value all environment variables including sensitive if exist.

  • AVAILABILITY_CHECK - use allow if you want run check availability of web app before run Canarytrace.

It's useful for check availability environment and tested application.

22:51:41.914980 * Connection #0 to host left intact
time_namelookup: 0.058289
time_connect: 0.086838
time_appconnect: 0.133599
time_pretransfer: 0.136155
time_redirect: 0.000000
time_starttransfer: 0.173897
time_total: 0.477677
  • WAIT_FOR_TIMEOUT - Timeout limit for all waitFor* commands. Default is 30.000ms

  • LOG_LEVEL - default is warn. Level of logging verbosity

  • ATTACHMENTS Use allow for store screenshot to disk, when testStep is failed.

    • Format HHmmss-YYYY-MM-DD-uuidAction.png

    • You must bind volume -v $(pwd)/attachments/:/opt/canary/attachments for "move screenshot from docker container to local directory" /attachments.

    • You can use AWS_S3_BUCKET option for upload screenshot to AWS S3 This option is described below.

  • CAPTURE_EVERY_SCREEN=allow create a screenshot on every test step.

  • TESTS_PATH default is /opt/canary/tests there is no reason to change this option.


  • REQUEST_LOG default no store collection all requests and responses directly from browser into elasticsearch index c.request-log-*

    • For activate this features use REQUEST_LOG=allow
  • CONSOLE_INTERCEPT default no store console of browser into elasticsearch index c.console-*

    • For activate this features use CONSOLE_INTERCEPT=allow
  • COVERAGE_AUDIT default no store percentage used and unused code of web application into elasticsearch index c.coverage-audit-*

    • For activate this features use COVERAGE_AUDIT=allow
  • MEMORY_INTERCEPT default no store used javascript memory during loading and using the web application into elasticsearch index c.memory-*

    • For activate this features use MEMORY_INTERCEPT=allow
  • HERO_ELEMENTS default no store Hero Elements into elasticsearch index c.performance-entries-*

    • For activate this features use HERO_ELEMENTS=allow


  • -v $(pwd)/assets/:/opt/canary/assets binding local directory with directory in docker container for statical files, e.g. Lighthouse HTML report or JSON records of activity in Chrome's processes.

  • -v $(pwd)/tests/:/opt/canary/tests binding local directory with tests to directory in docker container.

  • -v $(pwd)/config:/opt/canary/config/wdio for extended default configuration.