2016-10-28 12:54:49 +01:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"sync"
|
|
|
|
|
|
2017-09-14 09:36:06 +01:00
|
|
|
"github.com/coredns/coredns/plugin"
|
2016-10-28 12:54:49 +01:00
|
|
|
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
|
)
|
|
|
|
|
|
2017-09-14 09:36:06 +01:00
|
|
|
// Metrics the proxy plugin exports.
|
2016-10-28 12:54:49 +01:00
|
|
|
var (
|
2017-10-08 04:30:44 -07:00
|
|
|
RequestCount = prometheus.NewCounterVec(prometheus.CounterOpts{
|
|
|
|
|
Namespace: plugin.Namespace,
|
|
|
|
|
Subsystem: "proxy",
|
|
|
|
|
Name: "request_count_total",
|
|
|
|
|
Help: "Counter of requests made per protocol, proxy protocol, family and upstream.",
|
|
|
|
|
}, []string{"proto", "proxy_proto", "family", "to"})
|
2016-10-28 12:54:49 +01:00
|
|
|
RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
2017-09-14 09:36:06 +01:00
|
|
|
Namespace: plugin.Namespace,
|
2017-01-15 08:12:58 +00:00
|
|
|
Subsystem: "proxy",
|
2017-11-27 22:34:26 +01:00
|
|
|
Name: "request_duration_seconds",
|
|
|
|
|
Buckets: plugin.TimeBuckets,
|
|
|
|
|
Help: "Histogram of the time (in seconds) each request took.",
|
2017-10-08 04:30:44 -07:00
|
|
|
}, []string{"proto", "proxy_proto", "family", "to"})
|
2016-10-28 12:54:49 +01:00
|
|
|
)
|
|
|
|
|
|
2017-10-08 04:30:44 -07:00
|
|
|
// familyToString returns the string form of either 1, or 2. Returns
|
|
|
|
|
// empty string is not a known family
|
|
|
|
|
func familyToString(f int) string {
|
|
|
|
|
if f == 1 {
|
|
|
|
|
return "1"
|
|
|
|
|
}
|
|
|
|
|
if f == 2 {
|
|
|
|
|
return "2"
|
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 15:48:14 +00:00
|
|
|
var once sync.Once
|