64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package origin
|
|
|
|
import (
|
|
"github.com/cloudflare/cloudflared/connection"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
// Metrics uses connection.MetricsNamespace(aka cloudflared) as namespace and connection.TunnelSubsystem
|
|
// (tunnel) as subsystem to keep them consistent with the previous qualifier.
|
|
|
|
var (
|
|
totalRequests = prometheus.NewCounter(
|
|
prometheus.CounterOpts{
|
|
Namespace: connection.MetricsNamespace,
|
|
Subsystem: connection.TunnelSubsystem,
|
|
Name: "total_requests",
|
|
Help: "Amount of requests proxied through all the tunnels",
|
|
},
|
|
)
|
|
concurrentRequests = prometheus.NewGauge(
|
|
prometheus.GaugeOpts{
|
|
Namespace: connection.MetricsNamespace,
|
|
Subsystem: connection.TunnelSubsystem,
|
|
Name: "concurrent_requests_per_tunnel",
|
|
Help: "Concurrent requests proxied through each tunnel",
|
|
},
|
|
)
|
|
responseByCode = prometheus.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Namespace: connection.MetricsNamespace,
|
|
Subsystem: connection.TunnelSubsystem,
|
|
Name: "response_by_code",
|
|
Help: "Count of responses by HTTP status code",
|
|
},
|
|
[]string{"status_code"},
|
|
)
|
|
haConnections = prometheus.NewGauge(
|
|
prometheus.GaugeOpts{
|
|
Namespace: connection.MetricsNamespace,
|
|
Subsystem: connection.TunnelSubsystem,
|
|
Name: "ha_connections",
|
|
Help: "Number of active ha connections",
|
|
},
|
|
)
|
|
)
|
|
|
|
func init() {
|
|
prometheus.MustRegister(
|
|
totalRequests,
|
|
concurrentRequests,
|
|
responseByCode,
|
|
haConnections,
|
|
)
|
|
}
|
|
|
|
func incrementRequests() {
|
|
totalRequests.Inc()
|
|
concurrentRequests.Inc()
|
|
}
|
|
|
|
func decrementConcurrentRequests() {
|
|
concurrentRequests.Dec()
|
|
}
|