MGTheTrain / logging-monitoring-and-tracing-poc

Example repository showcasing the utilization of logging, monitoring and tracing solutions, communicating with them through backend services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logging-monitoring-and-tracing-poc

Table of Contents

Summary

Example repository showcasing the utilization of logging, monitoring and tracing solutions, communicating with them through backend services.

References

How to use

Prerequisite

Prometheus/Grafana stack

Building and running docker-compose network

Build and run the docker-compose network:

docker compose -f docker-compose.prometheus-grafana-stack.yml up -d --build # or `docker compose up -d --build`
# Because the build times for individual services (especially for Rust) are relatively lengthy, you may also opt to build and execute specific services.
docker compose -f docker-compose.prometheus-grafana-stack.yml up -d --build <service 1> <service 2> <service N>
# e.g. 
docker compose -f docker-compose.prometheus-grafana-stack.yml up -d --build python-hello-world-service grafana prometheus

Access the Prometheus UI by navigating to localhost:9090 using a web browser. Here, you can explore discovered services with a metrics endpoint. Access the Grafana UI by visiting localhost:3000 through a web browser. In this interface, you can create new dashboards.

Loki/Grafana stack

Building and running docker-compose network

Build and run the docker-compose network:

docker compose -f docker-compose.loki-grafana-stack.yml up -d --build # or `docker compose up -d --build`
# Because the build times for individual services (especially for Rust) are relatively lengthy, you may also opt to build and execute specific services.
docker compose -f docker-compose.loki-grafana-stack.yml up -d --build <service 1> <service 2> <service N>
# e.g. 
docker compose -f docker-compose.loki-grafana-stack.yml up -d --build python-hello-world-service grafana loki

Testing Loki endpoints

To check Loki endpoints, run following curl commands:

curl -X GET http://localhost:3100/ready # You must ensure that the status changes from "Ingester not ready: waiting for 15s after being ready" to "ready". Else the communication to the Loki server will fail
curl -X GET http://localhost:3100/loki/api/v1/labels
curl -v -H "Content-Type: application/json" -XPOST -s "http://localhost:3100/loki/api/v1/push" --data-raw '{"streams": [{ "stream": { "foo": "bar2" }, "values": [ [ "1570818238000000000", "fizzbuzz" ] ] }]}'
curl -X GET http://localhost:3100/loki/api/v1/label/foo/values

You can also refer to the sample_loki_script.py which can be executed once a Loki docker instance is runnning. E.g.

# Install pip dependencies
pip install -r requirements.txt

python ./sample_loki_script.py --loki-url localhost:3100

# You can expect to receive a status code of 204. Access the Grafana service running within the Docker Compose cluster by navigating to 192.168.99.100:3000 using a web browser. From there, you'll be able to create a dashboard, utilizing the Loki datasource.

Jaeger

Building and running docker-compose network with Jaeger

Build and run the docker-compose network:

docker compose -f docker-compose.jaeger.yml up -d --build # or `docker compose up -d --build`
# Because the build times for individual services (especially for Rust) are relatively lengthy, you may also opt to build and execute specific services.
docker compose -f docker-compose.jaeger.yml up -d --build <service 1> <service 2> <service N>
# e.g. 
docker compose -f docker-compose.jaeger.yml up -d --build python-hello-world-service jaeger

NOTE: The Python sample backend service makes use of the jaeger_client pip package. However, it's advisable to explore the OpenTelemetry Jaeger Exporter as preferred approach. Backend services for Go Gin, Rust Actix Web, and C# ASP .NET Core are not included in this example. Refer to the following links for guidance and instructions on getting started:

Results

ASP .NET Core metrics endpoints for Prometheus scraping

ASP .NET Core metrics endpoints for Prometheus scraping

Go Gin metrics endpoints for Prometheus scraping

ASP .NET Core metrics endpoints for Prometheus scraping

Python FastAPI metrics endpoints for Prometheus scraping

Python FastAPI metrics endpoints for Prometheus scraping

Rust Actix Web metrics endpoints for Prometheus scraping

Rust Actix Web metrics endpoints for Prometheus scraping

Prometheus metric for total requests received

Prometheus metric for total requests received

Grafana sample dashboard considering Prometheus

Grafana sample dashboard

Grafana sample dashboard considering Loki

Grafana sample dashboard considering Loki

Jaeger sample trace

Jaeger sample trace

Cleanup

To delete Docker resources that have been created, execute the following commands:

sudo docker rm -f $(sudo docker ps -qa)
sudo docker system prune --volumes --force

About

Example repository showcasing the utilization of logging, monitoring and tracing solutions, communicating with them through backend services.


Languages

Language:Dockerfile 34.1%Language:Python 23.4%Language:C# 17.6%Language:Go 13.5%Language:Rust 11.4%