Giter VIP home page Giter VIP logo

prometheus-middleware's Introduction

prometheus-middleware Build Status Go Report Card

Prometheus middleware supports only gorilla/mux.

Installation

go get -u github.com/spl0i7/prometheus-middleware

What you will get

You will get:

  • the HTTP request duration in seconds (http_request_duration_seconds) histogram partitioned by status code, method and HTTP path.
...
# HELP http_request_duration_seconds How long it took to process the request, partitioned by status code, method and HTTP path.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{code="200",method="get",path="/",le="0.3"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/",le="1"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/",le="2.5"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/",le="5"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/",le="+Inf"} 2
http_request_duration_seconds_sum{code="200",method="get",path="/"} 3.5256e-05
http_request_duration_seconds_count{code="200",method="get",path="/"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/metrics",le="0.3"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/metrics",le="1"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/metrics",le="2.5"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/metrics",le="5"} 2
http_request_duration_seconds_bucket{code="200",method="get",path="/metrics",le="+Inf"} 2
http_request_duration_seconds_sum{code="200",method="get",path="/metrics"} 0.001261767
http_request_duration_seconds_count{code="200",method="get",path="/metrics"} 2
...
  • HTTP request total (http_requests_total) partitioned by status code, method, and HTTP path.
...
# HELP http_requests_total How many HTTP requests processed, partitioned by status code, method and HTTP path.
# TYPE http_requests_total counter
http_requests_total{code="200",method="get",path="/"} 2
http_requests_total{code="200",method="get",path="/metrics"} 2
...

How to use it

  • Gorilla/Mux
middleware := NewPrometheusMiddleware(Opts{Subsystem: "sminem"})

r := mux.NewRouter()
r.Handle("/metrics", promhttp.Handler())
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(http.StatusOK)
    fmt.Fprintln(w, "ok")
})

r.Use(middleware.InstrumentHandlerDuration)

prometheus-middleware's People

Contributors

spl0i7 avatar albertogviana avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.