collector includes
- Metrics Collection: collector.go
- Data Storage: pusher.go (still wondering about this part, best practise might expose metrics and wait Prometheus to pull, if we want to save to Prometheus we need to push)
- API Endpoint: main.go
alertis in here- Visualization: import docs/grafana_sample.json to a Grafana, docs/grafana-screenshot.png is the sample grafana dashboard's screenshot at Sep 15 2024 10:34 a.m. UTC+13
- Documentation: contains most of the instruction to setup the project
Collecting server metrics is essential for maintaining the health, performance, and security of IT infrastructure, as well as for optimizing resource usage and ensuring compliance with industry standards and regulations.
Metric storage
Visualization, please import sample-grafana.json after startup
In our Go project, we just need to import the dependent library.
go mod download
Attach suitable metrics to relevant functions to evaluate the performance of the scope. Check example code here.
Start the server to collect the metrics.
go run main.go
and check the metrics by using follow URL,
http://localhost:9101/metrics
Server metrics need to be collected and visualized to analyze the data. Prometheus and Grafana need to be started and configured along with Docker.
Install Docker with Docker Compose. Check out here
Prometheus and Grafana Docker configuration can be found in docker-compose.yml. First of all, we need to create the network mode,
docker network create metricsThen initiate the Docker Compose by using the following command,
./metrics-run.shNow you can check the promethues dashboard by using follow link,
http://localhost:9090/graph
Server target is already set via the promethues.yml
Let's check the grafana dashboard through,
http://localhost:3000/
default username: admin, default password: admin
Configure the grafana database configuration by adding database,