Skip to content

Commit 282e385

Browse files
feat: Update getting started demo to Loki 3.0 (#12723)
Co-authored-by: J Stickler <[email protected]>
1 parent 7253444 commit 282e385

File tree

5 files changed

+79
-37
lines changed

5 files changed

+79
-37
lines changed

docs/sources/get-started/quick-start.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ If you want to experiment with Loki, you can run Loki locally using the Docker C
1212
The Docker Compose configuration instantiates the following components, each in its own container:
1313

1414
- **flog** a sample application which generates log lines. [flog](https://github.com/mingrammer/flog) is a log generator for common log formats.
15-
- **Promtail** which scrapes the log lines from flog, and pushes them to Loki through the gateway.
15+
- **Grafana Alloy** which scrapes the log lines from flog, and pushes them to Loki through the gateway.
1616
- **Gateway** (NGINX) which receives requests and redirects them to the appropriate container based on the request's URL.
17-
- One Loki **read** component.
18-
- One Loki **write** component.
17+
- One Loki **read** component (Query Frontend, Querier).
18+
- One Loki **write** component (Distributor, Ingester).
19+
- One Loki **backend** component (Index Gateway, Compactor, Ruler, Bloom Compactor (Experimental), Bloom Gateway (Experimental)).
1920
- **Minio** an S3-compatible object store which Loki uses to store its index and chunks.
2021
- **Grafana** which provides visualization of the log lines captured within Loki.
2122

22-
{{< figure max-width="75%" src="/media/docs/loki/get-started-flog-v2.png" caption="Getting started sample application" alt="Getting started sample application">}}
23+
{{< figure max-width="75%" src="/media/docs/loki/get-started-flog-v3.png" caption="Getting started sample application" alt="Getting started sample application">}}
2324

2425
## Installing Loki and collecting sample logs
2526

@@ -41,11 +42,11 @@ This quickstart assumes you are running Linux.
4142
cd evaluate-loki
4243
```
4344

44-
1. Download `loki-config.yaml`, `promtail-local-config.yaml`, and `docker-compose.yaml`:
45+
1. Download `loki-config.yaml`, `alloy-local-config.yaml`, and `docker-compose.yaml`:
4546

4647
```bash
4748
wget https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/loki-config.yaml -O loki-config.yaml
48-
wget https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/promtail-local-config.yaml -O promtail-local-config.yaml
49+
wget https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/alloy-local-config.yaml -O alloy-local-config.yaml
4950
wget https://raw.githubusercontent.com/grafana/loki/main/examples/getting-started/docker-compose.yaml -O docker-compose.yaml
5051
```
5152

@@ -63,16 +64,20 @@ This quickstart assumes you are running Linux.
6364
✔ Network evaluate-loki_loki Created 0.1s
6465
✔ Container evaluate-loki-minio-1 Started 0.6s
6566
✔ Container evaluate-loki-flog-1 Started 0.6s
67+
✔ Container evaluate-loki-backend-1 Started 0.8s
6668
✔ Container evaluate-loki-write-1 Started 0.8s
6769
✔ Container evaluate-loki-read-1 Started 0.8s
6870
✔ Container evaluate-loki-gateway-1 Started 1.1s
6971
✔ Container evaluate-loki-grafana-1 Started 1.4s
70-
✔ Container evaluate-loki-promtail-1 Started 1.4s
72+
✔ Container evaluate-loki-alloy-1 Started 1.4s
7173
```
7274

7375
1. (Optional) Verify that the Loki cluster is up and running.
7476
- The read component returns `ready` when you point a web browser at [http://localhost:3101/ready](http://localhost:3101/ready). The message `Query Frontend not ready: not ready: number of schedulers this worker is connected to is 0` will show prior to the read component being ready.
7577
- The write component returns `ready` when you point a web browser at [http://localhost:3102/ready](http://localhost:3102/ready). The message `Ingester not ready: waiting for 15s after being ready` will show prior to the write component being ready.
78+
79+
1. (Optional) Verify that Grafana Alloy is running.
80+
- Grafana Alloy's UI can be accessed at [http://localhost:12345](http://localhost:12345).
7681
7782
## Viewing your logs in Grafana
7883
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
discovery.docker "flog_scrape" {
2+
host = "unix:///var/run/docker.sock"
3+
refresh_interval = "5s"
4+
}
5+
6+
discovery.relabel "flog_scrape" {
7+
targets = []
8+
9+
rule {
10+
source_labels = ["__meta_docker_container_name"]
11+
regex = "/(.*)"
12+
target_label = "container"
13+
}
14+
}
15+
16+
loki.source.docker "flog_scrape" {
17+
host = "unix:///var/run/docker.sock"
18+
targets = discovery.docker.flog_scrape.targets
19+
forward_to = [loki.write.default.receiver]
20+
relabel_rules = discovery.relabel.flog_scrape.rules
21+
refresh_interval = "5s"
22+
}
23+
24+
loki.write "default" {
25+
endpoint {
26+
url = "http://gateway:3100/loki/api/v1/push"
27+
tenant_id = "tenant1"
28+
}
29+
external_labels = {}
30+
}

examples/getting-started/docker-compose.yaml

+23-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ networks:
66

77
services:
88
read:
9-
image: grafana/loki:2.9.2
9+
image: grafana/loki:3.0.0
1010
command: "-config.file=/etc/loki/config.yaml -target=read"
1111
ports:
1212
- 3101:3100
@@ -27,7 +27,7 @@ services:
2727
- loki
2828

2929
write:
30-
image: grafana/loki:2.9.2
30+
image: grafana/loki:3.0.0
3131
command: "-config.file=/etc/loki/config.yaml -target=write"
3232
ports:
3333
- 3102:3100
@@ -45,12 +45,14 @@ services:
4545
networks:
4646
<<: *loki-dns
4747

48-
promtail:
49-
image: grafana/promtail:2.9.2
48+
alloy:
49+
image: grafana/alloy:latest
5050
volumes:
51-
- ./promtail-local-config.yaml:/etc/promtail/config.yaml:ro
51+
- ./alloy-local-config.yaml:/etc/alloy/config.alloy:ro
5252
- /var/run/docker.sock:/var/run/docker.sock
53-
command: -config.file=/etc/promtail/config.yaml
53+
command: run --server.http.listen-addr=0.0.0.0:12345 --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy
54+
ports:
55+
- 12345:12345
5456
depends_on:
5557
- gateway
5658
networks:
@@ -118,6 +120,20 @@ services:
118120
networks:
119121
- loki
120122

123+
backend:
124+
image: grafana/loki:3.0.0
125+
volumes:
126+
- ./loki-config.yaml:/etc/loki/config.yaml
127+
ports:
128+
- "3100"
129+
- "7946"
130+
command: "-config.file=/etc/loki/config.yaml -target=backend -legacy-read-mode=false"
131+
depends_on:
132+
- gateway
133+
networks:
134+
- loki
135+
136+
121137
gateway:
122138
image: nginx:latest
123139
depends_on:
@@ -186,6 +202,7 @@ services:
186202
retries: 5
187203
networks:
188204
- loki
205+
189206

190207
flog:
191208
image: mingrammer/flog

examples/getting-started/loki-config.yaml

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
---
22
server:
3+
http_listen_address: 0.0.0.0
34
http_listen_port: 3100
5+
46
memberlist:
5-
join_members:
6-
- loki:7946
7+
join_members: ["read", "write", "backend"]
8+
dead_node_reclaim_time: 30s
9+
gossip_to_dead_nodes_time: 15s
10+
left_ingesters_timeout: 30s
11+
bind_addr: ['0.0.0.0']
12+
bind_port: 7946
13+
gossip_interval: 2s
14+
715
schema_config:
816
configs:
917
- from: 2021-08-01
@@ -16,6 +24,7 @@ schema_config:
1624
common:
1725
path_prefix: /loki
1826
replication_factor: 1
27+
compactor_address: http://backend:3100
1928
storage:
2029
s3:
2130
endpoint: minio:9000
@@ -31,3 +40,6 @@ ruler:
3140
storage:
3241
s3:
3342
bucketnames: loki-ruler
43+
44+
compactor:
45+
working_directory: /tmp/compactor

examples/getting-started/promtail-local-config.yaml

-22
This file was deleted.

0 commit comments

Comments
 (0)