Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/balena-os/log-streamer

Test sending logs to the API log-stream
https://github.com/balena-os/log-streamer

Last synced: about 1 month ago
JSON representation

Test sending logs to the API log-stream

Awesome Lists containing this project

README

        

# Log tester

Test sending logs to the API log-stream.

This is only meant to be used for debugging purposes. Abusing the tool may result in API limits being enforced.

## Usage

```
# Install dependencies
$ npm i

# Set the credentials as env vars (required)
$ export UUID=
$ export API_KEY=

# Start logging. Logs should show on the dashboard and on
# stdout
$ npm run dev
Mon, 27 Feb 2023 21:16:44 GMT - Test message No. 0. Next message in 1(s)
Mon, 27 Feb 2023 21:16:45 GMT - Test message No. 1. Next message in 2(s)
Mon, 27 Feb 2023 21:16:47 GMT - Test message No. 2. Next message in 3(s)
Mon, 27 Feb 2023 21:16:50 GMT - Test message No. 3. Next message in 4(s)
Mon, 27 Feb 2023 21:16:54 GMT - Test message No. 4. Next message in 5(s)
```

On a balena device

```
balena run --rm -ti -e UUID=$(cat /mnt/boot/config.json | jq -r .uuid) -e API_KEY=$(cat /mnt/boot/config.json | jq -r .deviceApiKey) ghcr.io/balena-os/log-streamer
```

You can also simulate messages coming from specific services

```
# Get the service id
SERVICE_NAME=
SERVICE_ID=$(balena inspect $(balena ps -qa --filter=name=${SERVICE_NAME}_*) | jq -r '.[].Config.Labels | to_entries[] | select(.key | contains("io.balena.service-id")) | .value')

# Run the tool
balena run --rm -ti -e UUID=$(cat /mnt/boot/config.json | jq -r .uuid) -e API_KEY=$(cat /mnt/boot/config.json | jq -r .deviceApiKey) -e SERVICE_ID=$SERVICE_ID ghcr.io/balena-os/log-streamer
```

## Environment Variables

| Name | Description | Required | Default Value |
| ------------- | -------------------------------------------------------------------- | -------- | ---------------------------- |
| UUID | UUID address of the balena device (for instance, from `config.json`) | true | |
| API_KEY | Device API key to use for authentication | true | |
| API_ENDPOINT | URL to use for testing | false | https://api.balena-cloud.com |
| INITIAL_DELAY | Delay in seconds to start the linear increase | false | 0 |
| DELTA_DELAY | Number of seconds to increase between iterations | false | 1 |