diff --git a/src/data/markdown/translated-guides/en/02 Using k6/05 Options.md b/src/data/markdown/translated-guides/en/02 Using k6/05 Options.md index 52b37bdc84..9aad407c97 100644 --- a/src/data/markdown/translated-guides/en/02 Using k6/05 Options.md +++ b/src/data/markdown/translated-guides/en/02 Using k6/05 Options.md @@ -689,45 +689,74 @@ $ k6 run --local-ips=192.168.20.12-192.168.20.15,192.168.10.0/27 script.js -## Log output +## Log Output This option specifies where to send logs to and another configuration connected to it. Available in the `k6 run` command. +| Env | CLI | Code / Config file | Default | +| --------------- | -------------- | ------------------ | -------- | +| `K6_LOG_OUTPUT` | `--log-output` | N/A | `stderr` | + + + +```bash +$ k6 run --log-output=stdout script.js +``` + + + Possible values are: - none - disable - stdout - send to the standard output - stderr - send to the standard error output (this is the default) - loki - send logs to a loki server +- file - write logs to a file + +### Loki The loki can additionally be configured as follows: -`loki=http://127.0.0.1:3100/loki/api/v1/push,label.something=else,label.foo=bar,limit=32,level=info,pushPeriod=5m32s,msgMaxSize=1231` + + + +```bash +$ k6 run --log-output=loki=http://127.0.0.1:3100/loki/api/v1/push,label.something=else,label.foo=bar,limit=32,level=info,pushPeriod=5m32s,msgMaxSize=1231 script.js +``` + + + Where all but the url in the beginning are not required. The possible keys with their meanings and default values: -| key | meaning | default value | -| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | -| `nothing` | the endpoint to which to send logs | `http://127.0.0.1:3100/loki/api/v1/push` | -| allowedLabels | if set k6 will send only the provided labels as such and all others will be appended to the message in the form `key=value`. The value of the option is in the form `[label1,label2]` | N/A | -| label.`labelName` | adds an additional label with the provided key and value to each message | N/A | -| limit | the limit of message per pushPeriod, an additional log is send when the limit is reached, logging how many logs were dropped | 100 | -| level | the minimal level of a message so it's send to loki | all | -| pushPeriod | at what period to send log lines | 1s | -| profile | whether to print some info about performance of the sending to loki | false | -| msgMaxSize | how many symbols can there be at most in a message. Messages bigger will miss the middle of the message with an additional few characters explaining how many characters were dropped. | 1048576 | +| key | description | default value | +| --- | ----------- | ------------- | +| `nothing` | the endpoint to which to send logs | `http://127.0.0.1:3100/loki/api/v1/push` | +| allowedLabels | if set k6 will send only the provided labels as such and all others will be appended to the message in the form `key=value`. The value of the option is in the form `[label1,label2]` | N/A | +| label.`labelName` | adds an additional label with the provided key and value to each message | N/A | +| limit | the limit of message per pushPeriod, an additional log is send when the limit is reached, logging how many logs were dropped | 100 | +| level | the minimal level of a message so it's send to loki | all | +| pushPeriod | at what period to send log lines | 1s | +| profile | whether to print some info about performance of the sending to loki | false | +| msgMaxSize | how many symbols can there be at most in a message. Messages bigger will miss the middle of the message with an additional few characters explaining how many characters were dropped. | 1048576 | -| Env | CLI | Code / Config file | Default | -| --------------- | -------------- | ------------------ | -------- | -| `K6_LOG_OUTPUT` | `--log-output` | N/A | `stderr` | +### File + +The file can be configured as below, where an explicit file path is required: ```bash -$ k6 run --log-output=stdout script.js +$ k6 run --log-output=file=./k6.log script.js ``` +A valid file path is the unique mandatory field, the other optional fields listed below: + +| key | description | default value | +| --- | ----------- | ------------- | +| level | the minimal level of a message to write out of (in ascending order): trace, debug, info, warning, error, fatal, panic | trace | + ## LogFormat A value specifying the log format. By default, k6 includes extra debug information like date and log level. The other options available are: