All Projects → zsais → Go Gin Prometheus

zsais / Go Gin Prometheus

Licence: mit
Gin Web Framework Prometheus metrics exporter

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Go Gin Prometheus

Starlette Prometheus
Prometheus integration for Starlette.
Stars: ✭ 127 (-48.79%)
Mutual labels:  middleware, prometheus
Service Tools
Prepare your Node.js application for production
Stars: ✭ 89 (-64.11%)
Mutual labels:  middleware, prometheus
Client ruby
Prometheus instrumentation library for Ruby applications
Stars: ✭ 369 (+48.79%)
Mutual labels:  middleware, prometheus
Go Http Metrics
Go modular http middleware to measure HTTP requests independent of metrics backend (with Prometheus and OpenCensus as backend implementations) and http framework/library
Stars: ✭ 128 (-48.39%)
Mutual labels:  middleware, prometheus
Carbonapi
Implementation of graphite API (graphite-web) in golang
Stars: ✭ 243 (-2.02%)
Mutual labels:  prometheus
Mux
A powerful HTTP router and URL matcher for building Go web servers with 🦍
Stars: ✭ 15,667 (+6217.34%)
Mutual labels:  middleware
Letsencrypt Rails Heroku
Automatic LetsEncrypt SSL certificates in your Rails app on Heroku.
Stars: ✭ 223 (-10.08%)
Mutual labels:  middleware
Caddy Authz
Caddy-authz is a middleware for Caddy that blocks or allows requests based on access control policies.
Stars: ✭ 221 (-10.89%)
Mutual labels:  middleware
Mikrotik Exporter
prometheus mikrotik device(s) exporter
Stars: ✭ 248 (+0%)
Mutual labels:  prometheus
Golf
⛳️ The Golf web framework
Stars: ✭ 248 (+0%)
Mutual labels:  middleware
My Review
主要存放平时理论学习,比如java jdk源码分析、并发理论;面试、数据库、Linux、中间件、分布式、网络协议等方向
Stars: ✭ 237 (-4.44%)
Mutual labels:  middleware
Router.cr
Minimum High Performance Middleware for Crystal Web Server.
Stars: ✭ 231 (-6.85%)
Mutual labels:  middleware
Beam Dashboards
BEAM ❤️ Prometheus ❤️ Grafana
Stars: ✭ 244 (-1.61%)
Mutual labels:  prometheus
Mux.jl
Middleware for Julia
Stars: ✭ 225 (-9.27%)
Mutual labels:  middleware
Csaguzzlebundle
A bundle integrating Guzzle >=4.0 in Symfony
Stars: ✭ 248 (+0%)
Mutual labels:  middleware
Jeff
🍍Jeff provides the simplest way to manage web sessions in Go.
Stars: ✭ 223 (-10.08%)
Mutual labels:  middleware
Datav
📊https://datav.io is a modern APM, provide observability for your business, application and infrastructure. It's also a lightweight alternative to Grafana.
Stars: ✭ 2,757 (+1011.69%)
Mutual labels:  prometheus
Prometheus rabbitmq exporter
Prometheus.io exporter as a RabbitMQ Managment Plugin plugin
Stars: ✭ 248 (+0%)
Mutual labels:  prometheus
Github Exporter
Prometheus exporter for github metrics
Stars: ✭ 231 (-6.85%)
Mutual labels:  prometheus
Redux Websocket
A Redux middleware to handle WebSocket connections.
Stars: ✭ 232 (-6.45%)
Mutual labels:  middleware

go-gin-prometheus

License: MIT

Gin Web Framework Prometheus metrics exporter

Installation

$ go get github.com/zsais/go-gin-prometheus

Usage

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/zsais/go-gin-prometheus"
)

func main() {
	r := gin.New()

	p := ginprometheus.NewPrometheus("gin")
	p.Use(r)

	r.GET("/", func(c *gin.Context) {
		c.JSON(200, "Hello world!")
	})

	r.Run(":29090")
}

See the example.go file

Preserving a low cardinality for the request counter

The request counter (requests_total) has a url label which, although desirable, can become problematic in cases where your application uses templated routes expecting a great number of variations, as Prometheus explicitly recommends against metrics having high cardinality dimensions:

https://prometheus.io/docs/practices/naming/#labels

If you have for instance a /customer/:name templated route and you don't want to generate a time series for every possible customer name, you could supply this mapping function to the middleware:

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/zsais/go-gin-prometheus"
)

func main() {
	r := gin.New()

	p := ginprometheus.NewPrometheus("gin")

	p.ReqCntURLLabelMappingFn = func(c *gin.Context) string {
		url := c.Request.URL.Path
		for _, p := range c.Params {
			if p.Key == "name" {
				url = strings.Replace(url, p.Value, ":name", 1)
				break
			}
		}
		return url
	}

	p.Use(r)

	r.GET("/", func(c *gin.Context) {
		c.JSON(200, "Hello world!")
	})

	r.Run(":29090")
}

which would map /customer/alice and /customer/bob to their template /customer/:name, and thus preserve a low cardinality for our metrics.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].