Skip to content

Commit

Permalink
Update readme and examples (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental authored Aug 29, 2023
1 parent 2588d2a commit dd673cb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 78 deletions.
124 changes: 48 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,65 @@
# Log load client

This project is a golang application to generate logs and send them to various output destinations in various formats. The app runs as a single executable. If more load is needed, scale the app horizontally.

Example:

```bash
$ ./logger --command=generate
goloader seq - localhost.localdomain.0.00000000000000003505C218B3455F5F - 0000000000 - You're screwed !
goloader seq - localhost.localdomain.0.00000000000000003505C218B3455F5F - 0000000001 - Don’t use beef stew as a computer password. It’s not stroganoff.
goloader seq - localhost.localdomain.0.00000000000000003505C218B3455F5F - 0000000002 - failed to reach the cloud, try again on a rainy day
goloader seq - localhost.localdomain.0.00000000000000003505C218B3455F5F - 0000000003 - successfully launched a car in space
goloader seq - localhost.localdomain.0.00000000000000003505C218B3455F5F - 0000000004 - error while reading floppy disk
goloader seq - localhost.localdomain.0.00000000000000003505C218B3455F5F - 0000000005 - Don’t use beef stew as a computer password. It’s not stroganoff.
```shell
$ ./logger
goloader seq - hostname.example.com - 0000000000 - infinite loop succeeded in less than 3 seconds
goloader seq - hostname.example.com - 0000000001 - Don’t use beef stew as a computer password. It’s not stroganoff.
goloader seq - hostname.example.com - 0000000002 - cannot over-write a locked variable.
goloader seq - hostname.example.com - 0000000003 - failed to get an error message
```
## Usage

examples using docker image:
`podman run quay.io/openshift-logging/cluster-logging-load-client:latest generate` - start outputting logs to stdout
examples using local binary:
`./logger --command=generate` - start outputting logs to stdout
`./logger --command=generate --url=http://localhost:3100/api/prom/push` - send logs to loki
`./logger --command=generate --logs-per-second=500` - logs 500 log lines per second (default is one log line per seconds)
Following flags are available:
```bash
Flags:
--log-level string Log level: debug, info, warning, error (default = error) (default "error")
--command string Overwrite to control if logs are generated or queried. Allowed values: generate, query.
--destination string Overwrite to control where logs are queried or written to. Allowed values: loki, elasticsearch, stdout, file.
--file string The name of the file to write logs to. Only available for File destinations.
--url string URL of Promtail, LogCLI, or Elasticsearch client.
--disable-security-check bool Disable security check in HTTPS client.
--logs-per-second int The rate to generate logs. This rate may not always be achievable.
--log-type string Overwrite to control the type of logs generated. Allowed values: simple, application, synthetic.
--log-format string Overwrite to control the format of logs generated. Allowed values: default, crio (mimic CRIO output), csv, json
--label-type string Overwrite to control what labels are included in Loki logs. Allowed values: none, client, client-host
--synthetic-payload-size int Overwrite to control size of synthetic log line.
--tenant string Loki tenant ID for writing logs.
--queries-per-minute int The rate to generate queries. This rate may not always be achievable.
--query string Query to use to get logs from storage.
--query-range string Duration of time period to query for logs (Loki only).
```
## Build
To build the app run `make build`
To build docker image use `make build-image`
To push docker image use `make push-image`
## Elasticsearch
### Generate logs to elasticsearch v6
Logger sends logs to elasticsearch using its `bulk` API.
Launch an elasticsearch(v6) container:
```
make run-es
```
Run logger and with remote type `elasticsearch`:
```
make run-local-es-generate
The following flags are available:

```shell
$ ./logger --help
Usage of ./logger:
--command string Overwrite to control if logs are generated or queried. Allowed values: generate, query. (default "generate")
--destination string Overwrite to control where logs are queried or written to. Allowed values: loki, elasticsearch, stdout, file. (default "stdout")
--disable-security-check Disable security check in HTTPS client.
--file string The name of the file to write logs to. Only available for "File" destinations. (default "output.txt")
--label-type string Overwrite to control what labels are included in Loki logs. Allowed values: none, client, client-host (default "none")
--log-format string Overwrite to control the format of logs generated. Allowed values: default, crio (mimic CRIO output), csv, json (default "default")
--log-level string Overwrite to control the level of logs emitted. Allowed values: debug, info, warning, error (default "error")
--log-type string Overwrite to control the type of logs generated. Allowed values: simple, application, synthetic. (default "simple")
--logs-per-second int The rate to generate logs. This rate may not always be achievable. (default 1)
--queries-per-minute int The rate to generate queries. This rate may not always be achievable. (default 1)
--query string Query to use to get logs from storage.
--query-range string Duration of time period to query for logs (Loki only). (default "1s")
--synthetic-payload-size int Overwrite to control size of synthetic log line. (default 100)
--tenant string Loki tenant ID for writing logs. (default "test")
--url string URL of Promtail, LogCLI, or Elasticsearch client.
--use-random-hostname Ensures that the hostname field is unique by adding a random integer to the end.
```
### Generate query requests to elasticsearch v6
## Docker Image
```shell
podman run --rm -it quay.io/openshift-logging/cluster-logging-load-client:latest
```
make run-local-es-query
```
## Loki
### Generate logs to loki
Launch a loki container:
```
make run-loki
```
Run logger and set with remote type `loki`:
```
make run-local-loki-generate
## From Source
```shell
# Build binary ("logger")
$ make build
# Default configuration
$ ./logger
# Increased log rate
$ ./logger --logs-per-second=500
# Push logs directly to Loki
$ ./logger --destination=loki --uri=http://localhost:3100/loki/api/v1/push
```
### Generate query requests to loki
## Build
```
make run-local-loki-query
```shell
# Build the binary
$ make build
# Build the Docker image
$ make build-image
```
2 changes: 0 additions & 2 deletions deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ spec:
spec:
containers:
- name: logger
args:
- generate
image: quay.io/openshift-logging/cluster-logging-load-client:latest
imagePullPolicy: Always

0 comments on commit dd673cb

Please sign in to comment.