https://github.com/kostis-codefresh/prometheus-sample-app
Example Go app that exposes prometheus metrics
https://github.com/kostis-codefresh/prometheus-sample-app
docker-compose golang graphana prometheus
Last synced: 4 months ago
JSON representation
Example Go app that exposes prometheus metrics
- Host: GitHub
- URL: https://github.com/kostis-codefresh/prometheus-sample-app
- Owner: kostis-codefresh
- License: mit
- Created: 2021-03-22T13:13:49.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-24T17:10:25.000Z (about 5 years ago)
- Last Synced: 2025-10-10T12:39:50.658Z (8 months ago)
- Topics: docker-compose, golang, graphana, prometheus
- Language: Go
- Homepage:
- Size: 130 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# Example Go app that exposes Prometheus metrics
[](https://goreportcard.com/report/github.com/kostis-codefresh/prometheus-sample-app)

Original code modified from https://gabrieltanner.org/blog/collecting-prometheus-metrics-in-golang
## How to build
Run:
* `go build` to get the executable OR
* `docker build . -t example-app` to create a container image if you prefer docker instead or don't have access to a Go dev environment
## How to run the application on its own
* `go run .` OR
* `docker run -p 8080:8080 example-app`
Then visit http://localhost:8080 or http://localhost:8080/metrics
## How to run with Prometheus and Graphana
Run `docker-compose up`
You can access Prometheus at http://localhost:9090 and Graphana at http://localhost:3000
1. Login into Graphana. Default user/password for Graphana is admin/admin
1. Add a datasource for type Prometheus at address http://localhost:9090 and auth type "Browser"
1. Import [graphana/graphana-dashboard.json](graphana/graphana-dashboard.json) as a premade dashboard