Skip to content

Commit

Permalink
Merge pull request #229 from grafana/staging
Browse files Browse the repository at this point in the history
Chore: Staging to Prod
  • Loading branch information
Jayclifford345 authored Mar 10, 2025
2 parents 52910d4 + c9cdec3 commit 886d603
Show file tree
Hide file tree
Showing 22 changed files with 998 additions and 578 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/regenerate-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ jobs:
"${GITHUB_WORKSPACE}/loki/docs/sources/query/logcli/logcli-tutorial.md"
"${GITHUB_WORKSPACE}/killercoda/loki/logcli-tutorial"
working-directory: killercoda/tools/transformer
- run: >
./transformer
"${GITHUB_WORKSPACE}/loki/docs/sources/send-data/k8s-monitoring-helm/_index.md"
"${GITHUB_WORKSPACE}/killercoda/loki/k8s-monitoring-helm"
working-directory: killercoda/tools/transformer
- run: >
./transformer
"${GITHUB_WORKSPACE}/grafana/docs/sources/tutorials/alerting-get-started/index.md"
Expand Down
2 changes: 2 additions & 0 deletions loki/alloy-kafka-logs/preprocessed.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ menuTitle: Sending Logs to Loki via Kafka using Alloy
description: Configuring Grafana Alloy to receive logs via Kafka and send them to Loki.
weight: 250
killercoda:
comment: |
This file is used to generate the interactive tutorial for sending logs to Loki via Kafka using Alloy. Please do not change url's with placeholders from the code snippets. This tutorial is assumes they remain static.
title: Sending Logs to Loki via Kafka using Alloy
description: Configuring Grafana Alloy to receive logs via Kafka and send them to Loki.
backend:
Expand Down
2 changes: 2 additions & 0 deletions loki/alloy-otel-logs/preprocessed.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ menuTitle: Sending OpenTelemetry logs to Loki using Alloy
description: Configuring Grafana Alloy to send OpenTelemetry logs to Loki.
weight: 250
killercoda:
comment: |
This file is used to generate the interactive tutorial for sending logs to Loki via otel using Alloy. Please do not change url's with placeholders from the code snippets. This tutorial is assumes they remain static.
title: Sending OpenTelemetry logs to Loki using Alloy
description: Configuring Grafana Alloy to send OpenTelemetry logs to Loki.
backend:
Expand Down
20 changes: 10 additions & 10 deletions loki/k8s-monitoring-helm/preprocessed.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ helm install --values grafana-values.yml grafana grafana/grafana --namespace met

As before, the command also includes a `values` file that specifies the configuration for Grafana. There are two important configuration attributes to take note of:

1. `adminUser` and `adminPassword`: These are the credentials you will use to log in to Grafana. The values are `admin` and `adminadminadmin` respectively. The recommended practice is to either use a Kubernetes secret or allow Grafana to generate a password for you. For more details on how to configure the Grafana Helm chart, refer to the Grafana Helm [documentation](https://grafana.com/docs/grafana/latest/installation/helm/).
1. `adminUser` and `adminPassword`: These are the credentials you will use to log in to Grafana. The values are `admin` and `adminadminadmin` respectively. The recommended practice is to either use a Kubernetes secret or allow Grafana to generate a password for you. For more details on how to configure the Grafana Helm chart, refer to the Grafana Helm [documentation](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/installation/helm/).

2. `datasources`: This section of the configuration lets you define the data sources that Grafana should use. In this tutorial, you will define a Loki data source. The data source is defined as follows:

Expand All @@ -163,12 +163,12 @@ As before, the command also includes a `values` file that specifies the configur

## Deploy the Kubernetes Monitoring Helm chart

The Kubernetes Monitoring Helm chart is used for gathering, scraping, and forwarding Kubernetes telemetry data to a Grafana stack. This includes the ability to collect metrics, logs, traces, and continuous profiling data. The scope of this tutorial is to deploy the Kubernetes Monitoring Helm chart to collect pod logs and Kubernetes events.
The Kubernetes Monitoring Helm chart is used for gathering, scraping, and forwarding Kubernetes telemetry data to a Grafana stack. This includes the ability to collect metrics, logs, traces, and continuous profiling data. The scope of this tutorial is to deploy the Kubernetes Monitoring Helm chart to collect pod logs and Kubernetes events.

To deploy the Kubernetes Monitoring Helm chart run the following command:

```bash
helm install --values ./k8s-monitoring-values.yml k8s grafana/k8s-monitoring -n meta
helm install --values ./k8s-monitoring-values.yml k8s grafana/k8s-monitoring -n meta
```
Within the configuration file `k8s-monitoring-values.yml` we have defined the following:

Expand Down Expand Up @@ -254,20 +254,20 @@ kubectl --namespace meta port-forward $POD_NAME 3000 --address 0.0.0.0
> **Tip:**
> This will make your terminal unusable until you stop the port-forwarding process. To stop the process, press `Ctrl + C`.

This command will port-forward the Grafana service to your local machine on port `3000`.
This command will port-forward the Grafana service to your local machine on port `3000`.

You can now access Grafana by navigating to [http://localhost:3000](http://localhost:3000) in your browser. The default credentials are `admin` and `adminadminadmin`.
You can now access Grafana by navigating to [http://localhost:3000](http://localhost:3000) in your browser. The default credentials are `admin` and `adminadminadmin`.

One of the first places you should visit is Explore Logs which lets you automatically visualize and explore your logs without having to write queries:
One of the first places you should visit is Logs Drilldown which lets you automatically visualize and explore your logs without having to write queries:
[http://localhost:3000/a/grafana-lokiexplore-app](http://localhost:3000/a/grafana-lokiexplore-app)

{{< figure max-width="100%" src="/media/docs/loki/k8s-logs-explore-logs.png" caption="Explore Logs view of K8s logs" alt="Explore Logs view of K8s logs" >}}
{{< figure max-width="100%" src="/media/docs/loki/k8s-logs-explore-logs.png" caption="Logs Drilldown view of K8s logs" alt="Logs Drilldown view of K8s logs" >}}

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

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

## (Optional): View the Alloy UI
## (Optional) View the Alloy UI

The Kubernetes Monitoring Helm chart deploys Grafana Alloy to collect and forward telemetry data from the Kubernetes cluster. The Helm chart is designed to abstract you away from creating an Alloy configuration file. However if you would like to understand the pipeline you can view the Alloy UI. To access the Alloy UI, you will need to port-forward the Alloy service to your local machine. To do this, run the following command:

Expand Down Expand Up @@ -315,8 +315,8 @@ and navigate to [http://localhost:3000/a/grafana-lokiexplore-app](http://localho

In this tutorial, you learned how to deploy Loki, Grafana, and the Kubernetes Monitoring Helm chart to collect and store logs from a Kubernetes cluster. We have deployed a minimal test version of each of these Helm charts to demonstrate how quickly you can get started with Loki. It is now worth exploring each of these Helm charts in more detail to understand how to scale them to meet your production needs:

* [Loki Helm chart](https://grafana.com/docs/loki/latest/setup/install/helm/)
* [Grafana Helm chart](https://grafana.com/docs/grafana/latest/installation/helm/)
* [Loki Helm chart](https://grafana.com/docs/loki/<LOKI_VERSION>/setup/install/helm/)
* [Grafana Helm chart](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/installation/helm/)
* [Kubernetes Monitoring Helm chart](https://grafana.com/docs/grafana-cloud/monitor-infrastructure/kubernetes-monitoring/)


Expand Down
2 changes: 1 addition & 1 deletion loki/k8s-monitoring-helm/step5.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Kubernetes Monitoring Helm chart is used for gathering, scraping, and forwar
To deploy the Kubernetes Monitoring Helm chart run the following command:

```bash
helm install --values ./k8s-monitoring-values.yml k8s grafana/k8s-monitoring -n meta
helm install --values ./k8s-monitoring-values.yml k8s grafana/k8s-monitoring -n meta
```{{exec}}
Within the configuration file `k8s-monitoring-values.yml`{{copy}} we have defined the following:
Expand Down
4 changes: 2 additions & 2 deletions loki/k8s-monitoring-helm/step6.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This command will port-forward the Grafana service to your local machine on port
You can now access Grafana by navigating to [http://localhost:3000]({{TRAFFIC_HOST1_3000}}) in your browser. The default credentials are `admin`{{copy}} and `adminadminadmin`{{copy}}.
One of the first places you should visit is Explore Logs which lets you automatically visualize and explore your logs without having to write queries:
One of the first places you should visit is Logs Drilldown which lets you automatically visualize and explore your logs without having to write queries:
[http://localhost:3000/a/grafana-lokiexplore-app]({{TRAFFIC_HOST1_3000}}/a/grafana-lokiexplore-app)
![Explore Logs view of K8s logs](https://grafana.com/media/docs/loki/k8s-logs-explore-logs.png)
![Logs Drilldown view of K8s logs](https://grafana.com/media/docs/loki/k8s-logs-explore-logs.png)
2 changes: 1 addition & 1 deletion loki/k8s-monitoring-helm/step7.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (Optional): View the Alloy UI
# (Optional) View the Alloy UI

The Kubernetes Monitoring Helm chart deploys Grafana Alloy to collect and forward telemetry data from the Kubernetes cluster. The Helm chart is designed to abstract you away from creating an Alloy configuration file. However if you would like to understand the pipeline you can view the Alloy UI. To access the Alloy UI, you will need to port-forward the Alloy service to your local machine. To do this, run the following command:

Expand Down
22 changes: 22 additions & 0 deletions tools/alloy-proxy/config.alloy
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Receives Logss over HTTP
loki.write "local" {
endpoint {
url = "https://logs-prod-021.grafana.net/loki/api/v1/push"
Expand All @@ -19,4 +20,25 @@ loki.source.api "loki_push_api" {
labels = {
forwarded = "true",
}
}

// Receives metrics over HTTP
prometheus.receive_http "api" {
http {
listen_address = "0.0.0.0"
listen_port = 9998
}
forward_to = [prometheus.remote_write.local.receiver]
}

// Send metrics to a locally running Mimir.
prometheus.remote_write "local" {
endpoint {
url = "https://prometheus-prod-36-prod-us-west-0.grafana.net/api/prom/push"

basic_auth {
username = sys.env("GRAFANA-CLOUD-USERNAME-METRICS")
password = sys.env("GRAFANA_CLOUD_PASSWORD")
}
}
}
24 changes: 12 additions & 12 deletions workshops/course-tracker-test/finish.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Summary

In this example, we configured the OpenTelemetry Collector to receive logs from an example application and send them to Loki using the native OTLP endpoint. Make sure to also consult the Loki configuration file `loki-config.yaml`{{copy}} to understand how we have configured Loki to receive logs from the OpenTelemetry Collector.
# What next?

## Back to docs

Head back to where you started from to continue with the [Loki documentation](https://grafana.com/docs/loki/latest/send-data/otel).
Head back to where you started from to continue with the Loki documentation: [Loki documentation](https://grafana.com/docs/loki/latest/get-started/quick-start/).

# Further reading
You have completed the Loki Quickstart demo. So where to go next? Here are a few suggestions:

For more information on the OpenTelemetry Collector and the native OTLP endpoint of Loki, refer to the following resources:
- **Deploy:** Loki can be deployed in multiple ways. For production usecases we recommend deploying Loki via the [Helm chart](https://grafana.com/docs/loki/latest/setup/install/helm/).

- [Loki OTLP endpoint](https://grafana.com/docs/loki/latest/send-data/otel/)
- **Send Logs:** In this example we used Grafana Alloy to collect and send logs to Loki. However there are many other methods you can use depending upon your needs. For more information see [send data](https://grafana.com/docs/loki/next/send-data/).

- [How is native OTLP endpoint different from Loki Exporter](https://grafana.com/docs/loki/latest/send-data/otel/native_otlp_vs_loki_exporter)
- **Query Logs:** LogQL is an extensive query language for logs and contains many tools to improve log retrival and generate insights. For more information see the [Query section](https://grafana.com/docs/loki/latest/query/).

- [OpenTelemetry Collector Configuration](https://opentelemetry.io/docs/collector/configuration/)
- **Alert:** Lastly you can use the ruler component of Loki to create alerts based on log queries. For more information see [Alerting](https://grafana.com/docs/loki/latest/alert/).

# Complete metrics, logs, traces, and profiling example
## Complete metrics, logs, traces, and profiling example

If you would like to use a demo that includes Mimir, Loki, Tempo, and Grafana, you can use [Introduction to Metrics, Logs, Traces, and Profiling in Grafana](https://github.com/grafana/intro-to-mlt). `Intro-to-mltp`{{copy}} provides a self-contained environment for learning about Mimir, Loki, Tempo, and Grafana.
If you would like to run a demonstration environment that includes Mimir, Loki, Tempo, and Grafana, you can use [Introduction to Metrics, Logs, Traces, and Profiling in Grafana](https://github.com/grafana/intro-to-mlt).
It’s a self-contained environment for learning about Mimir, Loki, Tempo, and Grafana.

The project includes detailed explanations of each component and annotated configurations for a single-instance deployment. Data from `intro-to-mltp`{{copy}} can also be pushed to Grafana Cloud.
The project includes detailed explanations of each component and annotated configurations for a single-instance deployment.
You can also push the data from the environment to [Grafana Cloud](https://grafana.com/cloud/).
21 changes: 18 additions & 3 deletions workshops/course-tracker-test/index.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"title": "Getting started with the OpenTelemetry Collector and Loki tutorial",
"description": "A Tutorial configuring the OpenTelemetry Collector to send OpenTelemetry logs to Loki",
"title": "Loki Quickstart Demo",
"description": "This sandbox provides an online enviroment for testing the Loki quickstart demo.",
"details": {
"intro": {
"text": "intro.md",
"foreground": "update.sh"
"foreground": "setup.sh"
},
"steps": [
{
Expand All @@ -15,6 +15,21 @@
},
{
"text": "step3.md"
},
{
"text": "step4.md"
},
{
"text": "step5.md"
},
{
"text": "step6.md"
},
{
"text": "step7.md"
},
{
"text": "step8.md"
}
],
"finish": {
Expand Down
31 changes: 6 additions & 25 deletions workshops/course-tracker-test/intro.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
# Getting started with the OpenTelemetry Collector and Loki tutorial
# Quickstart to run Loki locally

The OpenTelemetry Collector offers a vendor-agnostic implementation of how to receive, process, and export telemetry data. With the introduction of the OTLP endpoint in Loki, you can now send logs from applications instrumented with OpenTelemetry to Loki using the OpenTelemetry Collector in native OTLP format.
In this example, we will teach you how to configure the OpenTelemetry Collector to receive logs in the OpenTelemetry format and send them to Loki using the OTLP HTTP protocol. This will involve configuring the following components in the OpenTelemetry Collector:
This quick start guide will walk you through deploying Loki in single binary mode (also known as [monolithic mode](https://grafana.com/docs/loki/latest/get-started/deployment-modes/#monolithic-mode)) using Docker Compose. Grafana Loki is only one component of the Grafana observability stack for logs. In this tutorial we will refer to this stack as the **Loki stack**. The Loki stack consists of the following components:

- **OpenTelemetry Receiver:** This component will receive logs in the OpenTelemetry format via HTTP and gRPC.
![Loki Stack](https://grafana.com/media/docs/loki/getting-started-loki-stack-3.png)

- **OpenTelemetry Processor:** This component will accept telemetry data from other `otelcol.*`{{copy}} components and place them into batches. Batching improves the compression of data and reduces the number of outgoing network requests required to transmit data.
- **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.

- **OpenTelemetry Exporter:** This component will accept telemetry data from other `otelcol.*`{{copy}} components and write them over the network using the OTLP HTTP protocol. We will use this exporter to send the logs to the Loki native OTLP endpoint.
- **Loki**: A log aggregation system to store the collected logs. For more information on what Loki is, see the [Loki overview](https://grafana.com/docs/loki/latest/get-started/overview/).

## Scenario

In this scenario, we have a microservices application called the Carnivorous Greenhouse. This application consists of the following services:

- **User Service:** Manages user data and authentication for the application. Such as creating users and logging in.

- **Plant Service:** Manages the creation of new plants and updates other services when a new plant is created.

- **Simulation Service:** Generates sensor data for each plant.

- **Websocket Service:** Manages the websocket connections for the application.

- **Bug Service:** A service that when enabled, randomly causes services to fail and generate additional logs.

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

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

Each service generates logs using the OpenTelemetry SDK and exports to the OpenTelemetry Collector in the OpenTelemetry format (OTLP). The Collector then ingests the logs and sends them to 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 visualize the logs stored in Loki.
Loading

0 comments on commit 886d603

Please sign in to comment.