GrayCatCode / ShoeHubV2

GitHub repository for the Udemy course Mastering Prometheus and Grafana

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Observability with Grafana, Prometheus and Loki

The ShoeHub (Prometheus Exporter)

Grafana, Graphite, and StatsD

This repository belongs to an online course called "Observability with Grafana, Prometheus and Loki". The code generates random data points for an imaginary company called ShoeHub.

To access the metrics, run the application using the executable file provided under the Releases folder relevant to your operating system (i.e., ShoeHubV2.exe in Windows). If you prefer to use the provided Docker container, follow the instructions below.

The application includes a built-in web server, so once the application is run, you will see the address where you can see the metrics under /metrics endpoint.

Example of where to find the host address and port

In the above example, you must scrape HTTP://locahost:5000/metrics to see the metrics.

Use the prometheus.yml file that is provided in the repository. It contains a scrape configuration that you can use in Prometheus:

scrape_configs:
  - job_name: 'shoehub'
    scrape_interval: 5s
    static_configs:
      - targets: ['http://localhost:80']

Running the Docker Container

If you have Docker Desktop running, pull the provided Docker image:

  docker pull aussiearef/shoehub

The metric endpoint listens on port __8080__by default. If you want to assign a different port to the metrics endpoint, use the -p argument when running the docker run command:

  docker run -p <local port>:8080 -i aussiearef/shoehub

Example:

  docker run -p 8020:80 -i aussiearef/shoehub

Please update your scraping rule in Prometheus so it scrapes the correct port.

Building the code

The code is written in .NET 8 as a minimal web API. If you wish to build the code, download the .NET 8 SDK .NET 8 is cross-platform, so that you can download and install it on Windows, Mac and Linux.

Then, clone the code, and in Terminal (or Command Prompt), navigate to the ShoeHubV2 folder. Then enter "dotnet run" and press Enter or Return key.

Docker Compose For Launching Grafana

This repository also includes a dockercompose.yml file (under /Docker directory), which can be used to launch Grafana, Prometheus and Loki using Docker in a few minutes. Download the dockercompose.yml file and change the current directory in a Terminal window to the one where the dockercompose.yml file is. Then run

docker compose -f dockrecompose.yml up -d

This way, you will connect three containers via a single Docker network. You must log in to Grafana and manually add Prometheus and Loki as data sources. It is needless to say, you must have Docker Desktop installed on your computer before you can launch Grafana and Prometheus using Docker.

More Free Courses on YouTube

YouTube

Subscribe to the Free Technology and Technology Management Courses channel for free lectures about Coding, DevOps, and Technology Management. Here is the link to the YouTube channel.

Buy me a coffee ☕

If you find my work helpful, consider treating me by buying me a coffee!

ko-fi

About

GitHub repository for the Udemy course Mastering Prometheus and Grafana


Languages

Language:C# 64.8%Language:Dockerfile 35.2%