Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/grafana/killercoda into …
Browse files Browse the repository at this point in the history
…staging
  • Loading branch information
Jayclifford345 committed Dec 9, 2024
2 parents 8ddc65e + 0c9fe22 commit 5cfe679
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 49 deletions.
35 changes: 18 additions & 17 deletions alloy/send-logs-to-loki/preprocessed.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To complete this tutorial:
* You should be familiar with Prometheus, PromQL, Loki, LogQL, and basic Grafana navigation.
<!-- INTERACTIVE ignore START -->
> **Tip:**
> Alternatively, you can try out this example in our interactive learning environment: [Sending Logs to Loki](https://killercoda.com/grafana-labs/course/alloy/send-logs-to-loki).
> Alternatively, you can try out this example in the interactive learning environment: [Sending Logs to Loki](https://killercoda.com/grafana-labs/course/alloy/send-logs-to-loki).
>
> It's a fully configured environment with all the dependencies already installed.
>
Expand All @@ -66,9 +66,11 @@ Install and run Alloy on Linux.

1. [Install Alloy][Linux Install].
1. To view the Alloy UI within the sandbox, Alloy must run on all interfaces. Run the following command before you start the Alloy service.

```bash
sed -i -e 's/CUSTOM_ARGS=""/CUSTOM_ARGS="--server.http.listen-addr=0.0.0.0:12345"/' /etc/default/alloy
```

1. [Run Alloy][Run on Linux].

<!-- INTERACTIVE ignore START -->
Expand All @@ -81,7 +83,7 @@ Install and run Alloy on macOS.
1. [Run Alloy][Run on macOS].
<!-- INTERACTIVE ignore END -->

You should now be able to access the Alloy UI at [http://localhost:12345](http://localhost:12345).
You can access the Alloy UI at [http://localhost:12345](http://localhost:12345).

<!-- INTERACTIVE page step1.md END -->

Expand All @@ -95,7 +97,7 @@ This Docker Compose file includes Loki and Prometheus configured as data sources

> The interactive sandbox has a VSCode-like editor that allows you to access files and folders. To access this feature, click on the `Editor` tab. The editor also has a terminal that you can use to run commands. Since some commands assume you are within a specific directory, we recommend running the commands in `tab1`.
1. Create a new directory and save the Docker Compose file as `docker-compose.yml`.
1. Create a directory and save the Docker Compose file as `docker-compose.yml`.

```bash
mkdir alloy-tutorial
Expand Down Expand Up @@ -209,6 +211,7 @@ This configuration creates a [local.file_match][] component named `local_files`
### Second component: Scraping

Copy and paste the following component configuration below the previous component in your `config.alloy` file:

```alloy
loki.source.file "log_scrape" {
targets = local.file_match.local_files.targets
Expand All @@ -217,7 +220,7 @@ Copy and paste the following component configuration below the previous componen
}
```

This configuration creates a [loki.source.file][] component named `log_scrape` which does the following:
This configuration creates a [`loki.source.file`][loki.source.file] component named `log_scrape` which does the following:

* It connects to the `local_files` component as its source or target.
* It forwards the logs it scrapes to the receiver of another component called `filter_logs`.
Expand All @@ -230,6 +233,7 @@ Filtering non-essential logs before sending them to a data source can help you m
The following example demonstrates how you can filter out or drop logs before sending them to Loki.

Copy and paste the following component configuration below the previous component in your `config.alloy` file:

```alloy
loki.process "filter_logs" {
stage.drop {
Expand All @@ -244,15 +248,15 @@ Copy and paste the following component configuration below the previous componen
The `loki.process` component allows you to transform, filter, parse, and enrich log data.
Within this component, you can define one or more processing stages to specify how you would like to process log entries before they're stored or forwarded.

This configuration creates a [loki.process][] component named `filter_logs` which does the following:
This configuration creates a [`loki.process`][loki.process] component named `filter_logs` which does the following:

* It receives scraped log entries from the default `log_scrape` component.
* It uses the `stage.drop` block to define what to drop from the scraped logs.
* It uses the `expression` parameter to identify the specific log entries to drop.
* It uses an optional string label `drop_counter_reason` to show the reason for dropping the log entries.
* It forwards the processed logs to the receiver of another component called `grafana_loki`.

The [`loki.process` documentation][loki.process] provides more comprehensive information on processing logs.
The [`loki.process`][loki.process] documentation provides more comprehensive information on processing logs.

### Fourth component: Write logs to Loki

Expand Down Expand Up @@ -295,9 +299,11 @@ With this configuration, Alloy connects directly to the Loki instance running in

1. Copy your local `config.alloy` file into the default Alloy configuration file location.

```bash

```bash
sudo cp config.alloy /etc/alloy/config.alloy
```


<!-- INTERACTIVE ignore START -->
{{< code >}}
Expand All @@ -322,21 +328,22 @@ With this configuration, Alloy connects directly to the Loki instance running in
> **Tip:**
> This step uses the Alloy UI on `localhost` port `12345`.
> If you chose to run Alloy in a Docker container, make sure you use the `--server.http.listen-addr=0.0.0.0:12345` argument.
> If you dont use this argument, the [debugging UI][debug] wont be available outside of the Docker container.
> If you don't use this argument, the [debugging UI][debug] won't be available outside of the Docker container.
[debug]: https://grafana.com/docs/alloy/latest/troubleshoot/debug/#alloy-ui
<!-- INTERACTIVE ignore END -->


> This step uses the Alloy UI on `localhost` port `12345`. If you chose to run Alloy in a Docker container, make sure you use the `--server.http.listen-addr=` argument. If you dont use this argument, the [debugging UI](https://grafana.com/docs/alloy/latest/troubleshoot/debug/#alloy-ui) wont be available outside of the Docker container.
> This step uses the Alloy UI on `localhost` port `12345`. If you chose to run Alloy in a Docker container, make sure you use the `--server.http.listen-addr=` argument. If you don't use this argument, the [debugging UI](https://grafana.com/docs/alloy/latest/troubleshoot/debug/#alloy-ui) won't be available outside of the Docker container.


1. Optional: You can do a system service restart Alloy and load the configuration file.



```bash
sudo systemctl reload alloy
```

<!-- INTERACTIVE ignore START -->
{{< code >}}

Expand Down Expand Up @@ -388,7 +395,6 @@ In the [next tutorial][], you learn more about configuration concepts and metric

<!-- INTERACTIVE page finish.md END -->


[MacOS Install]: https://grafana.com/docs/alloy/latest/set-up/install/macos/
[Linux Install]: https://grafana.com/docs/alloy/latest/set-up/install/linux/
[Run on Linux]: https://grafana.com/docs/alloy/latest/set-up/run/linux/
Expand All @@ -397,10 +403,5 @@ In the [next tutorial][], you learn more about configuration concepts and metric
[loki.write]: https://grafana.com/docs/alloy/latest/reference/components/loki/loki.write/
[loki.source.file]: https://grafana.com/docs/alloy/latest/reference/components/loki/loki.source.file/
[loki.process]: https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/
[alloy]: https://grafana.com/docs/alloy/latest/
[configuration]: https://grafana.com/docs/alloy/latest/concepts/configuration-syntax/
[install]: https://grafana.com/docs/alloy/latest/get-started/install/binary/#install-alloy-as-a-standalone-binary
[debugging your configuration]: https://grafana.com/docs/alloy/latest/troubleshoot/debug/
[parse]: https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/
[next tutorial]: https://grafana.com/docs/alloy/latest/tutorials/send-metrics-to-prometheus/
[loki.process]: https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/
3 changes: 2 additions & 1 deletion alloy/send-logs-to-loki/step1.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ Install and run Alloy on Linux.
1. [Install Alloy](https://grafana.com/docs/alloy/latest/set-up/install/linux/).

1. To view the Alloy UI within the sandbox, Alloy must run on all interfaces. Run the following command before you start the Alloy service.

```bash
sed -i -e 's/CUSTOM_ARGS=""/CUSTOM_ARGS="--server.http.listen-addr=0.0.0.0:12345"/' /etc/default/alloy
```{{exec}}
1. [Run Alloy](https://grafana.com/docs/alloy/latest/set-up/run/linux/).
You should now be able to access the Alloy UI at [http://localhost:12345]({{TRAFFIC_HOST1_12345}}).
You can access the Alloy UI at [http://localhost:12345]({{TRAFFIC_HOST1_12345}}).
2 changes: 1 addition & 1 deletion alloy/send-logs-to-loki/step2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This Docker Compose file includes Loki and Prometheus configured as data sources

> The interactive sandbox has a VSCode-like editor that allows you to access files and folders. To access this feature, click on the `Editor`{{copy}} tab. The editor also has a terminal that you can use to run commands. Since some commands assume you are within a specific directory, we recommend running the commands in `tab1`{{copy}}.
1. Create a new directory and save the Docker Compose file as `docker-compose.yml`{{copy}}.
1. Create a directory and save the Docker Compose file as `docker-compose.yml`{{copy}}.

```bash
mkdir alloy-tutorial
Expand Down
6 changes: 3 additions & 3 deletions alloy/send-logs-to-loki/step3.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Copy and paste the following component configuration below the previous componen
}
```{{copy}}
This configuration creates a [loki.source.file](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.source.file/) component named `log_scrape`{{copy}} which does the following:
This configuration creates a [`loki.source.file`{{copy}}](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.source.file/) component named `log_scrape`{{copy}} which does the following:
- It connects to the `local_files`{{copy}} component as its source or target.
Expand Down Expand Up @@ -73,7 +73,7 @@ Copy and paste the following component configuration below the previous componen
The `loki.process`{{copy}} component allows you to transform, filter, parse, and enrich log data.
Within this component, you can define one or more processing stages to specify how you would like to process log entries before they’re stored or forwarded.
This configuration creates a [loki.process](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/) component named `filter_logs`{{copy}} which does the following:
This configuration creates a [`loki.process`{{copy}}](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/) component named `filter_logs`{{copy}} which does the following:
- It receives scraped log entries from the default `log_scrape`{{copy}} component.
Expand All @@ -85,7 +85,7 @@ This configuration creates a [loki.process](https://grafana.com/docs/alloy/lates
- It forwards the processed logs to the receiver of another component called `grafana_loki`{{copy}}.
The [`loki.process`{{copy}} documentation](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/) provides more comprehensive information on processing logs.
The [`loki.process`{{copy}}](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/) documentation provides more comprehensive information on processing logs.
## Fourth component: Write logs to Loki
Expand Down
17 changes: 10 additions & 7 deletions alloy/send-metrics-to-prometheus/preprocessed.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ To complete this tutorial:

<!-- INTERACTIVE ignore START -->
> **Tip:**
> Alternatively, you can try out this example in our interactive learning environment: [Sending metrics to Prometheus](https://killercoda.com/grafana-labs/course/alloy/send-metrics-to-prometheus).
> Alternatively, you can try out this example in the interactive learning environment: [Sending metrics to Prometheus](https://killercoda.com/grafana-labs/course/alloy/send-metrics-to-prometheus).
>
> It's a fully configured environment with all the dependencies already installed.
>
Expand Down Expand Up @@ -165,9 +165,11 @@ This connects directly to the Prometheus instance running in the Docker containe

Copy your local `config.alloy` file into the default Alloy configuration file location.


```bash
sudo cp config.alloy /etc/alloy/config.alloy
```

<!-- INTERACTIVE ignore START -->
{{< code >}}

Expand All @@ -178,6 +180,7 @@ sudo cp config.alloy $(brew --prefix)/etc/alloy/config.alloy
```linux
sudo cp config.alloy /etc/alloy/config.alloy
```

{{< /code >}}
<!-- INTERACTIVE ignore END -->

Expand All @@ -192,21 +195,23 @@ curl -X POST http://localhost:12345/-/reload
> This step uses the Alloy UI, on `localhost` port `12345`.
> If you choose to run Alloy in a Docker container, make sure you use the `--server.http.listen-addr=0.0.0.0:12345` argument.
>
> If you dont use this argument, the [debugging UI][debug] wont be available outside of the Docker container.
> If you don't use this argument, the [debugging UI][debug] won't be available outside of the Docker container.
[debug]: https://grafana.com/docs/alloy/latest/troubleshoot/debug/#alloy-ui
<!-- INTERACTIVE ignore END -->


> This step uses the Alloy UI on `localhost` port `12345`. If you chose to run Alloy in a Docker container, make sure you use the `--server.http.listen-addr=` argument. If you dont use this argument, the [debugging UI](https://grafana.com/docs/alloy/latest/troubleshoot/debug/#alloy-ui) wont be available outside of the Docker container.
> This step uses the Alloy UI on `localhost` port `12345`. If you chose to run Alloy in a Docker container, make sure you use the `--server.http.listen-addr=` argument. If you don't use this argument, the [debugging UI](https://grafana.com/docs/alloy/latest/troubleshoot/debug/#alloy-ui) won't be available outside of the Docker container.

Optional: You can do a system service restart Alloy and load the configuration file:


```bash
sudo systemctl reload alloy
```


<!-- INTERACTIVE ignore START -->
{{< code >}}

Expand Down Expand Up @@ -244,20 +249,18 @@ You can see that the components are healthy, and you are ready to explore the me

Open [http://localhost:3000/explore/metrics/](http://localhost:3000/explore/metrics/) to access the **Explore Metrics** feature in Grafana.

From here you can visually explore the metrics that are being sent to Prometheus by Alloy.
From here you can visually explore the metrics sent to Prometheus by Alloy.

{{< figure src="/media/docs/alloy/explore-metrics.png" alt="Explore Metrics App" >}}

You can also build promQL queries manually to explore the data further.
You can also build PromQL queries manually to explore the data further.

Open [http://localhost:3000/explore](http://localhost:3000/explore) to access the **Explore** feature in Grafana.

Select Prometheus as the data source and click the **Metrics Browser** button to select the metric, labels, and values for your labels.

Here you can see that metrics are flowing through to Prometheus as expected, and the end-to-end configuration was successful.



<!-- INTERACTIVE page step4.md END -->

<!-- INTERACTIVE page finish.md START -->
Expand Down
4 changes: 2 additions & 2 deletions alloy/send-metrics-to-prometheus/step4.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Open [http://localhost:3000/explore/metrics/]({{TRAFFIC_HOST1_3000}}/explore/metrics/) to access the **Explore Metrics** feature in Grafana.

From here you can visually explore the metrics that are being sent to Prometheus by Alloy.
From here you can visually explore the metrics sent to Prometheus by Alloy.

![Explore Metrics App](https://grafana.com/media/docs/alloy/explore-metrics.png)

You can also build promQL queries manually to explore the data further.
You can also build PromQL queries manually to explore the data further.

Open [http://localhost:3000/explore]({{TRAFFIC_HOST1_3000}}/explore) to access the **Explore** feature in Grafana.

Expand Down
18 changes: 9 additions & 9 deletions tempo/quick-start/preprocessed.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,35 +115,35 @@ You can use Grafana to explore the traces generated by the k6-tracing service.

<!-- INTERACTIVE page step3.md START -->

## Explore Traces Plugin
## Explore Traces plugin

Another method to explore traces within Grafana is via the [Explore Traces](https://grafana.com/docs/grafana/latest/explore/simplified-exploration/traces/) plugin. This plugin offers an opinionated non query-based approach to exploring traces. Lets take a look at some of its key features and panels.
The [Explore Traces](https://grafana.com/docs/grafana/latest/explore/simplified-exploration/traces/) plugin offers an opinionated non query-based approach to exploring traces. Lets take a look at some of its key features and panels.

1. Open a browser and navigate to [http://localhost:3000/a/grafana-exploretraces-app](http://localhost:3000/a/grafana-exploretraces-app).
2. Within the filter bar there is a dropdown menu set to `Rate` of `Full traces`. Change this to `Duration` and `All spans`.
2. Within the filter bar, there is a dropdown menu set to **Rate** of **Full traces**. Change this to **Duration** and **All spans**.

This should provide an updated panel view like this.
This updated panel view looks like this:

{{< figure align="center" src="/media/docs/tempo/explore-spans-error-view.png" alt="Explore Traces panel" >}}

Breakdown of the view:
* The histogram at the top shows the distribution of span durations. The lighter the color, the more spans in that duration bucket. In this example most spans fall within `537ms` which is considered the average duration for the system.
* There are some high peaks in the histogram, which indicate spans that are taking longer than the average (As high as `2.15s`). These are likely to be the spans that are causing performance issues. Lets investigate further to see if we can identify the root cause.
* The histogram at the top shows the distribution of span durations. The lighter the color, the more spans in that duration bucket. In this example, most spans fall within `537ms`, which is considered the average duration for the system.
* The high peaks in the histogram indicate spans that are taking longer than the average (As high as `2.15s`). These are likely to be the spans that are causing performance issues. You can investigate further to identify the root cause.

Select `Slow traces` tab in the navigation bar to view the slowest traces in the system.

{{< figure align="center" src="/media/docs/tempo/slow-trace-view.png" alt="Slow traces panel" >}}

`shop-backend` appears to be the primary culprit for the slow traces. This happens when a user initiates the `article-to-cart` operation. From here we can select the Trace Name which will open the Trace View panel.
`shop-backend` appears to be the primary culprit for the slow traces. This happens when a user initiates the `article-to-cart` operation. From here, you can select the **Trace Name** to open the **Trace View** panel.

{{< figure align="center" src="/media/docs/tempo/slow-trace-trace-view.png" alt="Trace View panel" >}}

The Trace View panel provides a detailed view of the trace. The panel is divided into three sections:
The **Trace View** panel provides a detailed view of the trace. The panel is divided into three sections:
* The top section shows the trace ID, duration, and the service that generated the trace.
* The middle section shows the trace timeline. Each span is represented as a horizontal bar. The color of the bar represents the span's status. The width of the bar represents the duration of the span.
* The bottom section shows the details of the selected span. This includes the span name, duration, and tags.
Drilling into the `shop-backend` span, we can see that the `place-articles` operation has an exception event tied to it. This is likely the root cause of the slow trace.
Drilling into the `shop-backend` span, you can see that the `place-articles` operation has an exception event tied to it. This is likely the root cause of the slow trace.
{{< figure align="center" src="/media/docs/tempo/slow-trace-root-cause-2.png" alt="Span View panel" >}}
Expand Down
Loading

0 comments on commit 5cfe679

Please sign in to comment.