Simple NodeJS log generator app for Datadog logs experiments.
- NodeJS 11.0 or superior
This app generates logs based on some pre-defined templates.
Templates are divided in success templates and error templates. Both can be found in data/
folder under the respective type.
A success log round selects, randomly, one log from each kind in the following order:
- driverFound
- paymentSubmitted
- paymentAccepted
- rideCreated
All the four logs are dispatched in the order above and all of them contains the same context_id
, generated randomly by the system.
An error log round selects, randomly, one log from each kind in the following order:
- driverFound
- paymentSubmitted
- paymentFailed
... or ...
- noDriverAvailable
All the logs are dispatched in the order above and all of them contains the same context_id
, generated randomly by the system.
This app requires two parameters, provided by environment variables:
LOG_INTERVAL_IN_MS
: the interval (in ms) between the logs production. Interval honoring isn't guaranteed, but since the log generation process is simple, the log overhead can be ignored.ERROR_RATE
: the error rate (float between 0 and 1), defining the probabilistic occurrence of error logs. Setting to zero disables error logs, while setting to one generates exclusively error logs.
$ LOG_INTERVAL_IN_MS=100 ERROR_RATE=0.25 npm start
# Build the Docker image
$ docker build -t mauricioklein/loggen .
# ... or use the publicly available image: https://hub.docker.com/r/mauricioklein/loggen/
# Start the container
$ docker run \
-e LOG_INTERVAL_IN_MS=100 \
-e ERROR_RATE=0.25 \
-it mauricioklein/loggen
A public Docker image is available on DockerHub and can be used to deploy the app on K8s:
# Creates a single pod, not managed by a deployment
$ kubectl run loggen \
--image mauricioklein/loggen:1.0.0 \
--env LOG_INTERVAL_IN_MS=250 \
--env ERROR_RATE=0.25 \
--restart=Never