convert old metrics to prom metrics
This commit is contained in:
committed by
Carl Bergquist
parent
788f677ed7
commit
2de94d6548
@@ -19,8 +19,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/metrics"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
@@ -35,8 +35,8 @@ func Logger() macaron.Handler {
|
||||
timeTakenMs := time.Since(start) / time.Millisecond
|
||||
|
||||
if timer, ok := c.Data["perfmon.timer"]; ok {
|
||||
timerTyped := timer.(metrics.Timer)
|
||||
timerTyped.Update(timeTakenMs)
|
||||
timerTyped := timer.(prometheus.Summary)
|
||||
timerTyped.Observe(float64(timeTakenMs))
|
||||
}
|
||||
|
||||
status := rw.Status()
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"github.com/grafana/grafana/pkg/components/apikeygen"
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
l "github.com/grafana/grafana/pkg/login"
|
||||
"github.com/grafana/grafana/pkg/metrics"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
@@ -251,7 +251,7 @@ func (ctx *Context) HasHelpFlag(flag m.HelpFlags1) bool {
|
||||
return ctx.HelpFlags1.HasFlag(flag)
|
||||
}
|
||||
|
||||
func (ctx *Context) TimeRequest(timer metrics.Timer) {
|
||||
func (ctx *Context) TimeRequest(timer prometheus.Summary) {
|
||||
ctx.Data["perfmon.timer"] = timer
|
||||
}
|
||||
|
||||
|
||||
@@ -28,38 +28,38 @@ func RequestMetrics() macaron.Handler {
|
||||
func countApiRequests(status int) {
|
||||
switch status {
|
||||
case 200:
|
||||
metrics.M_Api_Status_200.Inc(1)
|
||||
metrics.M_Api_Status.WithLabelValues("200").Inc()
|
||||
case 404:
|
||||
metrics.M_Api_Status_404.Inc(1)
|
||||
metrics.M_Api_Status.WithLabelValues("404").Inc()
|
||||
case 500:
|
||||
metrics.M_Api_Status_500.Inc(1)
|
||||
metrics.M_Api_Status.WithLabelValues("500").Inc()
|
||||
default:
|
||||
metrics.M_Api_Status_Unknown.Inc(1)
|
||||
metrics.M_Api_Status.WithLabelValues("unknown").Inc()
|
||||
}
|
||||
}
|
||||
|
||||
func countPageRequests(status int) {
|
||||
switch status {
|
||||
case 200:
|
||||
metrics.M_Page_Status_200.Inc(1)
|
||||
metrics.M_Page_Status.WithLabelValues("200").Inc()
|
||||
case 404:
|
||||
metrics.M_Page_Status_404.Inc(1)
|
||||
metrics.M_Page_Status.WithLabelValues("404").Inc()
|
||||
case 500:
|
||||
metrics.M_Page_Status_500.Inc(1)
|
||||
metrics.M_Page_Status.WithLabelValues("500").Inc()
|
||||
default:
|
||||
metrics.M_Page_Status_Unknown.Inc(1)
|
||||
metrics.M_Page_Status.WithLabelValues("unknown").Inc()
|
||||
}
|
||||
}
|
||||
|
||||
func countProxyRequests(status int) {
|
||||
switch status {
|
||||
case 200:
|
||||
metrics.M_Proxy_Status_200.Inc(1)
|
||||
metrics.M_Proxy_Status.WithLabelValues("200").Inc()
|
||||
case 404:
|
||||
metrics.M_Proxy_Status_404.Inc(1)
|
||||
metrics.M_Proxy_Status.WithLabelValues("400").Inc()
|
||||
case 500:
|
||||
metrics.M_Proxy_Status_500.Inc(1)
|
||||
metrics.M_Proxy_Status.WithLabelValues("500").Inc()
|
||||
default:
|
||||
metrics.M_Proxy_Status_Unknown.Inc(1)
|
||||
metrics.M_Proxy_Status.WithLabelValues("unknown").Inc()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user