forked from ContentSquare/chproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
186 lines (183 loc) · 6.15 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package main
import "github.com/prometheus/client_golang/prometheus"
var (
statusCodes = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "status_codes_total",
Help: "Distribution by status codes",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node", "code"},
)
requestSum = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "request_sum_total",
Help: "Total number of sent requests",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
requestSuccess = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "request_success_total",
Help: "Total number of sent success requests",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
limitExcess = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "concurrent_limit_excess_total",
Help: "Total number of max_concurrent_queries excess",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
hostPenalties = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "host_penalties_total",
Help: "Total number of given penalties by host",
},
[]string{"cluster", "replica", "cluster_node"},
)
hostHealth = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "host_health",
Help: "Health state of hosts by clusters",
},
[]string{"cluster", "replica", "cluster_node"},
)
concurrentQueries = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "concurrent_queries",
Help: "The number of concurrent queries at current time",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
requestQueueSize = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "request_queue_size",
Help: "Request queue sizes at the current time",
},
[]string{"user", "cluster", "cluster_user"},
)
userQueueOverflow = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "user_queue_overflow_total",
Help: "The number of overflows for per-user request queues",
},
[]string{"user", "cluster", "cluster_user"},
)
clusterUserQueueOverflow = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "cluster_user_queue_overflow_total",
Help: "The number of overflows for per-cluster_user request queues",
},
[]string{"user", "cluster", "cluster_user"},
)
requestBodyBytes = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "request_body_bytes_total",
Help: "The amount of bytes read from request bodies",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
responseBodyBytes = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "response_body_bytes_total",
Help: "The amount of bytes written to response bodies",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
cacheHit = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "cache_hits_total",
Help: "The amount of cache hits",
},
[]string{"cache", "user", "cluster", "cluster_user"},
)
cacheMiss = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "cache_miss_total",
Help: "The amount of cache misses",
},
[]string{"cache", "user", "cluster", "cluster_user"},
)
cacheSize = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cache_size",
Help: "Cache size at the current time",
},
[]string{"cache"},
)
cacheItems = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "cache_items",
Help: "Cache items at the current time",
},
[]string{"cache"},
)
requestDuration = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "request_duration_seconds",
Help: "Request duration. Includes possible wait time in the queue",
Objectives: map[float64]float64{0.5: 1e-1, 0.9: 1e-2, 0.99: 1e-3, 0.999: 1e-4, 1: 1e-5},
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
proxiedResponseDuration = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "proxied_response_duration_seconds",
Help: "Response duration proxied from clickhouse",
Objectives: map[float64]float64{0.5: 1e-1, 0.9: 1e-2, 0.99: 1e-3, 0.999: 1e-4, 1: 1e-5},
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
cachedResponseDuration = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "cached_response_duration_seconds",
Help: "Response duration served from the cache",
Objectives: map[float64]float64{0.5: 1e-1, 0.9: 1e-2, 0.99: 1e-3, 0.999: 1e-4, 1: 1e-5},
},
[]string{"cache", "user", "cluster", "cluster_user"},
)
canceledRequest = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "canceled_request_total",
Help: "The number of requests canceled by remote client",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
killedRequests = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "killed_request_total",
Help: "The number of requests killed by proxy",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
timeoutRequest = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "timeout_request_total",
Help: "The number of timed out requests",
},
[]string{"user", "cluster", "cluster_user", "replica", "cluster_node"},
)
configSuccess = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "config_last_reload_successful",
Help: "Whether the last configuration reload attempt was successful.",
})
configSuccessTime = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "config_last_reload_success_timestamp_seconds",
Help: "Timestamp of the last successful configuration reload.",
})
badRequest = prometheus.NewCounter(prometheus.CounterOpts{
Name: "bad_requests_total",
Help: "Total number of unsupported requests",
})
)
func init() {
prometheus.MustRegister(statusCodes, requestSum, requestSuccess,
limitExcess, hostPenalties, hostHealth, concurrentQueries,
requestQueueSize, userQueueOverflow, clusterUserQueueOverflow,
requestBodyBytes, responseBodyBytes,
cacheHit, cacheMiss, cacheSize, cacheItems,
requestDuration, proxiedResponseDuration, cachedResponseDuration,
canceledRequest, timeoutRequest,
configSuccess, configSuccessTime, badRequest)
}