I would like to try simple example of using Prometheus.
- I have downloaded server binaries
-
I have started simple code, but with few modifications
var addr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.") func main() { flag.Parse() http.Handle("/metrics", promhttp.Handler()) http.Handle("/test/{id}", myHandler(promhttp.Handler())) log.Fatal(http.ListenAndServe(*addr, nil)) } func myHandler(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "hello, you've hit %s ", r.URL.Path) next.ServeHTTP(w, r) }) }
Questions:
- I assume Prometheus is monitoring tool and I would like to monitor endpoints
metrics
and/test/{id}
separately. Did I get the idea correctly by creating several handlers and usingpromhttp.Handler()
as middleware? - What else apart of quantity and latency of requests can be monitored in e.g. simple web app with database?
- I assume Prometheus is monitoring tool and I would like to monitor endpoints