Simulating logs with flog
As-is, this is a fairly limited view of Loki’s capabilities, largely because we haven’t fed it some real logging to work with. Let’s fix that by first adding some live logs and then configuring Promtail to scrape them. Taking a cue from the Loki documentation, we’ll use an open source logging generator called flog
to generate fake logging. Next, we’ll create a configuration file for Promtail that will scrape those logs in real time.
flog
is available as a Docker container, so we just need to add it as a service to our docker-compose.yml
file:
flog: image: mingrammer/flog:latest command: -l -d 1
The service entry for flog
is very simple: pull the latest image and run it with the -l
command-line option for continuous looping, and -d 1
to run with a delay interval of 1 second so that we don’t overwhelm Promtail.