A simple API made in GO to see how Prometheus and Grafana can be setup and play around to see how they work.
Pre-requisite:
- Docker
docker compose up -d
The Dockerfile build an image of our application and the docker-compose run everything along with the Prometheus server and Grafana.
- Go to localhost:3000 to access Grafana Interface
- Default credential are
adminfor the login and the password. - Click skip if your don't want to change the default password.
- On the Homepage, click in the searchbar located at the very top of the page.
- Enter "Data Sources" and press ENTER.
- Click on "Add new data source".
- Then in the filter input above listed source, search "Prometheus".
- Click on it.
- Then once you are in the configuration page of the Prometheus source, go to the "Connection" section.
- In the "Prometheus server URL", put
http://host.docker.internal:9090since Grafana and Prometheus are not in the same network. - Then scroll to the button and click "Save and Test", everything should be green ✅ !
- Finally, navigate to the Dashboard page using the side panel of the app and create your stuff :D .
Since we want to monitor and maybe in the future optimize some endpoint to support a load of request we need something that can help us reproduce this flow of request into our app.
For that we will use K6 which will mimic how our users can send request to our API to see how the server can handle the traffic.
However, since I didn't wanted to include the image of app in my docker compose, it's up to you to see how you can install this tool here.
The application can be run using the docker image built using Dockerfile.
The docker-compose.yml is only used in development, it run our application and a grafana application alongisde to visualize prometheus metrics.