||3 years ago|
|grafana||4 years ago|
|prometheus||4 years ago|
|util||4 years ago|
|.gitignore||3 years ago|
|.travis.yml||4 years ago|
|Dockerfile||3 years ago|
|LICENSE||4 years ago|
|README.md||3 years ago|
|docker-compose.yml||3 years ago|
|gauge.go||3 years ago|
|handlers.go||4 years ago|
|handlers_test.go||3 years ago|
|main.go||3 years ago|
Sample Project for a gorilla/mux based go rest API with prometheus metrics enabled and simple request logging.
the main app is a sample golang application with a gorilla/mux based router.
port 8080 is used and you can build it yourself with:
go get -d github.com/ben-st/go-mux
CGO_ENABLED=0 GOOS=linux go build -o mux
CGO_ENABLED=0 GOOS=darwin go build -o mux
after this you should be able to start it with:
and test it with
or for the metrics endpoint:
If you do not want to build it yourself just use docker or even more convenient docker-compose
this will launch a stack with grafana, prometheus and the mux application
You can reach your applications under:
If you want to check if prometheus scrapes the mux application correctly, you can use the util/configure-grafana-datasource.sh script to configure the prometheus datasource. After this you only have to import the dashboards in the grafana folder. The mux-dashboard.json is a very basic dashboard which displays the go_threads of both prometheus and mux.
i added a simple prometheus gauge in the gauge.go file to show how to get updated metrics while the http server is running and blocking.
All patches are welcome! If you find something is missing or broken send me a PR or file an issue.