Skip to content

Commit 8eebf00

Browse files
committed
docs: add testing with grafana otel docs
1 parent 5bd6446 commit 8eebf00

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

TESTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## Testing with Grafana OTEL LGTM Docker container
2+
3+
The Grafana OTEL LGTM Docker container is a container that bundles Grafana,
4+
Prometheus, Loki, Tempo and a OTEL collector into a single image for testing,
5+
development and demonstration purposes. We can use it to test `LiteMon` with
6+
`Alloy`.
7+
8+
Below the process is described:
9+
10+
11+
### 1. Spin up Grafana & Prometheus
12+
13+
Run Grafana and Prometheus using the described container image.
14+
15+
```bash
16+
docker run \
17+
-p 3000:3000 \
18+
-p 4317:4317 \
19+
-p 4318:4318 \
20+
-p 3100:3100 \
21+
-p 9090:9090 \
22+
-p 4040:4040 \
23+
-p 3200:3200 \
24+
-ti \
25+
grafana/otel-lgtm
26+
```
27+
28+
29+
### 2. Download and run Alloy
30+
31+
Alloy is the scraper that scrapes `LiteMon` and pushes metrics to Prometheus.
32+
33+
```bash
34+
# Download & install alloy (e.g., on RHEL)
35+
wget https://github.com/grafana/alloy/releases/download/v1.9.1/alloy-1.9.1-1.amd64.rpm
36+
sudo yum installlocal ./alloy-1.9.1-1.amd64.rpm
37+
38+
# Run alloy with testing config
39+
./alloy-linux-amd64 run ./testing/config.alloy
40+
```
41+
42+
43+
### 3. Run LiteMon
44+
45+
Last step is to run LiteMon to allow it to be scraped by Alloy.
46+
47+
```bash
48+
cargo run
49+
```
50+
51+
52+
### 4. Open Grafana
53+
54+
In your web browser navigate to [localhost:3000](http://localhost) to open the
55+
Grafana Web UI.

testing/config.alloy

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
logging {
2+
level = "debug"
3+
}
4+
5+
livedebugging {
6+
enabled = true
7+
}
8+
9+
prometheus.remote_write "EXAMPLE" {
10+
endpoint {
11+
url = "http://localhost:9090/api/v1/write"
12+
}
13+
}
14+
15+
// https://grafana.com/docs/alloy/latest/reference/components/discovery/discovery.relabel/
16+
discovery.relabel "integrations_litemon_exporter" {
17+
targets = [
18+
// Optionally, update to your listen address and port.
19+
{"__address__" = "localhost:9774"},
20+
]
21+
22+
rule {
23+
target_label = "instance"
24+
replacement = constants.hostname
25+
}
26+
27+
rule {
28+
target_label = "job"
29+
replacement = "integrations/litemon"
30+
}
31+
}
32+
33+
// https://grafana.com/docs/alloy/latest/reference/components/prometheus/prometheus.scrape/
34+
prometheus.scrape "litemon_exporter" {
35+
job_name = "integrations/litemon"
36+
targets = discovery.relabel.integrations_litemon_exporter.output
37+
scheme = "http"
38+
scrape_interval = "10s"
39+
metrics_path = "/metrics"
40+
41+
// Update endpoint to your prometheus ingest.
42+
forward_to = [prometheus.remote_write.EXAMPLE.receiver]
43+
}

0 commit comments

Comments
 (0)