Forked from ipedrazas/gist:aa2b5550fd38446c131db0913e389b5e
Created
March 28, 2019 12:26
-
-
Save Shahid1993/a6e47c720b14aec9a4cc1931c51a1c96 to your computer and use it in GitHub Desktop.
instrument app - prometheus
This file contains hidden or 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