Skip to content

Add Logging to a Cluster

In this tutorial, we are going to show how you can use a Zarf component to inject zero-config, centralized logging into your Zarf cluster.

More specifically, you’ll be adding a Promtail / Loki / Grafana (PLG) stack to the Retro Arcade Tutorial by installing Zarf’s “logging” component.

  • You’ll need an internet connection to grab the Zarf Init Package if it’s not already on your machine.

Prior to this tutorial you’ll want to have a working cluster with Zarf initialized.

  1. Run the zarf init command on your cluster.
Terminal window
$ zarf init
  1. When prompted to deploy the package select y for Yes, then hit the enter key.
    When prompted to deploy the logging component select y for Yes, then hit the enter key.
  1. You can automatically accept the logging component, and confirm the package using the --confirm and --components flags.

  1. Review the zarf init command output for the following:

You should see a section for Logging. You will need these credentials later on.

  1. If you haven’t already in the prerequisites, deploy the Retro Arcade Tutorial.

To open Grafana you can use the zarf connect logging command.

You’ll be redirected the /login page where you have to sign in with the Grafana credentials you saved in a previous step.

zarf user logging into Loki

Once you’ve successfully logged in go to:

  1. The “Explore” page (Button on the left that looks like a compass)
  2. Select Loki in the dropdown, and then
  3. Enter {app="game"} into the Log Browser query input field

zarf user typing app='game' into the Loki Log Browser

Submit that query and you’ll get back a dump of all the game pod logs that Loki has collected.

Loki query results

  1. Use the zarf package list command to get a list of the installed packages and their components. This will give you the name of the init package and the logging component to remove it.
  1. Use the zarf package remove command to remove the logging component from the init package. Don’t forget the --confirm flag. Otherwise you’ll receive an error.