forked from gazette/core
-
Notifications
You must be signed in to change notification settings - Fork 2
/
metrics.go
250 lines (232 loc) · 9.76 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package metrics
import "github.com/prometheus/client_golang/prometheus"
// Key constants are exported primarily for documentation reasons. Typically,
// they will not be used programmatically outside of defining the collectors.
// Keys for gazette metrics.
const (
CommittedBytesTotalKey = "gazette_committed_bytes_total"
CommitsTotalKey = "gazette_commits_total"
RecoveryLogRecoveredBytesTotalKey = "gazette_recoverylog_recovered_bytes_total"
StoreRequestsTotalKey = "gazette_store_requests_total"
StorePersistedBytesTotalKey = "gazette_store_persisted_bytes_total"
AllocatorConvergeTotalKey = "gazette_allocator_converge_total"
AllocatorMembersKey = "gazette_allocator_members"
AllocatorItemsKey = "gazette_allocator_items"
AllocatorDesiredReplicationSlotsKey = "gazette_allocator_desired_replication_slots"
JournalServerResponseTimeSecondsKey = "gazette_journal_server_response_time_seconds"
Fail = "fail"
Ok = "ok"
)
// Collectors for gazette metrics.
var (
CommittedBytesTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: CommittedBytesTotalKey,
Help: "Cumulative number of bytes committed to journals.",
})
CommitsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: CommitsTotalKey,
Help: "Cumulative number of commits.",
}, []string{"status"})
RecoveryLogRecoveredBytesTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: RecoveryLogRecoveredBytesTotalKey,
Help: "Cumulative number of bytes recovered.",
})
StoreRequestTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: StoreRequestsTotalKey,
Help: "Cumulative number of fragment store operations.",
}, []string{"provider", "operation", "status"})
StorePersistedBytesTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: StorePersistedBytesTotalKey,
Help: "Cumulative number of bytes persisted to fragment stores.",
}, []string{"provider"})
AllocatorConvergeTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: AllocatorConvergeTotalKey,
Help: "Cumulative number of converge iterations.",
})
AllocatorMembers = prometheus.NewGauge(prometheus.GaugeOpts{
Name: AllocatorMembersKey,
Help: "Number of members known to the allocator.",
})
AllocatorItems = prometheus.NewGauge(prometheus.GaugeOpts{
Name: AllocatorItemsKey,
Help: "Number of items known to the allocator.",
})
AllocatorDesiredReplicationSlots = prometheus.NewGauge(prometheus.GaugeOpts{
Name: AllocatorDesiredReplicationSlotsKey,
Help: "Number of desired replicaiton slots summed across all items.",
})
JournalServerResponseTimeSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Name: JournalServerResponseTimeSecondsKey,
Help: "Response time of JournalServer.Append.",
}, []string{"operation", "status"})
)
// GazetteBrokerCollectors lists collectors used by the gazette broker.
func GazetteBrokerCollectors() []prometheus.Collector {
return []prometheus.Collector{
CommittedBytesTotal,
CommitsTotal,
RecoveryLogRecoveredBytesTotal,
StoreRequestTotal,
StorePersistedBytesTotal,
AllocatorConvergeTotal,
AllocatorMembers,
AllocatorItems,
AllocatorDesiredReplicationSlots,
JournalServerResponseTimeSeconds,
}
}
// Keys for gazconsumer metrics.
const (
GazconsumerLagBytesKey = "gazconsumer_lag_bytes"
)
// Collectors for gazconsumer metrics.
var (
GazconsumerLagBytes = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: GazconsumerLagBytesKey,
Help: "Lag of the consumer on a per shard basis.",
}, []string{"consumer"})
)
// GazetteconsumerCollectors lists collectors used by the gazette broker.
func GazconsumerCollectors() []prometheus.Collector {
return []prometheus.Collector{GazconsumerLagBytes}
}
// Keys for gazretention metrics.
const (
GazretentionDeletedBytesTotalKey = "gazretention_deleted_bytes_total"
GazretentionDeletedFragmentsTotalKey = "gazretention_deleted_fragments_total"
GazretentionRetainedBytesTotalKey = "gazretention_retained_bytes_total"
GazretentionRetainedFragmentsTotalKey = "gazretention_retained_fragments_total"
)
// Collectors for gazretention metrics.
var (
GazretentionDeletedBytesTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: GazretentionDeletedBytesTotalKey,
Help: "Cumulative number of bytes deleted.",
}, []string{"prefix"})
GazretentionDeletedFragmentsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: GazretentionDeletedFragmentsTotalKey,
Help: "Cumulative number of fragments deleted.",
}, []string{"prefix"})
GazretentionRetainedBytesTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: GazretentionRetainedBytesTotalKey,
Help: "Cumulative number of bytes retained.",
}, []string{"prefix"})
GazretentionRetainedFragmentsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: GazretentionRetainedFragmentsTotalKey,
Help: "Cumulative number of fragments retained.",
}, []string{"prefix"})
)
func GazretentionCollectors() []prometheus.Collector {
return []prometheus.Collector{
GazretentionDeletedBytesTotal,
GazretentionDeletedFragmentsTotal,
GazretentionRetainedBytesTotal,
GazretentionRetainedFragmentsTotal,
}
}
// Keys for gazette.Client and gazette.WriteService metrics.
const (
GazetteDiscardBytesTotalKey = "gazette_discard_bytes_total"
GazetteReadBytesTotalKey = "gazette_read_bytes_total"
GazetteWriteBytesTotalKey = "gazette_write_bytes_total"
GazetteWriteCountTotalKey = "gazette_write_count_total"
GazetteWriteDurationSecondsTotalKey = "gazette_write_duration_seconds_total"
GazetteWriteFailureTotalKey = "gazette_write_failure_total"
)
// Collectors for gazette.Client and gazette.WriteService metrics.
// TODO(rupert): Should prefix be GazetteClient-, "gazette_client_-"?
var (
GazetteDiscardBytesTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteDiscardBytesTotalKey,
Help: "Cumulative number of bytes read but discarded.",
})
GazetteReadBytesTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteReadBytesTotalKey,
Help: "Cumulative number of bytes read.",
})
GazetteWriteBytesTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteWriteBytesTotalKey,
Help: "Cumulative number of bytes written.",
})
GazetteWriteCountTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteWriteCountTotalKey,
Help: "Cumulative number of writes.",
})
GazetteWriteDurationTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteWriteDurationSecondsTotalKey,
Help: "Cumulative number of seconds spent writing.",
})
GazetteWriteFailureTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteWriteFailureTotalKey,
Help: "Cumulative number of write errors returned to clients.",
})
)
// GazetteClientCollectors returns the metrics used by gazette.Client and
// gazette.WriteService.
func GazetteClientCollectors() []prometheus.Collector {
return []prometheus.Collector{
GazetteDiscardBytesTotal,
GazetteReadBytesTotal,
GazetteWriteBytesTotal,
GazetteWriteCountTotal,
GazetteWriteDurationTotal,
}
}
// Keys for consumer.Runner metrics.
const (
GazetteConsumerTxCountTotalKey = "gazette_consumer_tx_count_total"
GazetteConsumerTxMessagesTotalKey = "gazette_consumer_tx_messages_total"
GazetteConsumerTxSecondsTotalKey = "gazette_consumer_tx_seconds_total"
GazetteConsumerTxConsumeSecondsTotalKey = "gazette_consumer_tx_consume_seconds_total"
GazetteConsumerTxStalledSecondsTotalKey = "gazette_consumer_tx_stalled_seconds_total"
GazetteConsumerTxFlushSecondsTotalKey = "gazette_consumer_tx_flush_seconds_total"
GazetteConsumerTxSyncSecondsTotalKey = "gazette_consumer_tx_sync_seconds_total"
GazetteConsumerConsumedBytesTotalKey = "gazette_consumer_consumed_bytes_total"
)
// Collectors for consumer.Runner metrics.
var (
GazetteConsumerTxCountTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerTxCountTotalKey,
Help: "Cumulative number of transactions",
})
GazetteConsumerTxMessagesTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerTxMessagesTotalKey,
Help: "Cumulative number of messages.",
})
GazetteConsumerTxSecondsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerTxSecondsTotalKey,
Help: "Cumulative number of seconds processing transactions.",
})
GazetteConsumerTxConsumeSecondsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerTxConsumeSecondsTotalKey,
Help: "Cumulative number of seconds transactions were processing messages.",
})
GazetteConsumerTxStalledSecondsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerTxStalledSecondsTotalKey,
Help: "Cumulative number of seconds transactions were stalled waiting for Gazette IO.",
})
GazetteConsumerTxFlushSecondsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerTxFlushSecondsTotalKey,
Help: "Cumulative number of seconds transactions were flushing their commit.",
})
GazetteConsumerTxSyncSecondsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerTxSyncSecondsTotalKey,
Help: "Cumulative number of seconds transactions were waiting for their commit to sync.",
})
GazetteConsumerBytesConsumedTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: GazetteConsumerConsumedBytesTotalKey,
Help: "Cumulative number of bytes consumed.",
})
)
// GazetteConsumerCollectors returns the metrics used by the consumer package.
func GazetteConsumerCollectors() []prometheus.Collector {
return []prometheus.Collector{
GazetteConsumerTxCountTotal,
GazetteConsumerTxMessagesTotal,
GazetteConsumerTxSecondsTotal,
GazetteConsumerTxConsumeSecondsTotal,
GazetteConsumerTxStalledSecondsTotal,
GazetteConsumerTxFlushSecondsTotal,
GazetteConsumerBytesConsumedTotal,
}
}