### URI+POST-style ammo file example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Example of an ammo.txt file for URI+POST-style ammo. The file begins with optional header lines in brackets. Then each URI line starts with a number indicating the size of the following POST body.
```default
[Host: example.org]
[Connection: close]
[User-Agent: Tank]
5 /route/?rll=50.262025%2C53.276083~50.056015%2C53.495561&origin=1&simplify=1
class
10 /route/?rll=50.262025%2C53.276083~50.056015%2C53.495561&origin=1&simplify=1
hello!clas
7 /route/?rll=37.565147%2C55.695758~37.412796%2C55.691454&origin=1&simplify=1
uripost
```
--------------------------------
### load.yaml example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/configuration.rst
A complete YAML configuration example for Yandex.Tank, defining phantom load generator settings, load profile, and autostop rules. This is the recommended starting point for a load test configuration.
```yaml
phantom:
address: "ya.ru:80"
instances: 1000
load_profile:
load_type: rps
schedule: const(1,30) line(1,1000,2m) const(1000,5m)
header_http: "1.1"
uris:
- "/"
- "/test"
- "/test2"
headers:
- "[Host: www.ya.ru]"
- "[Connection: close]"
autostop:
autostop:
- http(5xx,10%,5s)
```
--------------------------------
### URI-style ammo file example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Example of an ammo.txt file for URI-style ammo. The file contains headers and URIs. Each URI must start with a leading '/' on a new line. Lines starting with '[' are headers. Headers can be redefined in the middle of URIs. Requests can be tagged with a whitespace-separated tag after the URI.
```default
[Connection: close]
[Host: target.example.com]
[Cookie: None]
/?drg tag1
/
/buy tag2
[Cookie: test]
/buy/?rt=0&station_to=7&station_from=9
```
--------------------------------
### Minimal Host element example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/core_and_modules.rst
Minimal example of a Host element in the monitoring configuration. It sets the address, comment, interval, and username attributes.
```default
```
--------------------------------
### Complex load schedule example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Combine primitives to create complex load schemes. This example runs a linear load from 1 to 10 rps over 10 minutes, then a constant 10 rps for 10 minutes.
```text
schedule: line(1, 10, 10m) const(10,10m)
```
--------------------------------
### Example of phout.txt log format
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
This is an example of the phout.txt per-request log. It shows the fields: time, tag, interval_real, connect_time, send_time, latency, receive_time, interval_event, size_out, size_in, net_code, proto_code. The example is a sample of the log output.
```default
1326453006.582 1510 934 52 384 140 1249 37 478 0 404
1326453006.582 others 1301 674 58 499 70 1116 37 478 0 404
1326453006.587 heavy 377 76 33 178 90 180 37 478 0 404
1326453006.587 294 47 27 146 74 147 37 478 0 404
1326453006.588 345 75 29 166 75 169 37 478 0 404
1326453006.590 276 72 28 119 57 121 53 476 0 404
1326453006.593 255 62 27 131 35 134 37 478 0 404
1326453006.594 304 50 30 147 77 149 37 478 0 404
1326453006.596 317 53 33 158 73 161 37 478 0 404
1326453006.598 257 58 32 106 61 110 37 478 0 404
1326453006.602 315 59 27 160 69 161 37 478 0 404
1326453006.603 256 59 33 107 57 110 53 476 0 404
1326453006.605 241 53 26 130 32 131 37 478 0 404
```
--------------------------------
### Run Yandex.Tank with custom entrypoint
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Starts the container with /bin/bash as the entrypoint to perform tasks before running the tank.
```bash
docker run \
-v $(pwd):/var/loadtest \
-v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent \
--net host \
-it \
--entrypoint /bin/bash \
yandex/yandex-tank
```
--------------------------------
### Example log output (answ_*.txt)
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Sample output from the log file showing metrics and HTTP request/response.
```default
user@tank:~$ head answ_*.txt
553 572 8056 8043 0
GET /create-issue HTTP/1.1
Host: target.yandex.net
User-Agent: tank
Accept: */*
Connection: close
HTTP/1.1 200 OK
Content-Type: application/javascript;charset=UTF-8
```
--------------------------------
### Run Yandex.Tank with load.ini
Source: https://github.com/yandex/yandex-tank/wiki/Overload
Starts a load test using the specified config file (load.ini). Yandex.Tank prints a link to the test's live view after starting.
```bash
yandex-tank -c load.ini
```
--------------------------------
### load.yaml with writelog: all
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Example load.yaml that enables logging of all messages by setting phantom.writelog to all.
```yaml
phantom: {writelog: all}
```
--------------------------------
### Pandora plugin configuration with load.yaml, pandora_config.yml, and ammo.uri
Source: https://github.com/yandex/yandex-tank/blob/master/docs/core_and_modules.rst
Enable the Pandora plugin in load.yaml, configure the Pandora gun in pandora_config.yml, and provide the ammo.uri file. The config_content option can override config_file. The example uses a linear RPS schedule from 1 to 5 responses per second over 2 seconds and starts 5 instances.
```yaml
phantom:
enabled: false
pandora:
package: yandextank.plugins.Pandora
enabled: true
pandora_cmd: /usr/bin/pandora # Pandora executable path
config_file: pandora_config.yml # Pandora config path
```
```yaml
pools:
- id: HTTP pool # pool name (for your choice)
gun:
type: http # gun type
target: example.com:80 # gun target
ammo:
type: uri # ammo format
file: ./ammo.uri # ammo file path
result:
type: phout # report format (phout is compatible for Yandex.Tank)
destination: ./phout.log # report file name
rps: # RPS scheduler - controls throughput over test
type: line # linear growth load
from: 1 # from 1 responses per second
to: 5 # to 5 responses per second
duration: 2s # for 2 seconds
startup: # startup scheduler - control the level of parallelism
type: once # start 5 instances
times: 5 #
```
```yaml
# ammo.uri
/my/first/url
/my/second/url
```
--------------------------------
### Install system dependencies for PyPi
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Installs required system packages for building Python libraries on Debian-based systems.
```bash
sudo apt-get install python3-pip build-essential python3-dev libffi-dev gfortran libssl-dev
```
--------------------------------
### Sample GET requests (null body)
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Shows three GET requests in request-style format with null bodies. Each request includes a size, optional tag, and headers. The '\r' symbols are strictly required.
```default
73 good
GET / HTTP/1.0
Host: xxx.tanks.example.com
User-Agent: xxx (shell 1)
77 bad
GET /abra HTTP/1.0
Host: xxx.tanks.example.com
User-Agent: xxx (shell 1)
78 unknown
GET /ab ra HTTP/1.0
Host: xxx.tanks.example.com
User-Agent: xxx (shell 1)
```
--------------------------------
### Install Yandex.Tank from master branch
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Installs the latest version of Yandex.Tank directly from the GitHub master branch.
```bash
sudo -H pip3 install https://api.github.com/repos/yandex/yandex-tank/tarball/master
```
--------------------------------
### Fractional load example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
You can set fractional load values, as shown here with a linear load from 1.1 to 2.5 rps over 10 seconds.
```text
line(1.1, 2.5, 10)
```
--------------------------------
### line load primitive examples
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
The line primitive makes linear load. Examples show decreasing and increasing load from 10 to 1 rps and from 1 to 10 rps over 10 minutes.
```text
line(10, 1, 10m)
```
```text
line(1, 10, 10m)
```
--------------------------------
### Add PPA via add-apt-repository
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Installs software properties tools and adds the Yandex load PPA automatically.
```bash
sudo apt-get install python3-software-properties
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:yandex-load/main
```
--------------------------------
### Run Yandex.Tank with load.yaml
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Execute this command to start the load test using the configuration file created above.
```bash
$ yandex-tank -c load.yaml
```
--------------------------------
### tank-postloader help
Source: https://github.com/yandex/yandex-tank/wiki/JsonReport-&-Postloader-(yandextank-1.9.2)
Command to get more information about tank-postloader options.
```bash
$ tank-postloader --help
```
--------------------------------
### step load primitive examples
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
The step primitive makes stepped load. Examples show decreasing and increasing load from 25 to 5 rps and from 5 to 25 rps with 5 rps steps and 60s step duration.
```text
step(25, 5, 5, 60)
```
```text
step(5, 25, 5, 60)
```
--------------------------------
### const load primitive examples
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
The const primitive makes constant load. Examples show a constant 10 rps for 10 minutes and a 10-second pause with 0 rps.
```text
const(10,10m)
```
```text
const(0, 10)
```
--------------------------------
### Telegraf monitoring configuration XML example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/core_and_modules.rst
Example monitoring configuration XML for the Telegraf plugin. The root element Monitoring contains Host elements, each with metric elements like CPU, Kernel, Net, System, Memory, Disk, Netstat, Custom, Source, and TelegrafRaw. The second Host shows using a custom telegraf binary path and additional metrics.
```default
curl -s -H 'Host: host.tld' 'http://localhost:6100/stat' | python3 -c 'import sys, json; j = json.load(sys.stdin); print("\n".join(`c["values"]["accept"]` for c in j["charts"] if c["name"] == "localqueue_wait_time"))'/path/to/file
[[inputs.ping]]
urls = ["127.0.0.1"]
count = 1
```
--------------------------------
### JsonReport configuration in load.yaml
Source: https://github.com/yandex/yandex-tank/wiki/JsonReport-&-Postloader-(yandextank-1.9.2)
Configuration example for JsonReport in YAML format, setting monitoring_log and test_data_log filenames.
```yaml
# load.yaml
...
json_report:
monitoring_log: my_monitoring.json
test_data_log: my_test_data.json
...
```
--------------------------------
### JsonReport configuration in load.ini
Source: https://github.com/yandex/yandex-tank/wiki/JsonReport-&-Postloader-(yandextank-1.9.2)
Configuration example for JsonReport in INI format, setting monitoring_log and test_data_log filenames.
```ini
# load.ini
...
[json_report]:
monitoring_log=my_monitoring.json
test_data_log=my_test_data.json
...
```
--------------------------------
### Run Yandex.Tank in Docker
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Starts the Yandex.Tank container with the current directory mounted to /var/loadtest and SSH agent forwarding enabled for monitoring.
```bash
docker run \
-v $(pwd):/var/loadtest \
-v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent \
--net host \
-it yandex/yandex-tank
```
--------------------------------
### load.yaml with autostop configuration
Source: https://github.com/yandex/yandex-tank/blob/master/docs/tutorial.rst
Example load.yaml that stops the test when all answers in a 1-second period are 5xx, plus network and timing factors.
```yaml
phantom:
address: 203.0.113.1:80
load_profile:
load_type: rps
schedule: line(1, 10, 10m)
autostop:
autostop:
- time(1s,10s)
- http(5xx,100%,1s)
- net(xx,1,30)
```
--------------------------------
### Typical workflow with data session
Source: https://github.com/yandex/yandex-tank/blob/master/yandextank/contrib/netort/README.md
A Python example showing how to prepare data, specify backends (LunaClient with optional store_raw, LocalStorageClient), create a data session with a context manager, subscribe backends, create metrics and events (with optional aggregation), and add data.
```python
import numpy as np
import pandas as pd
from netort.data_manager import data_session
from netort.data_manager.clients import LunaClient, LocalStorageClient
# Prepare data
# random metrics
voltage_df = pd.DataFrame()
voltage_df["ts"] = (np.arange(0,1000000,100)
voltage_df["value"] = np.random.randint(1000000, size=10000))
current_df = pd.DataFrame()
current_df["ts"] = (np.arange(0,1000000,100)
current_df["value"] = np.random.randint(1000000, size=10000))
# events
logs_df = pd.DataFrame([
[0, "log message 1"],
[11345, "my event number 1"],
[100345, "my event number 2"],
[102234, "my event number 3"],
[103536, "my event number 4"],
],
columns=["ts", "value"])
errors_df = pd.DataFrame([
[110, "error 1"],
[11845, "error 2"],
[13845, "error 3"],
[202234, "error 4"],
[203536, "error 5"],
],
columns=["ts", "value"])
# specify backends (1)
luna = LunaClient( # store to Luna service
store_raw=False, # if data stream has aggregates, upload only aggregates without raw data
api_address="http://example.org")
local = LocalStorageClient() # store to local files
# create the data session (2)
# It will close automatically (6) because we've used a context manager
with data_session(dict(name="My first test")) as ds:
ds.subscribe(luna, local) # subscribe the backends (3)
# create metrics and events (4)
voltage = ds.new_metric(dict(name="Voltage"))
current = ds.new_metric(dict(name="Current"), aggregate=True) # this metric will be aggregated
logs = ds.new_events(dict(name="Log messages"))
error_codes = ds.new_events(dict(name="Error codes), aggregate=True) # these events will be aggregated
# add data (5)
voltage.put(voltage_df)
current.put(current_df)
logs.put(log_df)
error_codes.put(errors_df)
```
--------------------------------
### BFG pip option for multiple modules
Source: https://github.com/yandex/yandex-tank/blob/master/docs/core_and_modules.rst
Example of the pip option in BFG config to install multiple Python modules with pip3 install --user before the test. Use multiline options for multiple modules.
```default
pip=grequests
msgpack
```
--------------------------------
### Upgrade setuptools
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Updates setuptools to the latest version.
```bash
sudo -H pip3 install --upgrade setuptools
```
--------------------------------
### tracepath - farther location check
Source: https://github.com/yandex/yandex-tank/blob/master/docs/generator_tuning.rst
A second tracepath example with more hops and no 'reached' line, showing a tank farther from the target. If you get such results, find another tank in a closer location.
```bash
$ tracepath 24.24.24.24
1: 1.example.com (203.0.113.1) 0.084ms pmtu 1450
1: 2.example.com (203.0.113.1) 0.276ms
1: 3.example.com (203.0.113.1) 0.411ms
2: 4.example.com (203.0.113.1) 0.514ms
3: 5.example.com (203.0.113.1) 10.690ms
4: 6.example.com (203.0.113.1) 0.831ms asymm 3
5: 7.example.com (203.0.113.1) 0.512ms
6: 8.example.com (203.0.113.1) 0.525ms asymm 5
7: no reply
```
--------------------------------
### Install yandex-tank deb package
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Updates the package list and installs the yandex-tank package.
```bash
sudo apt-get update && sudo apt-get install yandex-tank
```
--------------------------------
### Install Yandex.Tank via PIP for Overload
Source: https://github.com/yandex/yandex-tank/wiki/Overload
Installs Yandex.Tank from the master branch on Debian-based systems, including required build packages, pip/setuptools upgrades, and the Phantom load generator from the yandex-load PPA. This is the recommended installation for Overload support.
```bash
sudo apt-get install python-pip build-essential python-dev libffi-dev gfortran libssl-dev
```
```bash
sudo -H pip install --upgrade pip
```
```bash
sudo -H pip install --upgrade setuptools
```
```bash
sudo -H pip install https://api.github.com/repos/yandex/yandex-tank/tarball/master
```
```bash
sudo add-apt-repository ppa:yandex-load/main && sudo apt-get update
sudo apt-get install phantom phantom-ssl
```
--------------------------------
### Install Phantom load generator
Source: https://github.com/yandex/yandex-tank/blob/master/docs/install.rst
Adds the Yandex load PPA and installs the Phantom load generator and SSL support.
```bash
sudo add-apt-repository ppa:yandex-load/main && sudo apt-get update
sudo apt-get install phantom phantom-ssl
```
--------------------------------
### Time units example
Source: https://github.com/yandex/yandex-tank/blob/master/docs/configuration.rst
Illustrates time unit abbreviations and mixing. The example shows that 30000 ms equals 30 s, and time(30000,120) is equivalent to time(30s,2m).
```default
``30000 == 30s``
``time(30000,120)`` is an equivalent to ``time(30s,2m)``
```