Created
April 23, 2018 13:31
-
-
Save ipedrazas/aa2b5550fd38446c131db0913e389b5e to your computer and use it in GitHub Desktop.
instrument app - prometheus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/stefanprodan/k8s-podinfo/blob/master/pkg/server/instrument.go | |
func NewInstrument() *Instrument { | |
// used for monitoring and alerting (RED method) | |
histogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{ | |
Subsystem: "http", | |
Name: "requests", | |
Help: "Seconds spent serving HTTP requests.", | |
Buckets: prometheus.DefBuckets, | |
}, []string{"method", "path", "status"}) | |
// used for horizontal pod auto-scaling (Kubernetes HPA v2) | |
counter := prometheus.NewCounterVec( | |
prometheus.CounterOpts{ | |
Subsystem: "http", | |
Name: "requests_total", | |
Help: "The total number of HTTP requests.", | |
}, | |
[]string{"status"}, | |
) | |
prometheus.MustRegister(histogram) | |
prometheus.MustRegister(counter) | |
return &Instrument{ | |
Histogram: histogram, | |
Counter: counter, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment