Skip to content
Exporter for gin metrics
Branch: master
Clone or download
Latest commit 2c0a723 May 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore init May 11, 2019
.travis.yml 添加自动测试 May 12, 2019
LICENSE Initial commit May 11, 2019
README.md 添加CI May 12, 2019
codecov.yml 添加CI May 12, 2019
glide.yaml add some collect May 18, 2019
go.mod add some collect May 18, 2019
go.sum add some collect May 18, 2019
metrics.go add some collect May 18, 2019
metrics_test.go add some collect May 18, 2019
middleware.go add some collect May 18, 2019
test.sh 添加自动测试 May 12, 2019

README.md

The Gin Framework Metrics Middleware

Build Status

Preface

Many small companies don't have such a large architecture for micro-services when they do websites. A simple solution for viewing application traffic is very important. This repository is a middleware that integrates seamlessly with Gin.

gin_metrics_v1

How to use

  • install the metrics lib
go get github.com/kylesliu/gin_metrics
  • run the server
package main

import (
	"github.com/gin-gonic/gin"
	"github.com/kylesliu/gin_metrics"
)

func main() {
	app := gin.Default()
	gin.SetMode(gin.DebugMode)

	app.GET("demo1", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"code": 200,
			"msg":  "demo1",
		})
	})

	gin_metrics.Default(app)

	if err := app.Run("127.0.0.1:9000"); err != nil {
		panic(err.Error())
	}
}
  • Config the Prometheus
  - job_name: 'gin_metrics'
    static_configs:
    - targets: ['localhost:9000']
  • Config the Grafana

Grafana Dashboard

Last

If you have any good suggestions to mention issue or PR, I will check it out in detail.

You can’t perform that action at this time.