项目作者: kylesliu

项目描述 :
Exporter for gin metrics
高级语言: Go
项目地址: git://github.com/kylesliu/gin_exporter.git
创建时间: 2019-08-10T02:23:23Z
项目社区:https://github.com/kylesliu/gin_exporter

开源协议:Apache License 2.0

下载


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
  1. go get github.com/kylesliu/gin_exporter
  • run the server
  1. package main
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/kylesliu/gin_exporter"
  5. )
  6. func main() {
  7. app := gin.Default()
  8. gin.SetMode(gin.DebugMode)
  9. app.GET("demo1", func(c *gin.Context) {
  10. c.JSON(200, gin.H{
  11. "code": 200,
  12. "msg": "demo1",
  13. })
  14. })
  15. gin_exporter.Default(app)
  16. if err := app.Run("127.0.0.1:9000"); err != nil {
  17. panic(err.Error())
  18. }
  19. }
  • Config the Prometheus
  1. - job_name: 'gin_metrics'
  2. static_configs:
  3. - 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.