Skip to content

halilylm/prometheusfiber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prometheus Middleware

Prometheus middleware for Fiber v2.

Installation

go get github.com/halilylm/prometheusfiber@v0.1.0

Usage/Examples

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")

About

Prometheus middleware for Fiber v2.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages