Commit bf138d18 by bergquist Committed by Carl Bergquist

adds small docs page metrics

parent c177a9a7
+++
title = "Internal metrics"
description = "Internal metrics exposed by Grafana"
keywords = ["grafana", "metrics", "internal metrics"]
type = "docs"
[menu.docs]
parent = "admin"
weight = 8
+++
# Internal metrics
Grafana collects some metrics about it self internally. Currently Grafana supports pushing metrics to graphite and exposing them to be scraped by Prometheus.
To enabled internal metrics you have to enable it under the [metrics] section in your [grafana.ini](http://docs.grafana.org/installation/configuration/#enabled-6) config file.If you want to push metrics to graphite you have also have to configure the [metrics.graphite](http://docs.grafana.org/installation/configuration/#metrics-graphite) section.
package api
import (
"net/http"
macaron "gopkg.in/macaron.v1"
)
type RouteRegister interface {
Get(string, ...macaron.Handler)
Post(string, ...macaron.Handler)
Delete(string, ...macaron.Handler)
Put(string, ...macaron.Handler)
Group(string, func(RouteRegister), ...macaron.Handler)
}
func newRouteRegister(rr *macaron.Router) RouteRegister {
return &routeRegister{
prefix: "",
routes: []route{},
}
}
type route struct {
method string
pattern string
handlers []macaron.Handler
}
type routeRegister struct {
prefix string
subfixHandlers []macaron.Handler
routes []route
}
func (rr *routeRegister) Group(pattern string, fn func(rr RouteRegister), handlers ...macaron.Handler) {
group := &routeRegister{
prefix: rr.prefix + pattern,
subfixHandlers: handlers,
routes: rr.routes,
}
fn(group)
}
func (rr *routeRegister) Get(pattern string, handlers ...macaron.Handler) {
rr.routes = append(rr.routes, route{
method: http.MethodGet,
pattern: rr.prefix + pattern,
handlers: handlers,
})
println("get: get ", len(rr.routes))
rr.routes = rr.routes[:len(rr.routes)-1]
}
func (rr *routeRegister) Post(pattern string, handlers ...macaron.Handler) {
rr.routes = append(rr.routes, route{
method: http.MethodPost,
pattern: rr.prefix + pattern,
handlers: handlers,
})
println("get: post ", len(rr.routes))
rr.routes = rr.routes[:len(rr.routes)-1]
}
func (rr *routeRegister) Delete(pattern string, handlers ...macaron.Handler) {
rr.routes = append(rr.routes, route{
method: http.MethodDelete,
pattern: rr.prefix + pattern,
handlers: handlers,
})
println("get: delete ", len(rr.routes))
rr.routes = rr.routes[:len(rr.routes)-1]
}
func (rr *routeRegister) Put(pattern string, handlers ...macaron.Handler) {
rr.routes = append(rr.routes, route{
method: http.MethodPut,
pattern: rr.prefix + pattern,
handlers: handlers,
})
rr.routes = rr.routes[:len(rr.routes)-1]
}
package api
import "testing"
func TestRouteRegister(t *testing.T) {
rr := &routeRegister{
prefix: "",
routes: []route{},
}
rr.Delete("/admin")
rr.Get("/down")
rr.Group("/user", func(innerRR RouteRegister) {
innerRR.Delete("")
innerRR.Get("/friends")
})
println("len", len(rr.routes))
if rr.routes[0].pattern != "/admin" && rr.routes[0].method != "DELETE" {
t.Errorf("expected first route to be DELETE /admin")
}
if rr.routes[1].pattern != "/down" && rr.routes[1].method != "GET" {
t.Errorf("expected first route to be GET /down")
}
println("len", len(rr.routes))
if rr.routes[2].pattern != "/user" && rr.routes[2].method != "DELETE" {
t.Errorf("expected first route to be DELETE /admin")
}
if rr.routes[3].pattern != "/user/friends" && rr.routes[3].method != "GET" {
t.Errorf("expected first route to be GET /down")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment