This Project is basic example on how to write prometheus metric generator/collector using golang and docker-compose. This gives starting point on how to instrument the go application for prometheus. Also, it will give opportunity in trying various promql queries on data controlled by user(main.go). It helps in giving more insights about the query.
Ensure you install the latest version of make, docker and docker-compose on your Docker host machine. This has been tested with Docker for Mac.
The code present is in main.go file This has three collectors registered:
prometheus.Register(version.NewCollector(collector))
prometheus.Register(NewSysStatCollector(collector))
prometheus.Register(taskCounterVec)
To build and run the docker-compose :
- (optional) add your code to main.go file
- execute
make image
from top of repo - cd monitor
- docker-compose up -d
Your docker-compose will be up and running.
You can check prom metric using http://localhost:9090
in your browser.
http://localhost:9090/targets
shows status of monitored targets as seen from prometheus.
For more information on Prometheus instrumentation : Prometheus Disclaimer: this setup is not in anyway secured. So use it only for inspiration.