Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Grafana and Loki to demo #1882

Merged
merged 7 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ jobs:
steps:
- uses: actions/[email protected]
- name: Test demo
run: make all
run: make test
working-directory: examples/demo
timeout-minutes: 10
11 changes: 7 additions & 4 deletions examples/demo/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
return 2;
}

var uri = args[0];
var url = args[0];
using var httpClient = new HttpClient();
var content = await httpClient.GetStringAsync(uri);
Console.WriteLine(content);
return 0;
while (true)
{
Thread.Sleep(5000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not await Task.Delay?

var content = await httpClient.GetStringAsync(url);
Console.WriteLine(content);
}
18 changes: 6 additions & 12 deletions examples/demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@
run:
mkdir -p log
chmod 777 log
docker-compose build
docker-compose up -d service
sleep 30 # wait for bootstrap
docker-compose run client
sleep 10 # wait for telemetry export
docker-compose up -d --build

.PHONY: clean
clean:
docker-compose down --remove-orphans
rm -rf log

.PHONY: test
test:
test -f "./log/traces.log" || (echo "traces not exported"; exit 1)
test -f "./log/metrics.log" || (echo "metrics not exported"; exit 1)
test -f "./log/logs.log" || (echo "logs not exported"; exit 1)
.PHONY: wait
wait:
until [ -f "./log/traces.log" ] && [ -f "./log/metrics.log" ] && [ -f "./log/logs.log" ]; do sleep 5; done

.PHONY: all
all: run test clean
.PHONY: test
test: run wait clean
12 changes: 5 additions & 7 deletions examples/demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ It consists of following services:
which collects the telemetry send by `client` and `service`
5. `jaeger` - [Jaeger](https://www.jaegertracing.io/) as traces backend
6. `prometheus` - [Prometheus](https://prometheus.io/) as metrics backend
7. `loki` - [Grafana Loki](https://grafana.com/oss/loki/) as logs backend
8. `grafana` - [Grafana](https://grafana.com/oss/grafana/) as telemetry UI

## Usage

Windows (Git Bash):

```sh
docker-compose build
docker-compose up -d service
docker-compose run client
docker-compose up -d --build
```

macOS and Linux:
Expand All @@ -34,10 +34,8 @@ macOS and Linux:
make
```

The following Web UI endpoints are exposed:

- <http://localhost:16686/search> - traces (Jaeger)
- <http://localhost:9090/graph> - metrics (Prometheus)
You can [explore](https://grafana.com/docs/grafana/v9.3/explore/)
the telemetry in [Grafana UI](http://localhost:3000/).

You can also find the exported telemetry in the `log` directory.

Expand Down
17 changes: 17 additions & 0 deletions examples/demo/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ services:
command: --config /etc/otel/config.yaml
environment:
JAEGER_ENDPOINT: "jaeger:4317"
LOKI_ENDPOINT: "http://loki:3100/loki/api/v1/push"
ports:
- "8889:8889" # Prometheus metrics exporter (scrape endpoint)
- "13133:13133" # health_check extension
- "55679:55679" # ZPages extension
depends_on:
- jaeger
- prometheus
- loki

jaeger:
image: jaegertracing/all-in-one:1.38.1
Expand All @@ -72,3 +74,18 @@ services:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"

loki:
image: grafana/loki:2.7.1
ports:
- "3100:3100"

grafana:
image: grafana/grafana:9.3.2
volumes:
- ./grafana-datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
ports:
- "3000:3000"
20 changes: 20 additions & 0 deletions examples/demo/grafana-datasources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: 1

datasources:
- name: Prometheus
uid: prom
type: prometheus
access: proxy
url: http://prometheus:9090

- name: Loki
uid: loki
type: loki
access: proxy
url: http://loki:3100

- name: Jaeger
type: jaeger
uid: jaeger
access: proxy
url: http://jaeger:16686
6 changes: 5 additions & 1 deletion examples/demo/otel-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ exporters:
insecure: true
prometheus:
endpoint: "0.0.0.0:8889"
loki:
endpoint: "${LOKI_ENDPOINT}"
tls:
insecure: true

service:
pipelines:
Expand Down Expand Up @@ -60,7 +64,7 @@ service:
exporters:
- logging
- file/logs
- otlp
- loki
extensions:
- health_check
- zpages