diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 4a8b55b0fa..750b78c484 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -18,5 +18,6 @@ jobs: steps: - uses: actions/checkout@v3.2.0 - name: Test demo - run: make all + run: make test working-directory: examples/demo + timeout-minutes: 10 diff --git a/examples/demo/Client/Program.cs b/examples/demo/Client/Program.cs index ef1f7bdf09..5250bc6886 100644 --- a/examples/demo/Client/Program.cs +++ b/examples/demo/Client/Program.cs @@ -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); + var content = await httpClient.GetStringAsync(url); + Console.WriteLine(content); +} diff --git a/examples/demo/Makefile b/examples/demo/Makefile index 4f6385f905..859a624693 100644 --- a/examples/demo/Makefile +++ b/examples/demo/Makefile @@ -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 diff --git a/examples/demo/README.md b/examples/demo/README.md index b6af595f07..eab713d92c 100644 --- a/examples/demo/README.md +++ b/examples/demo/README.md @@ -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: @@ -34,10 +34,8 @@ macOS and Linux: make ``` -The following Web UI endpoints are exposed: - -- - traces (Jaeger) -- - 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. diff --git a/examples/demo/docker-compose.yaml b/examples/demo/docker-compose.yaml index 46dd288899..fe956b4f16 100644 --- a/examples/demo/docker-compose.yaml +++ b/examples/demo/docker-compose.yaml @@ -51,6 +51,7 @@ 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 @@ -58,6 +59,7 @@ services: depends_on: - jaeger - prometheus + - loki jaeger: image: jaegertracing/all-in-one:1.38.1 @@ -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" diff --git a/examples/demo/grafana-datasources.yml b/examples/demo/grafana-datasources.yml new file mode 100644 index 0000000000..2c0a6f8dfa --- /dev/null +++ b/examples/demo/grafana-datasources.yml @@ -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 diff --git a/examples/demo/otel-config.yaml b/examples/demo/otel-config.yaml index 424fcae6f2..11f1b777c1 100644 --- a/examples/demo/otel-config.yaml +++ b/examples/demo/otel-config.yaml @@ -32,6 +32,10 @@ exporters: insecure: true prometheus: endpoint: "0.0.0.0:8889" + loki: + endpoint: "${LOKI_ENDPOINT}" + tls: + insecure: true service: pipelines: @@ -60,7 +64,7 @@ service: exporters: - logging - file/logs - - otlp + - loki extensions: - health_check - zpages