Prometheus middleware for Fiber v2.
go get github.com/halilylm/[email protected]
Each option is optional. Use what you need, if you don't use, it will fall back to default values.
app := fiber.New()
middleware := prometheusfiber.NewPrometheus(
prometheusfiber.WithSubSystem("fiber"), // define subsystem, default "fiber"
prometheusfiber.WithMetricPath("/metrics"), // where metric will be publisher, default "/metrics"
prometheusfiber.WithSkipURL(skipURL)) // urls to skip
middleware.Use(app)
Running metrics in different server.
// main server
app := fiber.New()
// creating a server to publish metrics.
metricApp := fiber.New()
middleware := prometheusfiber.NewPrometheus(
prometheusfiber.WithSubSystem("fiber"), // define subsystem, default "fiber"
prometheusfiber.WithMetricPath("/metrics"), // where metric will be publisher, default "/metrics"
prometheusfiber.WithSkipURL("/skip")) // urls to skip
// collect metrics on main server
app.Use(middleware.Middleware)
// publisher metrics on metric server.
middleware.SetMetricsPath(metricApp)
go func() { metricApp.Listen(":9090") }()
// run main application.
app.Listen(":8080")