This is a simple example project demonstrating how to use Golang, Prometheus, and Grafana together. The Golang application exposes metrics, Prometheus scrapes these metrics, and Grafana visualizes the data.
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/danielmeloramos/sre-artigo.git cd sre-artigo
-
Build the Golang application:
make build
-
Run the entire setup:
make run
-
This command starts the Golang application, Prometheus, and Grafana containers.
- Access Grafana at http://localhost:3000 (default credentials: admin/admin).
- Add Prometheus as a data source in Grafana with the URL http://prometheus:9090.
- Create a dashboard in Grafana and visualize the myapp_requests_total metric
sum(increase(myapp_requests_total[1m]))
.
-
Stopping the Setup. To stop and remove all containers, use the following command:
make clean
-
Notes
- The Golang application runs on port 8080;
- Prometheus is accessible at
http://localhost:9090
; - Grafana is accessible at
http://localhost:3000
(default credentials:admin/admin
).
-
Post Blog
https://danielmeloramos.com.br/site-reliability-engineering/
Feel free to customize the Golang application and the Prometheus/Grafana configurations based on your needs.
Replace https://github.com/your-username/your-repository.git with the actual URL of your Git repository.