You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

// this project is heavily inspired by the prometheus golang client example project
package main
import (
promhttp ""
func main() {
var log = logrus.New()
// set the log output
log.Out = os.Stdout
// set the log level
log.Level = logrus.DebugLevel
// Routes consist of a path and a handler function.
r := mux.NewRouter()
// sample log.Info
log.Info("http server is ready")
// sample log.Debug
log.Debug("i am only visible in debug mode\n")
// exposes / endpoint with the YourHandler handler
r.HandleFunc("/", YourHandler)
// exposes /metrics endpoint with standard golang metrics used by prometheus
r.Handle("/metrics", promhttp.Handler())
// start a goroutine which start the polling for the metrics endpoint
// wrap a logger around the mux server
logWrapper := handlers.LoggingHandler(os.Stdout, r)
metricsWrapper := prometheus.InstrumentHandler("metrics", logWrapper)
// Bind to a port and pass our loggedRouter in
log.Fatal(http.ListenAndServe(":8080", metricsWrapper))