Skip to content

Commit

Permalink
fixed wording, spelling, Grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayclifford345 committed Mar 3, 2025
1 parent b3f516d commit 79692f4
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 73 deletions.
2 changes: 1 addition & 1 deletion workshops/course-tracker-test/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
}
},
"backend": {
"imageid": "ubuntu-rapid"
"imageid": "ubuntu"
}
}
6 changes: 3 additions & 3 deletions workshops/course-tracker-test/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This quick start guide will walk you through deploying Loki in [single binary mo

![Loki Stack](https://grafana.com/media/docs/loki/getting-started-loki-stack-3.png)

- **Loki**: A log aggregation system to store the collected logs. For more information on what Loki is, see [Loki overview](https://grafana.com/docs/loki/latest/get-started/overview/).
- **Alloy**: [Grafana Alloy](https://grafana.com/docs/alloy/latest/) is an open source telemetry collector for metrics, logs, traces and continuous profiles. In this quickstart guide Grafana Alloy has been configured to tail logs from all docker containers and forward them to Loki.

- **Alloy**: Grafana Alloy is an open source telemtry collector for metrics, logs, traces and continuous profiles. In this quickstart guide Grafana Alloy has been configured to tail logs from all docker containers and forward them to Loki.
- **Loki**: A log aggregation system to store the collected logs. For more information on what Loki is, see [Loki overview](https://grafana.com/docs/loki/latest/get-started/overview/).

- **Grafana**: Grafana is an open-source platform for monitoring and observability. Grafana will be used to query and vizualize on the logs stored in Loki.
- **Grafana**: [Grafana](https://grafana.com/docs/grafana/latest/) is an open-source platform for monitoring and observability. Grafana will be used to query and vizualize on the logs stored in Loki.
78 changes: 43 additions & 35 deletions workshops/course-tracker-test/preprocessed.md

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions workshops/course-tracker-test/step1.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Install the Loki stack
# Deploy the Loki stack

> **Note:**
> This quickstart assumes you are running Linux or MacOS. Windows users can follow the same steps using [WSL](https://learn.microsoft.com/en-us/windows/wsl/install).
**To install Loki locally, follow these steps:**
**To deploy the Loki stack locally, follow these steps:**

1. Clone the Loki fundamentals repository and checkout the getting-started branch:

Expand All @@ -23,15 +20,15 @@
docker compose up -d
```{{exec}}
At the end of the command, you should see something similar to the following:
After running the command, you should see a similar output:
```console
✔ Container loki-fundamentals-grafana-1 Started 0.3s
✔ Container loki-fundamentals-loki-1 Started 0.3s
✔ Container loki-fundamentals-alloy-1 Started 0.4s
```{{copy}}
With the Loki stack running, you can now verify component is up and running:
With the Loki stack running, you can now verify each component is up and running:
- **Alloy**: Open a browser and navigate to [http://localhost:12345/graph]({{TRAFFIC_HOST1_12345}}/graph). You should see the Alloy UI.
Expand Down
6 changes: 3 additions & 3 deletions workshops/course-tracker-test/step2.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Since Grafana Alloy is configured to tail logs from all docker containers, Loki should already be receiving logs. The best place to verify this is using the Grafana Drilldown Logs feature. To do navigate to [http://localhost:3000/a/grafana-lokiexplore-app]({{TRAFFIC_HOST1_3000}}/a/grafana-lokiexplore-app). You should see the Grafana Logs Drilldown page.
Since Grafana Alloy is configured to tail logs from all docker containers, Loki should already be receiving logs. The best place to verify log collection is using the Grafana Logs Drilldown feature. To do this navigate to [http://localhost:3000/a/grafana-lokiexplore-app]({{TRAFFIC_HOST1_3000}}/a/grafana-lokiexplore-app). You should see the Grafana Logs Drilldown page.

![Grafana Drilldown](https://grafana.com/media/docs/loki/get-started-drill-down.png)
![Grafana Logs Drilldown](https://grafana.com/media/docs/loki/get-started-drill-down.png)

If you have only the getting started demo deployed in your docker environment, you should see three containers and their logs; `loki-fundamentals-alloy-1`{{copy}}, `loki-fundamentals-grafana-1`{{copy}} and `loki-fundamentals-loki-1`{{copy}}. Click **Show Logs** within the `loki-fundamentals-loki-1`{{copy}} container to drill down into the logs for that container.

![Grafana Drilldown Service View](https://grafana.com/media/docs/loki/get-started-drill-down-container.png)

We will not cover the rest of the Grafana Drilldown Log features in this quickstart guide. For more information on how to use the Grafana Drilldown Logs feature, see [Drilldown Logs](https://grafana.com/docs/grafana/latest/explore/simplified-exploration/logs/get-started/).
We will not cover the rest of the Grafana Logs Drilldown features in this quickstart guide. For more information on how to use the Grafana Logs Drilldown feature, see [the getting started page](https://grafana.com/docs/grafana/latest/explore/simplified-exploration/logs/get-started/).
10 changes: 5 additions & 5 deletions workshops/course-tracker-test/step3.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Currently, the Loki stack is collecting logs about itself. To provide a more rea

- **Main App:** The main application that ties all the services together.

- **Database:** A database that stores user and plant data.
- **Database:** A Postgres database that stores user and plant data.

The architecture of the application is shown below:

![Getting started sample application](https://grafana.com/media/docs/loki/get-started-architecture.png)
![Sample Microservice Architecture](https://grafana.com/media/docs/loki/get-started-architecture.png)

To deploy the sample application, follow these steps:

Expand All @@ -31,7 +31,7 @@ To deploy the sample application, follow these steps:
> **Note:**
> This may take a few minutes to complete since the images for the sample application need to be built. Go grab a coffee and come back.
Once the command completes, you should see something similar to the following:
Once the command completes, you should see a similar output:
```console
✔ bug_service Built 0.0s
Expand All @@ -51,7 +51,7 @@ To deploy the sample application, follow these steps:
1. To verify the sample application is running, open a browser and navigate to [http://localhost:5005]({{TRAFFIC_HOST1_5005}}). You should see the login page for the Carnivorous Greenhouse application.
![Getting started sample application](https://grafana.com/media/docs/loki/get-started-login.png)
![Greenhouse Home Page](https://grafana.com/media/docs/loki/get-started-login.png)
Now that the sample application is running, run some actions in the application to generate logs. Here is a list of actions:
Expand All @@ -65,4 +65,4 @@ Your greenhouse should look something like this:
![Greenhouse Dashboard](https://grafana.com/media/docs/loki/get-started-greenhouse.png)
Now that you have generated some logs, you can view them in Grafana. To do this, navigate to [http://localhost:3000/a/grafana-lokiexplore-app]({{TRAFFIC_HOST1_3000}}/a/grafana-lokiexplore-app). You should see the Grafana Logs Drilldown page.
Now that you have generated some logs, you can return to the Grafana Logs Drilldown page [http://localhost:3000/a/grafana-lokiexplore-app]({{TRAFFIC_HOST1_3000}}/a/grafana-lokiexplore-app). You should see 7 new services such as `greenhouse-main_app-1`{{copy}}, `greenhouse-plant_service-1`{{copy}}, `greenhouse-user_service-1`{{copy}}, etc.
8 changes: 4 additions & 4 deletions workshops/course-tracker-test/step4.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Querying Logs

At this point, you have viewed logs using the Grafana Drilldown Logs feature. In many cases this will provide you with all the information you need. However, we can also manually query Loki to ask more advanced questions about the logs. This can be done via the **Grafana Explore**.
At this point, you have viewed logs using the Grafana Logs Drilldown feature. In many cases this will provide you with all the information you need. However, we can also manually query Loki to ask more advanced questions about the logs. This can be done via the **Grafana Explore**.

1. Open a browser and navigate to [http://localhost:3000]({{TRAFFIC_HOST1_3000}}) to open Grafana.

Expand All @@ -23,13 +23,13 @@ At this point, you have viewed logs using the Grafana Drilldown Logs feature. In

- [Code mode](https://grafana.com/docs/grafana/latest/datasources/loki/query-editor/#code-mode), which provides a feature-rich editor for writing LogQL queries.

Next we’ll walk through a few simple queries using both the builder and code views.
Next we’ll walk through a few queries using the code view.

1. Click **Code** (3) to work in Code mode in the query editor.

Here are some sample queries to get you started using LogQL. After copying any of these queries into the query editor, click **Run Query** (4) to execute the query.

1. View all the log lines which have the container label `greenhouse-main_app-1`{{copy}}:
1. View all the log lines which have the `container`{{copy}} label value `greenhouse-main_app-1`{{copy}}:

```bash
{container="greenhouse-main_app-1"}
Expand All @@ -45,5 +45,5 @@ At this point, you have viewed logs using the Grafana Drilldown Logs feature. In
1. Find all the log lines in the `{container="greenhouse-main_app-1"}`{{copy}} stream that contain the string `POST`{{copy}}:
```bash
{container="greenhouse-main_app-1"} |= `POST`
{container="greenhouse-main_app-1"} |= "POST"
```{{copy}}
23 changes: 18 additions & 5 deletions workshops/course-tracker-test/step5.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Extracting Attributes from Logs

Loki by design does not force log lines into a specific schema format. Whether you are using JSON, key-value pairs, or plain text, Logfmt, or any other format, Loki ingests these logs lines as a stream of characters. The sample application we are using stores logs in [Logfmt](https://brandur.org/logfmt) format:
Loki by design does not force log lines into a specific schema format. Whether you are using JSON, key-value pairs, plain text, Logfmt, or any other format, Loki ingests these logs lines as a stream of characters. The sample application we are using stores logs in [Logfmt](https://brandur.org/logfmt) format:

```bash
ts=2025-02-21 16:09:42,176 level=INFO line=97 msg="192.168.65.1 - - [21/Feb/2025 16:09:42] "GET /static/style.css HTTP/1.1" 304 -"
```{{copy}}
To break this down:
- `ts=2025-02-21 16:09:42,176`{{copy}} is the timestamp of the log line.
- `level=INFO`{{copy}} is the log level.
- `line=97`{{copy}} is the line number in the code.
- `msg="192.168.65.1 - - [21/Feb/2025 16:09:42] "GET /static/style.css HTTP/1.1" 304 -"`{{copy}} is the log message.
When querying Loki, you can pipe the result of the label selector through a formatter. This extracts attributes from the log line for further processing. For example lets pipe `{container="greenhouse-main_app-1"}`{{copy}} through the `logfmt`{{copy}} formatter to extract the `level`{{copy}} and `line`{{copy}} attributes:
```bash
Expand All @@ -14,11 +24,12 @@ When querying Loki, you can pipe the result of the label selector through a form
When you now expand a log line in the query result, you will see the extracted attributes.
**Before we move on** to the next section, let’s generate some error logs. To do this, enable the bug service in the sample application. This is done by setting the `Toggle Error Mode`{{copy}} to `On`{{copy}} in the Carnivorous Greenhouse application. This will cause the bug service to randomly cause services to fail.
> **Tip:**
> **Before we move on** to the next section, let’s generate some error logs. To do this, enable the bug service in the sample application. This is done by setting the `Toggle Error Mode`{{copy}} to `On`{{copy}} in the Carnivorous Greenhouse application. This will cause the bug service to randomly cause services to fail.
# Advanced and Metrics Queries
Now that are sample application is failing, we can query Loki to find the error logs. Lets start by parsing the logs to extract the `level`{{copy}} attribute and then filter for logs with a `level`{{copy}} of `ERROR`{{copy}}:
With Error Mode enabled the bug service will start causing services to fail, in these next few LogQL examples we will track down some of these errors. Lets start by parsing the logs to extract the `level`{{copy}} attribute and then filter for logs with a `level`{{copy}} of `ERROR`{{copy}}:
```bash
{container="greenhouse-plant_service-1"} | logfmt | level="ERROR"
Expand All @@ -32,10 +43,12 @@ This query will return all the logs from the `greenhouse-plant_service-1`{{copy}
This query will return all the logs from the `greenhouse-plant_service-1`{{copy}} container that have a `level`{{copy}} attribute of `ERROR`{{copy}} and a `line`{{copy}} attribute of `58`{{copy}}.
LogQL also supports metrics queries. Metrics are useful for abstracting the raw log data into a more manageable form. For example, you can use metrics to count the number of logs per second that have a specific attribute:
LogQL also supports metrics queries. Metrics are useful for abstracting the raw log data aggregating attributes into numeric values. This allows you to utilise more visualization options in Grafana as well as generate alerts on your logs.
For example, you can use a metric query to count the number of logs per second that have a specific attribute:
```bash
sum(rate({container="greenhouse-plant_service-1"} | logfmt | level=`ERROR` [$__auto]))
sum(rate({container="greenhouse-plant_service-1"} | logfmt | level="ERROR" [$__auto]))
```{{copy}}
Another example is to get the top 10 services producing the highest rate of errors:
Expand Down
7 changes: 6 additions & 1 deletion workshops/course-tracker-test/step6.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A look under the hood

At this point you will have a running Loki Stack and a sample application generating logs. You have also queried Loki using the Grafana Explore.
At this point you will have a running Loki Stack and a sample application generating logs. You have also queried Loki using Grafana Logs Drilldown and Grafana Explore.
In this next section we will take a look under the hood to understand how the Loki stack has been configured to collect logs, the Loki configuration file, and how the Loki datasource has been configured in Grafana.

## Grafana Alloy configuration
Expand Down Expand Up @@ -73,3 +73,8 @@ In this view you can see the components of the Alloy configuration file and how
- **loki.process**: This component provides stages for log transformation and extraction. In this case it adds a static label `env=production`{{copy}} to all logs.
- **loki.write**: This component writes the logs to Loki. It forwards the logs to the Loki endpoint `http://loki:3100/loki/api/v1/push`{{copy}}.
## View Logs in realtime
Grafana Alloy provides inbuilt realtime log viewer. This allows you to view current log entries and how they are being transformed via specific components of the pipeline.
To view live debugging mode open a browser tab and navigate to: [http://localhost:12345/debug/loki.process.getting_started]({{TRAFFIC_HOST1_12345}}/debug/loki.process.getting_started).
13 changes: 4 additions & 9 deletions workshops/course-tracker-test/step7.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# View Logs in realtime

Grafana Alloy provides inbuilt realtime log viewer. This allows you to view current log entries and how they are being transformed via specific components of the pipeline.
To view live debugging mode open a browser tab and navigate to: [http://localhost:12345/debug/loki.process.getting_started]({{TRAFFIC_HOST1_12345}}/debug/loki.process.getting_started).

Loki Configuration
# Loki Configuration

Grafana Loki requires a configuration file to define how it should run. Within the `loki-fundamentals`{{copy}} directory, you will find a file called `loki-config.yaml`{{copy}}:

Expand Down Expand Up @@ -71,19 +66,19 @@ compactor:
To summarize the configuration file:
- **auth_enabled**: This is set to false, meaning Loki does not a tennent ID for ingest or query.
- **auth_enabled**: This is set to false, meaning Loki does not need a [tennent ID](https://grafana.com/docs/loki/latest/operations/multi-tenancy/) for ingest or query.
- **server**: Defines the ports Loki listens on, the log level, and the maximum number of concurrent grpc streams.
- **common**: Defines the common configuration for Loki. This includes the instance address, storage configuration, replication factor, and ring configuration.
- **query_range**: This is defined to tell Loki to use inbuilt caching for query results. In production environments of Loki this is handled by a seperate cache service such as memcached.
- **limits_config**: Defines the global limits for all Loki tennents. This includes enabling specific features such as metric aggregation and structured metadata.
- **limits_config**: Defines the global limits for all Loki tennents. This includes enabling specific features such as metric aggregation and structured metadata. Limits can be defined on a per tennent basis, however this is considered an advanced configuration and for most usecases the global limits are sufficient.
- **schema_config**: Defines the schema configuration for Loki. This includes the schema version, the object store, and the index configuration.
- **pattern_ingester**: Enables pattern ingesters which are used to discover log patterns. Mostly used by Grafana Drilldown Logs.
- **pattern_ingester**: Enables pattern ingesters which are used to discover log patterns. Mostly used by Grafana Logs Drilldown.
- **ruler**: Enables the ruler component of Loki. This is used to create alerts based on log queries.
Expand Down

0 comments on commit 79692f4

Please sign in to comment.