-
Notifications
You must be signed in to change notification settings - Fork 781
/
metrics.go
630 lines (584 loc) · 26.9 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
package ingester
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"go.uber.org/atomic"
"github.com/cortexproject/cortex/pkg/util"
util_math "github.com/cortexproject/cortex/pkg/util/math"
)
const (
memSeriesCreatedTotalName = "cortex_ingester_memory_series_created_total"
memSeriesCreatedTotalHelp = "The total number of series that were created per user."
memSeriesRemovedTotalName = "cortex_ingester_memory_series_removed_total"
memSeriesRemovedTotalHelp = "The total number of series that were removed per user."
)
type ingesterMetrics struct {
ingestedSamples prometheus.Counter
ingestedExemplars prometheus.Counter
ingestedMetadata prometheus.Counter
ingestedSamplesFail prometheus.Counter
ingestedExemplarsFail prometheus.Counter
ingestedMetadataFail prometheus.Counter
queries prometheus.Counter
queriedSamples prometheus.Histogram
queriedExemplars prometheus.Histogram
queriedSeries prometheus.Histogram
queriedChunks prometheus.Histogram
memSeries prometheus.Gauge
memMetadata prometheus.Gauge
memUsers prometheus.Gauge
memSeriesCreatedTotal *prometheus.CounterVec
memMetadataCreatedTotal *prometheus.CounterVec
memSeriesRemovedTotal *prometheus.CounterVec
memMetadataRemovedTotal *prometheus.CounterVec
activeSeriesPerUser *prometheus.GaugeVec
// Global limit metrics
maxUsersGauge prometheus.GaugeFunc
maxSeriesGauge prometheus.GaugeFunc
maxIngestionRate prometheus.GaugeFunc
ingestionRate prometheus.GaugeFunc
maxInflightPushRequests prometheus.GaugeFunc
inflightRequests prometheus.GaugeFunc
inflightQueryRequests prometheus.GaugeFunc
}
func newIngesterMetrics(r prometheus.Registerer,
createMetricsConflictingWithTSDB bool,
activeSeriesEnabled bool,
instanceLimitsFn func() *InstanceLimits,
ingestionRate *util_math.EwmaRate,
inflightPushRequests *atomic.Int64,
maxInflightQueryRequests *util_math.MaxTracker,
) *ingesterMetrics {
const (
instanceLimits = "cortex_ingester_instance_limits"
instanceLimitsHelp = "Instance limits used by this ingester." // Must be same for all registrations.
limitLabel = "limit"
)
m := &ingesterMetrics{
ingestedSamples: promauto.With(r).NewCounter(prometheus.CounterOpts{
Name: "cortex_ingester_ingested_samples_total",
Help: "The total number of samples ingested.",
}),
ingestedExemplars: promauto.With(r).NewCounter(prometheus.CounterOpts{
Name: "cortex_ingester_ingested_exemplars_total",
Help: "The total number of exemplars ingested.",
}),
ingestedMetadata: promauto.With(r).NewCounter(prometheus.CounterOpts{
Name: "cortex_ingester_ingested_metadata_total",
Help: "The total number of metadata ingested.",
}),
ingestedSamplesFail: promauto.With(r).NewCounter(prometheus.CounterOpts{
Name: "cortex_ingester_ingested_samples_failures_total",
Help: "The total number of samples that errored on ingestion.",
}),
ingestedExemplarsFail: promauto.With(r).NewCounter(prometheus.CounterOpts{
Name: "cortex_ingester_ingested_exemplars_failures_total",
Help: "The total number of exemplars that errored on ingestion.",
}),
ingestedMetadataFail: promauto.With(r).NewCounter(prometheus.CounterOpts{
Name: "cortex_ingester_ingested_metadata_failures_total",
Help: "The total number of metadata that errored on ingestion.",
}),
queries: promauto.With(r).NewCounter(prometheus.CounterOpts{
Name: "cortex_ingester_queries_total",
Help: "The total number of queries the ingester has handled.",
}),
queriedSamples: promauto.With(r).NewHistogram(prometheus.HistogramOpts{
Name: "cortex_ingester_queried_samples",
Help: "The total number of samples returned from queries.",
// Could easily return 10m samples per query - 10*(8^(8-1)) = 20.9m.
Buckets: prometheus.ExponentialBuckets(10, 8, 8),
}),
queriedExemplars: promauto.With(r).NewHistogram(prometheus.HistogramOpts{
Name: "cortex_ingester_queried_exemplars",
Help: "The total number of exemplars returned from queries.",
// A reasonable upper bound is around 6k - 10*(5^(5-1)) = 6250.
Buckets: prometheus.ExponentialBuckets(10, 5, 5),
}),
queriedSeries: promauto.With(r).NewHistogram(prometheus.HistogramOpts{
Name: "cortex_ingester_queried_series",
Help: "The total number of series returned from queries.",
// A reasonable upper bound is around 100k - 10*(8^(6-1)) = 327k.
Buckets: prometheus.ExponentialBuckets(10, 8, 6),
}),
queriedChunks: promauto.With(r).NewHistogram(prometheus.HistogramOpts{
Name: "cortex_ingester_queried_chunks",
Help: "The total number of chunks returned from queries.",
// A small number of chunks per series - 10*(8^(7-1)) = 2.6m.
Buckets: prometheus.ExponentialBuckets(10, 8, 7),
}),
memSeries: promauto.With(r).NewGauge(prometheus.GaugeOpts{
Name: "cortex_ingester_memory_series",
Help: "The current number of series in memory.",
}),
memMetadata: promauto.With(r).NewGauge(prometheus.GaugeOpts{
Name: "cortex_ingester_memory_metadata",
Help: "The current number of metadata in memory.",
}),
memUsers: promauto.With(r).NewGauge(prometheus.GaugeOpts{
Name: "cortex_ingester_memory_users",
Help: "The current number of users in memory.",
}),
memMetadataCreatedTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: "cortex_ingester_memory_metadata_created_total",
Help: "The total number of metadata that were created per user",
}, []string{"user"}),
memMetadataRemovedTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: "cortex_ingester_memory_metadata_removed_total",
Help: "The total number of metadata that were removed per user.",
}, []string{"user"}),
maxUsersGauge: promauto.With(r).NewGaugeFunc(prometheus.GaugeOpts{
Name: instanceLimits,
Help: instanceLimitsHelp,
ConstLabels: map[string]string{limitLabel: "max_tenants"},
}, func() float64 {
if g := instanceLimitsFn(); g != nil {
return float64(g.MaxInMemoryTenants)
}
return 0
}),
maxSeriesGauge: promauto.With(r).NewGaugeFunc(prometheus.GaugeOpts{
Name: instanceLimits,
Help: instanceLimitsHelp,
ConstLabels: map[string]string{limitLabel: "max_series"},
}, func() float64 {
if g := instanceLimitsFn(); g != nil {
return float64(g.MaxInMemorySeries)
}
return 0
}),
maxIngestionRate: promauto.With(r).NewGaugeFunc(prometheus.GaugeOpts{
Name: instanceLimits,
Help: instanceLimitsHelp,
ConstLabels: map[string]string{limitLabel: "max_ingestion_rate"},
}, func() float64 {
if g := instanceLimitsFn(); g != nil {
return float64(g.MaxIngestionRate)
}
return 0
}),
maxInflightPushRequests: promauto.With(r).NewGaugeFunc(prometheus.GaugeOpts{
Name: instanceLimits,
Help: instanceLimitsHelp,
ConstLabels: map[string]string{limitLabel: "max_inflight_push_requests"},
}, func() float64 {
if g := instanceLimitsFn(); g != nil {
return float64(g.MaxInflightPushRequests)
}
return 0
}),
ingestionRate: promauto.With(r).NewGaugeFunc(prometheus.GaugeOpts{
Name: "cortex_ingester_ingestion_rate_samples_per_second",
Help: "Current ingestion rate in samples/sec that ingester is using to limit access.",
}, func() float64 {
if ingestionRate != nil {
return ingestionRate.Rate()
}
return 0
}),
inflightRequests: promauto.With(r).NewGaugeFunc(prometheus.GaugeOpts{
Name: "cortex_ingester_inflight_push_requests",
Help: "Current number of inflight push requests in ingester.",
}, func() float64 {
if inflightPushRequests != nil {
return float64(inflightPushRequests.Load())
}
return 0
}),
inflightQueryRequests: promauto.With(r).NewGaugeFunc(prometheus.GaugeOpts{
Name: "cortex_ingester_max_inflight_query_requests",
Help: "Max number of inflight query requests in ingester.",
}, func() float64 {
if maxInflightQueryRequests != nil {
return float64(maxInflightQueryRequests.Load())
}
return 0
}),
// Not registered automatically, but only if activeSeriesEnabled is true.
activeSeriesPerUser: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "cortex_ingester_active_series",
Help: "Number of currently active series per user.",
}, []string{"user"}),
}
if activeSeriesEnabled && r != nil {
r.MustRegister(m.activeSeriesPerUser)
}
if createMetricsConflictingWithTSDB {
m.memSeriesCreatedTotal = promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: memSeriesCreatedTotalName,
Help: memSeriesCreatedTotalHelp,
}, []string{"user"})
m.memSeriesRemovedTotal = promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Name: memSeriesRemovedTotalName,
Help: memSeriesRemovedTotalHelp,
}, []string{"user"})
}
return m
}
func (m *ingesterMetrics) deletePerUserMetrics(userID string) {
m.memMetadataCreatedTotal.DeleteLabelValues(userID)
m.memMetadataRemovedTotal.DeleteLabelValues(userID)
m.activeSeriesPerUser.DeleteLabelValues(userID)
if m.memSeriesCreatedTotal != nil {
m.memSeriesCreatedTotal.DeleteLabelValues(userID)
}
if m.memSeriesRemovedTotal != nil {
m.memSeriesRemovedTotal.DeleteLabelValues(userID)
}
}
// TSDB metrics collector. Each tenant has its own registry, that TSDB code uses.
type tsdbMetrics struct {
// Metrics aggregated from Thanos shipper.
dirSyncs *prometheus.Desc // sum(thanos_shipper_dir_syncs_total)
dirSyncFailures *prometheus.Desc // sum(thanos_shipper_dir_sync_failures_total)
uploads *prometheus.Desc // sum(thanos_shipper_uploads_total)
uploadFailures *prometheus.Desc // sum(thanos_shipper_upload_failures_total)
// Metrics aggregated from TSDB.
tsdbCompactionsTotal *prometheus.Desc
tsdbCompactionDuration *prometheus.Desc
tsdbFsyncDuration *prometheus.Desc
tsdbPageFlushes *prometheus.Desc
tsdbPageCompletions *prometheus.Desc
tsdbWALTruncateFail *prometheus.Desc
tsdbWALTruncateTotal *prometheus.Desc
tsdbWALTruncateDuration *prometheus.Desc
tsdbWALCorruptionsTotal *prometheus.Desc
tsdbWALWritesFailed *prometheus.Desc
tsdbHeadTruncateFail *prometheus.Desc
tsdbHeadTruncateTotal *prometheus.Desc
tsdbHeadGcDuration *prometheus.Desc
tsdbActiveAppenders *prometheus.Desc
tsdbSeriesNotFound *prometheus.Desc
tsdbChunks *prometheus.Desc
tsdbChunksCreatedTotal *prometheus.Desc
tsdbChunksRemovedTotal *prometheus.Desc
tsdbMmapChunkCorruptionTotal *prometheus.Desc
tsdbChunkwriteQueueOperationsTotal *prometheus.Desc
tsdbSamplesAppended *prometheus.Desc
tsdbOutOfOrderSamplesAppended *prometheus.Desc
tsdbSnapshotReplayErrorTotal *prometheus.Desc
tsdbOOOHistogram *prometheus.Desc
tsdbMmapChunksTotal *prometheus.Desc
tsdbDataTotalReplayDuration *prometheus.Desc
tsdbExemplarsTotal *prometheus.Desc
tsdbExemplarsInStorage *prometheus.Desc
tsdbExemplarSeriesInStorage *prometheus.Desc
tsdbExemplarLastTs *prometheus.Desc
tsdbExemplarsOutOfOrder *prometheus.Desc
// Follow metrics are from https://github.com/prometheus/prometheus/blob/fbe960f2c1ad9d6f5fe2f267d2559bf7ecfab6df/tsdb/db.go#L179
tsdbLoadedBlocks *prometheus.Desc
tsdbSymbolTableSize *prometheus.Desc
tsdbReloads *prometheus.Desc
tsdbReloadsFailed *prometheus.Desc
tsdbTimeRetentionCount *prometheus.Desc
tsdbBlocksBytes *prometheus.Desc
checkpointDeleteFail *prometheus.Desc
checkpointDeleteTotal *prometheus.Desc
checkpointCreationFail *prometheus.Desc
checkpointCreationTotal *prometheus.Desc
// These two metrics replace metrics in ingesterMetrics, as we count them differently
memSeriesCreatedTotal *prometheus.Desc
memSeriesRemovedTotal *prometheus.Desc
regs *util.UserRegistries
}
func newTSDBMetrics(r prometheus.Registerer) *tsdbMetrics {
m := &tsdbMetrics{
regs: util.NewUserRegistries(),
dirSyncs: prometheus.NewDesc(
"cortex_ingester_shipper_dir_syncs_total",
"Total number of TSDB dir syncs",
nil, nil),
dirSyncFailures: prometheus.NewDesc(
"cortex_ingester_shipper_dir_sync_failures_total",
"Total number of failed TSDB dir syncs",
nil, nil),
uploads: prometheus.NewDesc(
"cortex_ingester_shipper_uploads_total",
"Total number of uploaded TSDB blocks",
nil, nil),
uploadFailures: prometheus.NewDesc(
"cortex_ingester_shipper_upload_failures_total",
"Total number of TSDB block upload failures",
nil, nil),
tsdbCompactionsTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_compactions_total",
"Total number of TSDB compactions that were executed.",
nil, nil),
tsdbCompactionDuration: prometheus.NewDesc(
"cortex_ingester_tsdb_compaction_duration_seconds",
"Duration of TSDB compaction runs.",
nil, nil),
tsdbFsyncDuration: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_fsync_duration_seconds",
"Duration of TSDB WAL fsync.",
nil, nil),
tsdbPageFlushes: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_page_flushes_total",
"Total number of TSDB WAL page flushes.",
nil, nil),
tsdbPageCompletions: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_completed_pages_total",
"Total number of TSDB WAL completed pages.",
nil, nil),
tsdbWALTruncateFail: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_truncations_failed_total",
"Total number of TSDB WAL truncations that failed.",
nil, nil),
tsdbWALTruncateTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_truncations_total",
"Total number of TSDB WAL truncations attempted.",
nil, nil),
tsdbWALTruncateDuration: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_truncate_duration_seconds",
"Duration of TSDB WAL truncation.",
nil, nil),
tsdbWALCorruptionsTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_corruptions_total",
"Total number of TSDB WAL corruptions.",
nil, nil),
tsdbWALWritesFailed: prometheus.NewDesc(
"cortex_ingester_tsdb_wal_writes_failed_total",
"Total number of TSDB WAL writes that failed.",
nil, nil),
tsdbHeadTruncateFail: prometheus.NewDesc(
"cortex_ingester_tsdb_head_truncations_failed_total",
"Total number of TSDB head truncations that failed.",
nil, nil),
tsdbHeadTruncateTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_head_truncations_total",
"Total number of TSDB head truncations attempted.",
nil, nil),
tsdbHeadGcDuration: prometheus.NewDesc(
"cortex_ingester_tsdb_head_gc_duration_seconds",
"Runtime of garbage collection in the TSDB head.",
nil, nil),
tsdbActiveAppenders: prometheus.NewDesc(
"cortex_ingester_tsdb_head_active_appenders",
"Number of currently active TSDB appender transactions.",
nil, nil),
tsdbSeriesNotFound: prometheus.NewDesc(
"cortex_ingester_tsdb_head_series_not_found_total",
"Total number of TSDB requests for series that were not found.",
nil, nil),
tsdbChunks: prometheus.NewDesc(
"cortex_ingester_tsdb_head_chunks",
"Total number of chunks in the TSDB head block.",
nil, nil),
tsdbChunksCreatedTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_head_chunks_created_total",
"Total number of series created in the TSDB head.",
[]string{"user"}, nil),
tsdbChunksRemovedTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_head_chunks_removed_total",
"Total number of series removed in the TSDB head.",
[]string{"user"}, nil),
tsdbMmapChunkCorruptionTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_mmap_chunk_corruptions_total",
"Total number of memory-mapped TSDB chunk corruptions.",
nil, nil),
tsdbChunkwriteQueueOperationsTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_chunk_write_queue_operations_total",
"Number of currently tsdb chunk write queues.",
[]string{"user", "operation"}, nil),
tsdbDataTotalReplayDuration: prometheus.NewDesc(
"cortex_ingester_tsdb_data_replay_duration_seconds",
"Time taken to replay the tsdb data on disk.",
[]string{"user"}, nil),
tsdbLoadedBlocks: prometheus.NewDesc(
"cortex_ingester_tsdb_blocks_loaded",
"Number of currently loaded data blocks",
nil, nil),
tsdbReloads: prometheus.NewDesc(
"cortex_ingester_tsdb_reloads_total",
"Number of times the database reloaded block data from disk.",
nil, nil),
tsdbReloadsFailed: prometheus.NewDesc(
"cortex_ingester_tsdb_reloads_failures_total",
"Number of times the database failed to reloadBlocks block data from disk.",
nil, nil),
tsdbSymbolTableSize: prometheus.NewDesc(
"cortex_ingester_tsdb_symbol_table_size_bytes",
"Size of symbol table in memory for loaded blocks",
[]string{"user"}, nil),
tsdbBlocksBytes: prometheus.NewDesc(
"cortex_ingester_tsdb_storage_blocks_bytes",
"The number of bytes that are currently used for local storage by all blocks.",
[]string{"user"}, nil),
tsdbTimeRetentionCount: prometheus.NewDesc(
"cortex_ingester_tsdb_time_retentions_total",
"The number of times that blocks were deleted because the maximum time limit was exceeded.",
nil, nil),
checkpointDeleteFail: prometheus.NewDesc(
"cortex_ingester_tsdb_checkpoint_deletions_failed_total",
"Total number of TSDB checkpoint deletions that failed.",
nil, nil),
checkpointDeleteTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_checkpoint_deletions_total",
"Total number of TSDB checkpoint deletions attempted.",
nil, nil),
checkpointCreationFail: prometheus.NewDesc(
"cortex_ingester_tsdb_checkpoint_creations_failed_total",
"Total number of TSDB checkpoint creations that failed.",
nil, nil),
checkpointCreationTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_checkpoint_creations_total",
"Total number of TSDB checkpoint creations attempted.",
nil, nil),
tsdbSamplesAppended: prometheus.NewDesc(
"cortex_ingester_tsdb_head_samples_appended_total",
"Total number of appended samples.",
[]string{"type", "user"}, nil),
tsdbOutOfOrderSamplesAppended: prometheus.NewDesc(
"cortex_ingester_tsdb_head_out_of_order_samples_appended_total",
"Total number of appended out of order samples.",
[]string{"user"}, nil),
tsdbSnapshotReplayErrorTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_snapshot_replay_error_total",
"Total number snapshot replays that failed.",
nil, nil),
tsdbOOOHistogram: prometheus.NewDesc(
"cortex_ingester_tsdb_sample_ooo_delta",
"Delta in seconds by which a sample is considered out of order (reported regardless of OOO time window and whether sample is accepted or not).",
nil, nil),
tsdbMmapChunksTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_mmap_chunks_total",
"Total number of chunks that were memory-mapped.",
nil, nil),
// The most useful exemplar metrics are per-user. The rest
// are global to reduce metrics overhead.
tsdbExemplarsTotal: prometheus.NewDesc(
"cortex_ingester_tsdb_exemplar_exemplars_appended_total",
"Total number of TSDB exemplars appended.",
nil, nil), // see distributor_exemplars_in for per-user rate
tsdbExemplarsInStorage: prometheus.NewDesc(
"cortex_ingester_tsdb_exemplar_exemplars_in_storage",
"Number of TSDB exemplars currently in storage.",
nil, nil),
tsdbExemplarSeriesInStorage: prometheus.NewDesc(
"cortex_ingester_tsdb_exemplar_series_with_exemplars_in_storage",
"Number of TSDB series with exemplars currently in storage.",
[]string{"user"}, nil),
tsdbExemplarLastTs: prometheus.NewDesc(
"cortex_ingester_tsdb_exemplar_last_exemplars_timestamp_seconds",
"The timestamp of the oldest exemplar stored in circular storage. Useful to check for what time "+
"range the current exemplar buffer limit allows. This usually means the last timestamp "+
"for all exemplars for a typical setup. This is not true though if one of the series timestamp is in future compared to rest series.",
[]string{"user"}, nil),
tsdbExemplarsOutOfOrder: prometheus.NewDesc(
"cortex_ingester_tsdb_exemplar_out_of_order_exemplars_total",
"Total number of out of order exemplar ingestion failed attempts.",
nil, nil),
memSeriesCreatedTotal: prometheus.NewDesc(memSeriesCreatedTotalName, memSeriesCreatedTotalHelp, []string{"user"}, nil),
memSeriesRemovedTotal: prometheus.NewDesc(memSeriesRemovedTotalName, memSeriesRemovedTotalHelp, []string{"user"}, nil),
}
if r != nil {
r.MustRegister(m)
}
return m
}
func (sm *tsdbMetrics) Describe(out chan<- *prometheus.Desc) {
out <- sm.dirSyncs
out <- sm.dirSyncFailures
out <- sm.uploads
out <- sm.uploadFailures
out <- sm.tsdbCompactionsTotal
out <- sm.tsdbCompactionDuration
out <- sm.tsdbFsyncDuration
out <- sm.tsdbPageFlushes
out <- sm.tsdbPageCompletions
out <- sm.tsdbWALTruncateFail
out <- sm.tsdbWALTruncateTotal
out <- sm.tsdbWALTruncateDuration
out <- sm.tsdbWALCorruptionsTotal
out <- sm.tsdbWALWritesFailed
out <- sm.tsdbHeadTruncateFail
out <- sm.tsdbHeadTruncateTotal
out <- sm.tsdbHeadGcDuration
out <- sm.tsdbActiveAppenders
out <- sm.tsdbSeriesNotFound
out <- sm.tsdbChunks
out <- sm.tsdbChunksCreatedTotal
out <- sm.tsdbChunksRemovedTotal
out <- sm.tsdbMmapChunkCorruptionTotal
out <- sm.tsdbChunkwriteQueueOperationsTotal
out <- sm.tsdbDataTotalReplayDuration
out <- sm.tsdbLoadedBlocks
out <- sm.tsdbSymbolTableSize
out <- sm.tsdbReloads
out <- sm.tsdbReloadsFailed
out <- sm.tsdbTimeRetentionCount
out <- sm.tsdbBlocksBytes
out <- sm.tsdbSamplesAppended
out <- sm.tsdbOutOfOrderSamplesAppended
out <- sm.tsdbSnapshotReplayErrorTotal
out <- sm.tsdbOOOHistogram
out <- sm.tsdbMmapChunksTotal
out <- sm.checkpointDeleteFail
out <- sm.checkpointDeleteTotal
out <- sm.checkpointCreationFail
out <- sm.checkpointCreationTotal
out <- sm.tsdbExemplarsTotal
out <- sm.tsdbExemplarsInStorage
out <- sm.tsdbExemplarSeriesInStorage
out <- sm.tsdbExemplarLastTs
out <- sm.tsdbExemplarsOutOfOrder
out <- sm.memSeriesCreatedTotal
out <- sm.memSeriesRemovedTotal
}
func (sm *tsdbMetrics) Collect(out chan<- prometheus.Metric) {
data := sm.regs.BuildMetricFamiliesPerUser()
// OK, we have it all. Let's build results.
data.SendSumOfCounters(out, sm.dirSyncs, "thanos_shipper_dir_syncs_total")
data.SendSumOfCounters(out, sm.dirSyncFailures, "thanos_shipper_dir_sync_failures_total")
data.SendSumOfCounters(out, sm.uploads, "thanos_shipper_uploads_total")
data.SendSumOfCounters(out, sm.uploadFailures, "thanos_shipper_upload_failures_total")
data.SendSumOfCounters(out, sm.tsdbCompactionsTotal, "prometheus_tsdb_compactions_total")
data.SendSumOfHistograms(out, sm.tsdbCompactionDuration, "prometheus_tsdb_compaction_duration_seconds")
data.SendSumOfSummaries(out, sm.tsdbFsyncDuration, "prometheus_tsdb_wal_fsync_duration_seconds")
data.SendSumOfCounters(out, sm.tsdbPageFlushes, "prometheus_tsdb_wal_page_flushes_total")
data.SendSumOfCounters(out, sm.tsdbPageCompletions, "prometheus_tsdb_wal_completed_pages_total")
data.SendSumOfCounters(out, sm.tsdbWALTruncateFail, "prometheus_tsdb_wal_truncations_failed_total")
data.SendSumOfCounters(out, sm.tsdbWALTruncateTotal, "prometheus_tsdb_wal_truncations_total")
data.SendSumOfSummaries(out, sm.tsdbWALTruncateDuration, "prometheus_tsdb_wal_truncate_duration_seconds")
data.SendSumOfCounters(out, sm.tsdbWALCorruptionsTotal, "prometheus_tsdb_wal_corruptions_total")
data.SendSumOfCounters(out, sm.tsdbWALWritesFailed, "prometheus_tsdb_wal_writes_failed_total")
data.SendSumOfCounters(out, sm.tsdbHeadTruncateFail, "prometheus_tsdb_head_truncations_failed_total")
data.SendSumOfCounters(out, sm.tsdbHeadTruncateTotal, "prometheus_tsdb_head_truncations_total")
data.SendSumOfSummaries(out, sm.tsdbHeadGcDuration, "prometheus_tsdb_head_gc_duration_seconds")
data.SendSumOfGauges(out, sm.tsdbActiveAppenders, "prometheus_tsdb_head_active_appenders")
data.SendSumOfCounters(out, sm.tsdbSeriesNotFound, "prometheus_tsdb_head_series_not_found_total")
data.SendSumOfGauges(out, sm.tsdbChunks, "prometheus_tsdb_head_chunks")
data.SendSumOfCountersPerUser(out, sm.tsdbChunksCreatedTotal, "prometheus_tsdb_head_chunks_created_total")
data.SendSumOfCountersPerUser(out, sm.tsdbChunksRemovedTotal, "prometheus_tsdb_head_chunks_removed_total")
data.SendSumOfCounters(out, sm.tsdbMmapChunkCorruptionTotal, "prometheus_tsdb_mmap_chunk_corruptions_total")
data.SendSumOfCountersPerUserWithLabels(out, sm.tsdbChunkwriteQueueOperationsTotal, "prometheus_tsdb_chunk_write_queue_operations_total", "operation")
data.SendSumOfGaugesPerUser(out, sm.tsdbDataTotalReplayDuration, "prometheus_tsdb_data_replay_duration_seconds")
data.SendSumOfGauges(out, sm.tsdbLoadedBlocks, "prometheus_tsdb_blocks_loaded")
data.SendSumOfGaugesPerUser(out, sm.tsdbSymbolTableSize, "prometheus_tsdb_symbol_table_size_bytes")
data.SendSumOfCounters(out, sm.tsdbReloads, "prometheus_tsdb_reloads_total")
data.SendSumOfCounters(out, sm.tsdbReloadsFailed, "prometheus_tsdb_reloads_failures_total")
data.SendSumOfCounters(out, sm.tsdbTimeRetentionCount, "prometheus_tsdb_time_retentions_total")
data.SendSumOfGaugesPerUser(out, sm.tsdbBlocksBytes, "prometheus_tsdb_storage_blocks_bytes")
data.SendSumOfCountersPerUserWithLabels(out, sm.tsdbSamplesAppended, "prometheus_tsdb_head_samples_appended_total", "type")
data.SendSumOfCountersPerUser(out, sm.tsdbOutOfOrderSamplesAppended, "prometheus_tsdb_head_out_of_order_samples_appended_total")
data.SendSumOfCounters(out, sm.tsdbSnapshotReplayErrorTotal, "prometheus_tsdb_snapshot_replay_error_total")
data.SendSumOfHistograms(out, sm.tsdbOOOHistogram, "prometheus_tsdb_sample_ooo_delta")
data.SendSumOfGauges(out, sm.tsdbMmapChunksTotal, "prometheus_tsdb_mmap_chunks_total")
data.SendSumOfCounters(out, sm.checkpointDeleteFail, "prometheus_tsdb_checkpoint_deletions_failed_total")
data.SendSumOfCounters(out, sm.checkpointDeleteTotal, "prometheus_tsdb_checkpoint_deletions_total")
data.SendSumOfCounters(out, sm.checkpointCreationFail, "prometheus_tsdb_checkpoint_creations_failed_total")
data.SendSumOfCounters(out, sm.checkpointCreationTotal, "prometheus_tsdb_checkpoint_creations_total")
data.SendSumOfCounters(out, sm.tsdbExemplarsTotal, "prometheus_tsdb_exemplar_exemplars_appended_total")
data.SendSumOfGauges(out, sm.tsdbExemplarsInStorage, "prometheus_tsdb_exemplar_exemplars_in_storage")
data.SendSumOfGaugesPerUser(out, sm.tsdbExemplarSeriesInStorage, "prometheus_tsdb_exemplar_series_with_exemplars_in_storage")
data.SendSumOfGaugesPerUser(out, sm.tsdbExemplarLastTs, "prometheus_tsdb_exemplar_last_exemplars_timestamp_seconds")
data.SendSumOfCounters(out, sm.tsdbExemplarsOutOfOrder, "prometheus_tsdb_exemplar_out_of_order_exemplars_total")
data.SendSumOfCountersPerUser(out, sm.memSeriesCreatedTotal, "prometheus_tsdb_head_series_created_total")
data.SendSumOfCountersPerUser(out, sm.memSeriesRemovedTotal, "prometheus_tsdb_head_series_removed_total")
}
func (sm *tsdbMetrics) setRegistryForUser(userID string, registry *prometheus.Registry) {
sm.regs.AddUserRegistry(userID, registry)
}
func (sm *tsdbMetrics) removeRegistryForUser(userID string) {
sm.regs.RemoveUserRegistry(userID, false)
}