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.
- Zarf binary installed on your $PATH: (Installing Zarf)
- Initialize a cluster.
- Perform the Retro Arcade Tutorial.
- Run the
zarf init
command on your cluster.
- When prompted to deploy the package select
y
for Yes, then hit theenter
key.
When prompted to deploy the logging component selecty
for Yes, then hit theenter
key.
- You can automatically accept the logging component, and confirm the package using the
--confirm
and--components
flags.
- Review the
zarf init
command output for the following:
You should see a section for Logging
. You will need these credentials later on.
- 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.
Once you’ve successfully logged in go to:
- The “Explore” page (Button on the left that looks like a compass)
- Select
Loki
in the dropdown, and then - Enter
{app="game"}
into the Log Browser query input field
Submit that query and you’ll get back a dump of all the game pod logs that Loki has collected.
- 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.
- Use the
zarf package remove
command to remove thelogging
component from the init package. Don’t forget the--confirm
flag. Otherwise you’ll receive an error.