-
Notifications
You must be signed in to change notification settings - Fork 35
docs: improve stdout-log-generator README with full argument documentation #3763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,19 +1,86 @@ | ||||||||||
| # Stdout Log Generator | ||||||||||
|
|
||||||||||
| Small tool for generating logs to stdout, used in the e2e tests of the telemetry-manager. | ||||||||||
| A small tool that continuously writes log lines to stdout. Used in the e2e tests of telemetry-manager to produce configurable log traffic inside Kubernetes workloads. | ||||||||||
|
|
||||||||||
| Available command line args: | ||||||||||
| The tool exposes a Prometheus metrics endpoint on port `2112` (`/metrics`) with two metrics: | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
never mention the exact number when introducing a list, easier for maintenancce |
||||||||||
|
|
||||||||||
| - format | ||||||||||
| - bytes | ||||||||||
| - rate | ||||||||||
| - fields | ||||||||||
| - text | ||||||||||
| - `logs_generated_total` — total log lines written since start | ||||||||||
| - `logs_generated_rate` — actual throughput in logs/second since start | ||||||||||
|
|
||||||||||
| ## Build locally | ||||||||||
| ## Usage | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| stdout-log-generator [flags] | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Flags | ||||||||||
|
|
||||||||||
| | Flag | Short | Default | Description | | ||||||||||
| |------|-------|---------|-------------| | ||||||||||
| | `--format` | | `json` | Output format: `json` or `plaintext` | | ||||||||||
| | `--bytes` | `-b` | `2048` | Size of each log line in bytes | | ||||||||||
| | `--rate` | `-r` | `1` | Target log lines per second. `0` means unlimited | | ||||||||||
| | `--fields` | `-f` | | Additional key=value fields to include in every JSON log record (can be repeated or comma-separated). Ignored when `--format plaintext` is used | | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. less ambiguity
Suggested change
|
||||||||||
| | `--text` | `-t` | | Fixed text to write for every plaintext log line. Ignored if `--bytes` is set. Only relevant when `--format plaintext` is used | | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ## Output formats | ||||||||||
|
|
||||||||||
| ### JSON (default) | ||||||||||
|
|
||||||||||
| Each line is a JSON object with a `padding` field filled with random characters to reach the requested byte size, plus any custom fields added via `--fields`: | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ```json | ||||||||||
| {"padding":"aBcDeFgH...","environment":"prod","app":"myservice"} | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| The `padding` field is sized so that the total serialized JSON line matches `--bytes` exactly (including the trailing newline added by the JSON encoder). | ||||||||||
|
|
||||||||||
| If the combined size of the custom fields already exceeds `--bytes`, the tool exits with an error. | ||||||||||
|
|
||||||||||
| ### Plaintext | ||||||||||
|
|
||||||||||
| Each line is either the fixed string given by `--text`, or a random string of `--bytes` length when `--text` is not set. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if neither flag ( |
||||||||||
| ## Rate limiting | ||||||||||
|
|
||||||||||
| The tool uses a token-bucket rate limiter (`golang.org/x/time/rate`). On Linux, the minimum achievable sleep granularity is approximately 2 ms. To compensate, the burst size is set to `2 × (rate / 1000)` so that the generator can emit multiple logs back-to-back before sleeping, keeping the long-run average close to the requested rate even at high throughputs. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Splitting the sentence for clarity
Suggested change
|
||||||||||
|
|
||||||||||
| Setting `--rate 0` disables throttling entirely (write as fast as possible). | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. purpose first, then instruction
Suggested change
|
||||||||||
|
|
||||||||||
| ## Examples | ||||||||||
|
|
||||||||||
| Generate 100 JSON logs per second, each 1 KiB in size: | ||||||||||
|
|
||||||||||
| To build the image locally run: | ||||||||||
| ```sh | ||||||||||
| stdout-log-generator --rate 100 --bytes 1024 | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Generate JSON logs with custom fields at the default rate: | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| stdout-log-generator --fields app=myservice,env=prod | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Generate plaintext logs with a fixed message at 50 logs/second: | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| stdout-log-generator --format plaintext --text "hello world" --rate 50 | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Generate random plaintext logs of 512 bytes each, unlimited rate: | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| stdout-log-generator --format plaintext --bytes 512 --rate 0 | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Build locally | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| docker build -t stdout-log-generator:local . | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| Run the local image: | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| docker run --rm stdout-log-generator:local --rate 10 --fields app=test | ||||||||||
| ``` | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.