Skip to Content
DocsGetting StartedSet up Artillery CLI
·

Set up Artillery CLI

A CLI is a command-line interface. Use the Artillery CLI to run tests from your terminal.

Install Artillery CLI

Artillery requires the most recent LTS release of Node.js . LTS means long-term support. Install Node.js before installing Artillery.

Install Artillery globally with npm:

npm install -g artillery@latest

You can also run the Artillery CLI with npx:

npx artillery@latest

System requirements

Artillery runs on Windows, MacOS, and Linux. It requires the most recent LTS release of Node.js.

Common issues

Windows PowerShell

An execution policy controls which scripts PowerShell can run. By default, this policy blocks scripts on Windows Desktop clients. If you use PowerShell, Artillery can fail with this error:

artillery: File C:\Users\Artillery\AppData\Roaming\npm\artillery.ps1 cannot be loaded because running scripts is disabled on this system.

To allow Artillery to run, change the PowerShell execution policy to RemoteSigned. Open PowerShell as an administrator. Run Set-ExecutionPolicy as shown below:

PS C:\Windows\system32> Set-ExecutionPolicy RemoteSigned Execution Policy Change The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y

Installing as root in Docker

If you install Artillery in a Docker container or image, do not run the installation as root. This also applies to installation commands in a Dockerfile, such as RUN npm install -g artillery.

Installing as a devDependency in Node.js projects

We recommend keeping performance tests in a separate repository or project. Install Artillery as a dependency there, rather than as a development dependency in your application with npm install -D. A development dependency is a package used during development.

Canary releases

A canary release contains changes before an official release. Artillery publishes one for every new commit to its GitHub repository. You can use these releases to try changes and report bugs.

Use canary releases with caution. Features can break. If you find a problem, report it through Github Issues .

Install the latest canary release with:

npm install -g artillery@canary

Checking your installation

To make sure that Artillery is installed, run:

npx artillery dino

To display the installed version, run:

artillery version

Set up cloud reporting

Artillery Cloud provides reports and visualizations for your load tests. To use it, create an account. Then enable reporting for each test run that you want to record.

All load tests still run entirely in your environment: locally, on AWS Lambda, AWS Fargate, or Azure Container Instances. Cloud reporting is optional for each run. The CLI sends reports to the cloud dashboard only when you use the --record flag.

Create an Artillery Cloud account

Sign in with your GitHub account at https://app.artillery.io  to create an Artillery Cloud account.

An API key lets the CLI send reports to your account. Get an API key from Settings → API Keys.

Configure the CLI to send data to Artillery Cloud

The CLI sends test results to Artillery Cloud only when you enable reporting for that run.

To record a test, use --record and --key with artillery run. For example, this command runs a test without cloud reporting:

artillery run my-service-test.yml

To enable cloud reporting, add --record. Set --key to the API key from the previous step. Replace a9_myapikey in this example with that key:

artillery run my-service-test.yml --record --key a9_myapikey

When a test with cloud reporting starts, the CLI prints the URL of its report.

You can also set the API key with the ARTILLERY_CLOUD_API_KEY environment variable. If you set this variable, you can omit --key.

Best practices

Naming tests

By default, Artillery Cloud uses the script filename as the test name.

To use a different name, set --name. In the following examples, $MY_ARTILLERY_CLOUD_KEY contains your Artillery Cloud API key.

artillery run service-foo.yml --name "service-foo-spike-test" --record --key $MY_ARTILLERY_CLOUD_KEY

Artillery Cloud uses the test name in these places:

  • The list of test runs
  • The group name in group view
  • Other runs of the same test in Comparison View
  • Performance trends across multiple runs

Using tags

Tags are labels that help you find and group tests. Consistent tags help you search, filter, and analyze results across runs.

Use --tags to pass a comma-separated list of tags to your test script:

artillery run my-service-test.yml --tags "env:staging,service:auth,version:1.2.3" --record --key $MY_ARTILLERY_CLOUD_KEY

The following tags work well for common uses:

env  — different environments where the application is deployed

Track performance across environments to account for differences in the application or infrastructure.

A baseline is a reference measurement for later comparisons. For example, use staging to gather baselines under high load. Run automated tests that simulate user activity in production at lower loads.

Examples: env:staging, env:prod, env:qa

service  — name of the application or service

Use tests for individual services to build dashboards for those services. A smoke test makes sure that basic functions work. For example, run a production smoke test for each service to track its performance.

Examples: service:auth, service:billing

version  — version ID of the application or service

Use a service version or commit SHA to trace performance issues to a specific application version. A commit SHA identifies a Git commit.

In the application repository, run git rev-parse --short HEAD to get a short Git SHA for the tag.

Examples: version:a231b3e, version:1.2.3

type  — type of load test

Distinguish runs of the same test that serve different purposes.

A soak test applies load over an extended period. For example, run nightly tests to gather baselines. In the same environment, run a soak test before a release every two weeks.

Examples: type:spike, type:baseline, type:soak, type:acceptance

ci  — whether a run was triggered from CI or not

Continuous integration (CI) automates the integration and testing of code changes. Distinguish manual test runs from CI runs to compare results under specific CI conditions over time.

Examples: ci:true, ci:jenkins

team  — name of the team running the test

Use this tag to build team dashboards that show tests run by that team.

Examples: team:billing, team:capybara

actor  — ID of the person or workflow that triggered the test

Filter tests by the ID of the person or workflow that started them.

In GitHub Actions, you can use the github.actor or github.job variables.

Examples: actor:github-post-deployment-check, actor:deepak@example.com

Troubleshooting

Error: unable to reach Artillery Cloud API

This error means that the CLI cannot reach the Artillery Cloud API.

The most common cause is a corporate proxy or firewall that blocks POST requests to the Artillery Cloud API (https://app.artillery.io ).

On the machine that runs Artillery, run the command for your operating system to see whether requests reach the API:

curl -X POST -H "user-agent: Artillery CLI v2.0.23" https://app.artillery.io/api/ping

If the request succeeds, the response is:

{"message":"pong"}

If the request fails or is blocked, ask your network administrators to allow requests to the Artillery Cloud API. For example, the command can report a network timeout.

You can also try Artillery on a different network, such as your home network or a cloud instance.

Last updated on