Skip to content

Latest commit

 

History

History
122 lines (63 loc) · 3.72 KB

add-logging.md

File metadata and controls

122 lines (63 loc) · 3.72 KB

Zarf Components - Add Logging

This example demonstrates using 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 example game cluster by installing Zarf's "logging" component.

 

The Flow

Here's what you'll do in this example:

  1. Get ready

  2. Install the logging component

  3. Note the credentials

  4. Check the logs

  5. Cleanup

 

 

Get ready

This scenario builds upon the previous one, so:

  1. Run through the Zarf game example but stop when you're told to run zarf init

  2. Take a deep breath—because it's good for your body—and read on!

 

 

Install the logging component

Installing a Zarf component is really easy—you just have to let zarf init know that you want use it. That's it!

Exactly like when you first created the game example cluster, you move into the directory holding your init package and run:

cd <same dir as zarf-init-<arch>.tar.zst>
zarf init

You can answer the follow-on prompts in almost the exact same way as during your original install except this time answer "yes" when asked whether to install the "logging" component.

Give it some time for the new logging pods to come up and you're ready to go!

Note

Zarf supports non-interactive installs too! See zarf init --help for how to make that work.

 

Note the credentials

Go back to your terminal and review the zarf init command output—the very last thing printed should be a set of credentials Zarf has generated for you.

Pay attention to these because you're going to need them to log into your shiny, new Grafana installation.

The line you want will look something like this:

logging-creds

The ones under "Logging" are what you'll need.

 

Check the logs

We've only just installed the logging utilities so we (likely) haven't had time to record anything interesting. Since log aggregation & monitoring aren't worth much without something to collect, let's get some data in there.

 

Generate some traffic

Deploy the Game example again, then pull up the game in your brower—instructions here, in case you forgot how—and then reload the browser window a few times.

Doing that sends a bunch of HTTP traffic into the cluster & should give you something worth looking at in Grafana.

 

Get into Grafana

Now that you've got some logs worth looking at, you're ready to log into your brand new Grafana instance.

Get started by opening Grafana using zarf connect logging

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:

  1. The "Explore" page (Button on the left that looks like a compass)

  2. you can select Loki in the dropdown, and then

  3. 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. Neat!

 

Cleanup

Once you've had your fun it's time to clean up.

In this case, since the Zarf cluster was installed specifically (and only) to serve this example, clean up is really easy—you just tear down the entire cluster:

kind delete cluster

It takes just a couple moments for the entire cluster to disappear—long-running system services and all—leaving your machine squeaky clean.