-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
metrics.go
3215 lines (3024 loc) · 132 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
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2016 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package kvserver
import (
"context"
"fmt"
"runtime/debug"
"sync/atomic"
"time"
"unsafe"
"github.com/cockroachdb/cockroach/pkg/kv/kvbase"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/allocatorimpl"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval/result"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/rangefeed"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/split"
"github.com/cockroachdb/cockroach/pkg/multitenant"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/metric"
"github.com/cockroachdb/cockroach/pkg/util/metric/aggmetric"
"github.com/cockroachdb/cockroach/pkg/util/slidingwindow"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/pebble"
"go.etcd.io/raft/v3/raftpb"
)
func init() {
// Inject the TenantStorageMetricsSet available in the kvbase pkg to
// avoid import cycles.
kvbase.TenantsStorageMetricsSet = tenantsStorageMetricsSet()
}
var (
// Replica metrics.
metaReplicaCount = metric.Metadata{
Name: "replicas",
Help: "Number of replicas",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaReservedReplicaCount = metric.Metadata{
Name: "replicas.reserved",
Help: "Number of replicas reserved for snapshots",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaRaftLeaderCount = metric.Metadata{
Name: "replicas.leaders",
Help: "Number of raft leaders",
Measurement: "Raft Leaders",
Unit: metric.Unit_COUNT,
}
metaRaftLeaderNotLeaseHolderCount = metric.Metadata{
Name: "replicas.leaders_not_leaseholders",
Help: "Number of replicas that are Raft leaders whose range lease is held by another store",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaRaftLeaderInvalidLeaseCount = metric.Metadata{
Name: "replicas.leaders_invalid_lease",
Help: "Number of replicas that are Raft leaders whose lease is invalid",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaLeaseHolderCount = metric.Metadata{
Name: "replicas.leaseholders",
Help: "Number of lease holders",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaQuiescentCount = metric.Metadata{
Name: "replicas.quiescent",
Help: "Number of quiesced replicas",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaUninitializedCount = metric.Metadata{
Name: "replicas.uninitialized",
Help: "Number of uninitialized replicas, this does not include uninitialized replicas that can lie dormant in a persistent state.",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
// Range metrics.
metaRangeCount = metric.Metadata{
Name: "ranges",
Help: "Number of ranges",
Measurement: "Ranges",
Unit: metric.Unit_COUNT,
}
metaUnavailableRangeCount = metric.Metadata{
Name: "ranges.unavailable",
Help: "Number of ranges with fewer live replicas than needed for quorum",
Measurement: "Ranges",
Unit: metric.Unit_COUNT,
}
metaUnderReplicatedRangeCount = metric.Metadata{
Name: "ranges.underreplicated",
Help: "Number of ranges with fewer live replicas than the replication target",
Measurement: "Ranges",
Unit: metric.Unit_COUNT,
}
metaOverReplicatedRangeCount = metric.Metadata{
Name: "ranges.overreplicated",
Help: "Number of ranges with more live replicas than the replication target",
Measurement: "Ranges",
Unit: metric.Unit_COUNT,
}
// Lease request metrics.
metaLeaseRequestSuccessCount = metric.Metadata{
Name: "leases.success",
Help: "Number of successful lease requests",
Measurement: "Lease Requests",
Unit: metric.Unit_COUNT,
}
metaLeaseRequestErrorCount = metric.Metadata{
Name: "leases.error",
Help: "Number of failed lease requests",
Measurement: "Lease Requests",
Unit: metric.Unit_COUNT,
}
metaLeaseRequestLatency = metric.Metadata{
Name: "leases.requests.latency",
Help: "Lease request latency (all types and outcomes, coalesced)",
Measurement: "Latency",
Unit: metric.Unit_NANOSECONDS,
}
metaLeaseTransferSuccessCount = metric.Metadata{
Name: "leases.transfers.success",
Help: "Number of successful lease transfers",
Measurement: "Lease Transfers",
Unit: metric.Unit_COUNT,
}
metaLeaseTransferErrorCount = metric.Metadata{
Name: "leases.transfers.error",
Help: "Number of failed lease transfers",
Measurement: "Lease Transfers",
Unit: metric.Unit_COUNT,
}
metaLeaseExpirationCount = metric.Metadata{
Name: "leases.expiration",
Help: "Number of replica leaseholders using expiration-based leases",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaLeaseEpochCount = metric.Metadata{
Name: "leases.epoch",
Help: "Number of replica leaseholders using epoch-based leases",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
metaLeaseLivenessCount = metric.Metadata{
Name: "leases.liveness",
Help: "Number of replica leaseholders for the liveness range(s)",
Measurement: "Replicas",
Unit: metric.Unit_COUNT,
}
// Storage metrics.
metaLiveBytes = metric.Metadata{
Name: "livebytes",
Help: "Number of bytes of live data (keys plus values)",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaKeyBytes = metric.Metadata{
Name: "keybytes",
Help: "Number of bytes taken up by keys",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaValBytes = metric.Metadata{
Name: "valbytes",
Help: "Number of bytes taken up by values",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaRangeKeyBytes = metric.Metadata{
Name: "rangekeybytes",
Help: "Number of bytes taken up by range keys (e.g. MVCC range tombstones)",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaRangeValBytes = metric.Metadata{
Name: "rangevalbytes",
Help: "Number of bytes taken up by range key values (e.g. MVCC range tombstones)",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaTotalBytes = metric.Metadata{
Name: "totalbytes",
Help: "Total number of bytes taken up by keys and values including non-live data",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaIntentBytes = metric.Metadata{
Name: "intentbytes",
Help: "Number of bytes in intent KV pairs",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaLiveCount = metric.Metadata{
Name: "livecount",
Help: "Count of live keys",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaKeyCount = metric.Metadata{
Name: "keycount",
Help: "Count of all keys",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaValCount = metric.Metadata{
Name: "valcount",
Help: "Count of all values",
Measurement: "MVCC Values",
Unit: metric.Unit_COUNT,
}
metaRangeKeyCount = metric.Metadata{
Name: "rangekeycount",
Help: "Count of all range keys (e.g. MVCC range tombstones)",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaRangeValCount = metric.Metadata{
Name: "rangevalcount",
Help: "Count of all range key values (e.g. MVCC range tombstones)",
Measurement: "MVCC Values",
Unit: metric.Unit_COUNT,
}
metaIntentCount = metric.Metadata{
Name: "intentcount",
Help: "Count of intent keys",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaIntentAge = metric.Metadata{
Name: "intentage",
Help: "Cumulative age of intents",
Measurement: "Age",
Unit: metric.Unit_SECONDS,
}
metaGcBytesAge = metric.Metadata{
Name: "gcbytesage",
Help: "Cumulative age of non-live data",
Measurement: "Age",
Unit: metric.Unit_SECONDS,
}
// Contention and intent resolution metrics.
metaResolveCommit = metric.Metadata{
Name: "intents.resolve-attempts",
Help: "Count of (point or range) intent commit evaluation attempts",
Measurement: "Operations",
Unit: metric.Unit_COUNT,
}
metaResolveAbort = metric.Metadata{
Name: "intents.abort-attempts",
Help: "Count of (point or range) non-poisoning intent abort evaluation attempts",
Measurement: "Operations",
Unit: metric.Unit_COUNT,
}
metaResolvePoison = metric.Metadata{
Name: "intents.poison-attempts",
Help: "Count of (point or range) poisoning intent abort evaluation attempts",
Measurement: "Operations",
Unit: metric.Unit_COUNT,
}
// Disk usage diagram (CR=Cockroach):
// ---------------------------------
// Entire hard drive: | non-CR data | CR data | empty |
// ---------------------------------
// Metrics:
// "capacity": |===============================|
// "used": |=========|
// "available": |=======|
// "usable" (computed in UI): |=================|
metaCapacity = metric.Metadata{
Name: "capacity",
Help: "Total storage capacity",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaAvailable = metric.Metadata{
Name: "capacity.available",
Help: "Available storage capacity",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaUsed = metric.Metadata{
Name: "capacity.used",
Help: "Used storage capacity",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaReserved = metric.Metadata{
Name: "capacity.reserved",
Help: "Capacity reserved for snapshots",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaSysBytes = metric.Metadata{
Name: "sysbytes",
Help: "Number of bytes in system KV pairs",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaSysCount = metric.Metadata{
Name: "syscount",
Help: "Count of system KV pairs",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaAbortSpanBytes = metric.Metadata{
Name: "abortspanbytes",
Help: "Number of bytes in the abort span",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
// Metrics used by the rebalancing logic that aren't already captured elsewhere.
metaAverageQueriesPerSecond = metric.Metadata{
Name: "rebalancing.queriespersecond",
Help: "Number of kv-level requests received per second by the store, considering the last 30 minutes, as used in rebalancing decisions.",
Measurement: "Queries/Sec",
Unit: metric.Unit_COUNT,
}
metaAverageWritesPerSecond = metric.Metadata{
Name: "rebalancing.writespersecond",
Help: "Number of keys written (i.e. applied by raft) per second to the store, considering the last 30 minutes.",
Measurement: "Keys/Sec",
Unit: metric.Unit_COUNT,
}
metaAverageRequestsPerSecond = metric.Metadata{
Name: "rebalancing.requestspersecond",
Help: "Number of requests received recently per second, considering the last 30 minutes.",
Measurement: "Requests/Sec",
Unit: metric.Unit_COUNT,
}
metaAverageReadsPerSecond = metric.Metadata{
Name: "rebalancing.readspersecond",
Help: "Number of keys read recently per second, considering the last 30 minutes.",
Measurement: "Keys/Sec",
Unit: metric.Unit_COUNT,
}
metaAverageWriteBytesPerSecond = metric.Metadata{
Name: "rebalancing.writebytespersecond",
Help: "Number of bytes written recently per second, considering the last 30 minutes.",
Measurement: "Bytes/Sec",
Unit: metric.Unit_BYTES,
}
metaAverageReadBytesPerSecond = metric.Metadata{
Name: "rebalancing.readbytespersecond",
Help: "Number of bytes read recently per second, considering the last 30 minutes.",
Measurement: "Bytes/Sec",
Unit: metric.Unit_BYTES,
}
metaAverageCPUNanosPerSecond = metric.Metadata{
Name: "rebalancing.cpunanospersecond",
Help: "Average CPU nanoseconds spent on processing replica operations in the last 30 minutes.",
Measurement: "Nanoseconds/Sec",
Unit: metric.Unit_NANOSECONDS,
}
metaRecentReplicaCPUNanosPerSecond = metric.Metadata{
Name: "rebalancing.replicas.cpunanospersecond",
Help: "Histogram of average CPU nanoseconds spent on processing " +
"replica operations in the last 30 minutes.",
Measurement: "Nanoseconds/Sec",
Unit: metric.Unit_NANOSECONDS,
}
metaRecentReplicaQueriesPerSecond = metric.Metadata{
Name: "rebalancing.replicas.queriespersecond",
Help: "Histogram of average kv-level requests received per second by " +
"replicas on the store in the last 30 minutes.",
Measurement: "Queries/Sec",
Unit: metric.Unit_COUNT,
}
// Metric for tracking follower reads.
metaFollowerReadsCount = metric.Metadata{
Name: "follower_reads.success_count",
Help: "Number of reads successfully processed by any replica",
Measurement: "Read Ops",
Unit: metric.Unit_COUNT,
}
// Server-side transaction metrics.
metaCommitWaitBeforeCommitTriggerCount = metric.Metadata{
Name: "txn.commit_waits.before_commit_trigger",
Help: "Number of KV transactions that had to commit-wait on the server " +
"before committing because they had a commit trigger",
Measurement: "KV Transactions",
Unit: metric.Unit_COUNT,
}
metaWriteEvaluationServerSideRetrySuccess = metric.Metadata{
Name: "txn.server_side_retry.write_evaluation.success",
Help: "Number of write batches that were successfully refreshed server side",
Measurement: "KV Transactions",
Unit: metric.Unit_COUNT,
}
metaWriteEvaluationServerSideRetryFailure = metric.Metadata{
Name: "txn.server_side_retry.write_evaluation.failure",
Help: "Number of write batches that were not successfully refreshed server side",
Measurement: "KV Transactions",
Unit: metric.Unit_COUNT,
}
metaReadEvaluationServerSideRetrySuccess = metric.Metadata{
Name: "txn.server_side_retry.read_evaluation.success",
Help: "Number of read batches that were successfully refreshed server side",
Measurement: "KV Transactions",
Unit: metric.Unit_COUNT,
}
metaReadEvaluationServerSideRetryFailure = metric.Metadata{
Name: "txn.server_side_retry.read_evaluation.failure",
Help: "Number of read batches that were not successfully refreshed server side",
Measurement: "KV Transactions",
Unit: metric.Unit_COUNT,
}
metaReadWithinUncertaintyIntervalErrorServerSideRetrySuccess = metric.Metadata{
Name: "txn.server_side_retry.uncertainty_interval_error.success",
Help: "Number of batches that ran into uncertainty interval errors that were " +
"successfully refreshed server side",
Measurement: "KV Transactions",
Unit: metric.Unit_COUNT,
}
metaReadWithinUncertaintyIntervalErrorServerSideRetryFailure = metric.Metadata{
Name: "txn.server_side_retry.uncertainty_interval_error.failure",
Help: "Number of batches that ran into uncertainty interval errors that were not " +
"successfully refreshed server side",
Measurement: "KV Transactions",
Unit: metric.Unit_COUNT,
}
// Pebble metrics.
metaRdbBlockCacheHits = metric.Metadata{
Name: "rocksdb.block.cache.hits",
Help: "Count of block cache hits",
Measurement: "Cache Ops",
Unit: metric.Unit_COUNT,
}
metaRdbBlockCacheMisses = metric.Metadata{
Name: "rocksdb.block.cache.misses",
Help: "Count of block cache misses",
Measurement: "Cache Ops",
Unit: metric.Unit_COUNT,
}
metaRdbBlockCacheUsage = metric.Metadata{
Name: "rocksdb.block.cache.usage",
Help: "Bytes used by the block cache",
Measurement: "Memory",
Unit: metric.Unit_BYTES,
}
metaRdbBloomFilterPrefixChecked = metric.Metadata{
Name: "rocksdb.bloom.filter.prefix.checked",
Help: "Number of times the bloom filter was checked",
Measurement: "Bloom Filter Ops",
Unit: metric.Unit_COUNT,
}
metaRdbBloomFilterPrefixUseful = metric.Metadata{
Name: "rocksdb.bloom.filter.prefix.useful",
Help: "Number of times the bloom filter helped avoid iterator creation",
Measurement: "Bloom Filter Ops",
Unit: metric.Unit_COUNT,
}
metaRdbMemtableTotalSize = metric.Metadata{
Name: "rocksdb.memtable.total-size",
Help: "Current size of memtable in bytes",
Measurement: "Memory",
Unit: metric.Unit_BYTES,
}
metaRdbFlushes = metric.Metadata{
Name: "rocksdb.flushes",
Help: "Number of table flushes",
Measurement: "Flushes",
Unit: metric.Unit_COUNT,
}
metaRdbFlushedBytes = metric.Metadata{
Name: "rocksdb.flushed-bytes",
Help: "Bytes written during flush",
Measurement: "Bytes Written",
Unit: metric.Unit_BYTES,
}
metaRdbCompactions = metric.Metadata{
Name: "rocksdb.compactions",
Help: "Number of table compactions",
Measurement: "Compactions",
Unit: metric.Unit_COUNT,
}
metaRdbIngestedBytes = metric.Metadata{
Name: "rocksdb.ingested-bytes",
Help: "Bytes ingested",
Measurement: "Bytes Ingested",
Unit: metric.Unit_BYTES,
}
metaRdbCompactedBytesRead = metric.Metadata{
Name: "rocksdb.compacted-bytes-read",
Help: "Bytes read during compaction",
Measurement: "Bytes Read",
Unit: metric.Unit_BYTES,
}
metaRdbCompactedBytesWritten = metric.Metadata{
Name: "rocksdb.compacted-bytes-written",
Help: "Bytes written during compaction",
Measurement: "Bytes Written",
Unit: metric.Unit_BYTES,
}
metaRdbTableReadersMemEstimate = metric.Metadata{
Name: "rocksdb.table-readers-mem-estimate",
Help: "Memory used by index and filter blocks",
Measurement: "Memory",
Unit: metric.Unit_BYTES,
}
metaRdbReadAmplification = metric.Metadata{
Name: "rocksdb.read-amplification",
Help: "Number of disk reads per query",
Measurement: "Disk Reads per Query",
Unit: metric.Unit_COUNT,
}
metaRdbNumSSTables = metric.Metadata{
Name: "rocksdb.num-sstables",
Help: "Number of storage engine SSTables",
Measurement: "SSTables",
Unit: metric.Unit_COUNT,
}
metaRdbPendingCompaction = metric.Metadata{
Name: "rocksdb.estimated-pending-compaction",
Help: "Estimated pending compaction bytes",
Measurement: "Storage",
Unit: metric.Unit_BYTES,
}
metaRdbMarkedForCompactionFiles = metric.Metadata{
Name: "storage.marked-for-compaction-files",
Help: "Count of SSTables marked for compaction",
Measurement: "SSTables",
Unit: metric.Unit_COUNT,
}
metaRdbKeysRangeKeySets = metric.Metadata{
Name: "storage.keys.range-key-set.count",
Help: "Approximate count of RangeKeySet internal keys across the storage engine.",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaRdbKeysTombstones = metric.Metadata{
Name: "storage.keys.tombstone.count",
Help: "Approximate count of DEL, SINGLEDEL and RANGEDEL internal keys across the storage engine.",
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
// NB: bytes only ever get flushed into L0, so this metric does not
// exist for any other level.
metaRdbL0BytesFlushed = storageLevelMetricMetadata(
"bytes-flushed",
"Number of bytes flushed (from memtables) into Level %d",
"Bytes",
metric.Unit_BYTES,
)[0]
// NB: sublevels is trivial (zero or one) except on L0.
metaRdbL0Sublevels = storageLevelMetricMetadata(
"sublevels",
"Number of Level %d sublevels",
"Sublevels",
metric.Unit_COUNT,
)[0]
// NB: we only expose the file count in L0 because it matters for
// admission control. The other file counts are less interesting.
metaRdbL0NumFiles = storageLevelMetricMetadata(
"num-files",
"Number of SSTables in Level %d",
"SSTables",
metric.Unit_COUNT,
)[0]
metaRdbBytesIngested = storageLevelMetricMetadata(
"bytes-ingested",
"Number of bytes ingested directly into Level %d",
"Bytes",
metric.Unit_BYTES,
)
metaRdbLevelSize = storageLevelMetricMetadata(
"level-size",
"Size of the SSTables in level %d",
"Bytes",
metric.Unit_BYTES,
)
metaRdbLevelScores = storageLevelMetricMetadata(
"level-score",
"Compaction score of level %d",
"Score",
metric.Unit_COUNT,
)
metaRdbWriteStalls = metric.Metadata{
Name: "storage.write-stalls",
Help: "Number of instances of intentional write stalls to backpressure incoming writes",
Measurement: "Events",
Unit: metric.Unit_COUNT,
}
metaRdbWriteStallNanos = metric.Metadata{
Name: "storage.write-stall-nanos",
Help: "Total write stall duration in nanos",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaRdbCheckpoints = metric.Metadata{
Name: "storage.checkpoints",
Help: `The number of checkpoint directories found in storage.
This is the number of directories found in the auxiliary/checkpoints directory.
Each represents an immutable point-in-time storage engine checkpoint. They are
cheap (consisting mostly of hard links), but over time they effectively become a
full copy of the old state, which increases their relative cost. Checkpoints
must be deleted once acted upon (e.g. copied elsewhere or investigated).
A likely cause of having a checkpoint is that one of the ranges in this store
had inconsistent data among its replicas. Such checkpoint directories are
located in auxiliary/checkpoints/rN_at_M, where N is the range ID, and M is the
Raft applied index at which this checkpoint was taken.`,
Measurement: "Directories",
Unit: metric.Unit_COUNT,
}
metaBlockBytes = metric.Metadata{
Name: "storage.iterator.block-load.bytes",
Help: "Bytes loaded by storage engine iterators (possibly cached). See storage.AggregatedIteratorStats for details.",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaBlockBytesInCache = metric.Metadata{
Name: "storage.iterator.block-load.cached-bytes",
Help: "Bytes loaded by storage engine iterators from the block cache. See storage.AggregatedIteratorStats for details.",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaBlockReadDuration = metric.Metadata{
Name: "storage.iterator.block-load.read-duration",
Help: "Cumulative time storage engine iterators spent loading blocks from durable storage. See storage.AggregatedIteratorStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaIterExternalSeeks = metric.Metadata{
Name: "storage.iterator.external.seeks",
Help: "Cumulative count of seeks performed on storage engine iterators. See storage.AggregatedIteratorStats for details.",
Measurement: "Iterator Ops",
Unit: metric.Unit_COUNT,
}
metaIterExternalSteps = metric.Metadata{
Name: "storage.iterator.external.steps",
Help: "Cumulative count of steps performed on storage engine iterators. See storage.AggregatedIteratorStats for details.",
Measurement: "Iterator Ops",
Unit: metric.Unit_COUNT,
}
metaIterInternalSeeks = metric.Metadata{
Name: "storage.iterator.internal.seeks",
Help: `Cumulative count of seeks performed internally within storage engine iterators.
A value high relative to 'storage.iterator.external.seeks'
is a good indication that there's an accumulation of garbage
internally within the storage engine.
See storage.AggregatedIteratorStats for details.`,
Measurement: "Iterator Ops",
Unit: metric.Unit_COUNT,
}
metaIterInternalSteps = metric.Metadata{
Name: "storage.iterator.internal.steps",
Help: `Cumulative count of steps performed internally within storage engine iterators.
A value high relative to 'storage.iterator.external.steps'
is a good indication that there's an accumulation of garbage
internally within the storage engine.
See storage.AggregatedIteratorStats for more details.`,
Measurement: "Iterator Ops",
Unit: metric.Unit_COUNT,
}
metaStorageCompactionsDuration = metric.Metadata{
Name: "storage.compactions.duration",
Help: `Cumulative sum of all compaction durations.
The rate of this value provides the effective compaction concurrency of a store,
which can be useful to determine whether the maximum compaction concurrency is
fully utilized.`,
Measurement: "Processing Time",
Unit: metric.Unit_NANOSECONDS,
}
metaStorageCompactionsKeysPinnedCount = metric.Metadata{
Name: "storage.compactions.keys.pinned.count",
Help: `Cumulative count of storage engine KVs written to sstables during flushes and compactions due to open LSM snapshots.
Various subsystems of CockroachDB take LSM snapshots to maintain a consistent view
of the database over an extended duration. In order to maintain the consistent view,
flushes and compactions within the storage engine must preserve keys that otherwise
would have been dropped. This increases write amplification, and introduces keys
that must be skipped during iteration. This metric records the cumulative count of
KVs preserved during flushes and compactions over the lifetime of the process.
`,
Measurement: "Keys",
Unit: metric.Unit_COUNT,
}
metaStorageCompactionsKeysPinnedBytes = metric.Metadata{
Name: "storage.compactions.keys.pinned.bytes",
Help: `Cumulative size of storage engine KVs written to sstables during flushes and compactions due to open LSM snapshots.
Various subsystems of CockroachDB take LSM snapshots to maintain a consistent view
of the database over an extended duration. In order to maintain the consistent view,
flushes and compactions within the storage engine must preserve keys that otherwise
would have been dropped. This increases write amplification, and introduces keys
that must be skipped during iteration. This metric records the cumulative number of
bytes preserved during flushes and compactions over the lifetime of the process.
`,
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaSharedStorageBytesWritten = metric.Metadata{
Name: "storage.shared-storage.write",
Help: "Bytes written to external storage",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaSharedStorageBytesRead = metric.Metadata{
Name: "storage.shared-storage.read",
Help: "Bytes read from shared storage",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaFlushableIngestCount = metric.Metadata{
Name: "storage.flush.ingest.count",
Help: "Flushes performing an ingest (flushable ingestions)",
Measurement: "Flushes",
Unit: metric.Unit_COUNT,
}
metaFlushableIngestTableCount = metric.Metadata{
Name: "storage.flush.ingest.table.count",
Help: "Tables ingested via flushes (flushable ingestions)",
Measurement: "Tables",
Unit: metric.Unit_COUNT,
}
metaFlushableIngestTableBytes = metric.Metadata{
Name: "storage.flush.ingest.table.bytes",
Help: "Bytes ingested via flushes (flushable ingestions)",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaBatchCommitCount = metric.Metadata{
Name: "storage.batch-commit.count",
Help: "Count of batch commits. See storage.AggregatedBatchCommitStats for details.",
Measurement: "Commit Ops",
Unit: metric.Unit_COUNT,
}
metaBatchCommitDuration = metric.Metadata{
Name: "storage.batch-commit.duration",
Help: "Cumulative time spent in batch commit. " +
"See storage.AggregatedBatchCommitStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaBatchCommitSemWaitDuration = metric.Metadata{
Name: "storage.batch-commit.sem-wait.duration",
Help: "Cumulative time spent in semaphore wait, for batch commit. " +
"See storage.AggregatedBatchCommitStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaBatchCommitWALQWaitDuration = metric.Metadata{
Name: "storage.batch-commit.wal-queue-wait.duration",
Help: "Cumulative time spent waiting for memory blocks in the WAL queue, for batch commit. " +
"See storage.AggregatedBatchCommitStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaBatchCommitMemStallDuration = metric.Metadata{
Name: "storage.batch-commit.mem-stall.duration",
Help: "Cumulative time spent in a write stall due to too many memtables, for batch commit. " +
"See storage.AggregatedBatchCommitStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaBatchCommitL0StallDuration = metric.Metadata{
Name: "storage.batch-commit.l0-stall.duration",
Help: "Cumulative time spent in a write stall due to high read amplification in L0, for batch commit. " +
"See storage.AggregatedBatchCommitStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaBatchCommitWALRotDuration = metric.Metadata{
Name: "storage.batch-commit.wal-rotation.duration",
Help: "Cumulative time spent waiting for WAL rotation, for batch commit. " +
"See storage.AggregatedBatchCommitStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
metaBatchCommitCommitWaitDuration = metric.Metadata{
Name: "storage.batch-commit.commit-wait.duration",
Help: "Cumulative time spent waiting for WAL sync, for batch commit. " +
"See storage.AggregatedBatchCommitStats for details.",
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}
)
var (
// Disk health metrics.
metaDiskSlow = metric.Metadata{
Name: "storage.disk-slow",
Help: "Number of instances of disk operations taking longer than 10s",
Measurement: "Events",
Unit: metric.Unit_COUNT,
}
metaDiskStalled = metric.Metadata{
Name: "storage.disk-stalled",
Help: "Number of instances of disk operations taking longer than 30s",
Measurement: "Events",
Unit: metric.Unit_COUNT,
}
// Range event metrics.
metaRangeSplits = metric.Metadata{
Name: "range.splits",
Help: "Number of range splits",
Measurement: "Range Ops",
Unit: metric.Unit_COUNT,
}
metaRangeMerges = metric.Metadata{
Name: "range.merges",
Help: "Number of range merges",
Measurement: "Range Ops",
Unit: metric.Unit_COUNT,
}
metaRangeAdds = metric.Metadata{
Name: "range.adds",
Help: "Number of range additions",
Measurement: "Range Ops",
Unit: metric.Unit_COUNT,
}
metaRangeRemoves = metric.Metadata{
Name: "range.removes",
Help: "Number of range removals",
Measurement: "Range Ops",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotsGenerated = metric.Metadata{
Name: "range.snapshots.generated",
Help: "Number of generated snapshots",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotsAppliedByVoters = metric.Metadata{
Name: "range.snapshots.applied-voter",
Help: "Number of snapshots applied by voter replicas",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotsAppliedForInitialUpreplication = metric.Metadata{
Name: "range.snapshots.applied-initial",
Help: "Number of snapshots applied for initial upreplication",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotsAppliedByNonVoter = metric.Metadata{
Name: "range.snapshots.applied-non-voter",
Help: "Number of snapshots applied by non-voter replicas",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotRcvdBytes = metric.Metadata{
Name: "range.snapshots.rcvd-bytes",
Help: "Number of snapshot bytes received",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotSentBytes = metric.Metadata{
Name: "range.snapshots.sent-bytes",
Help: "Number of snapshot bytes sent",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotUnknownRcvdBytes = metric.Metadata{
Name: "range.snapshots.unknown.rcvd-bytes",
Help: "Number of unknown snapshot bytes received",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotUnknownSentBytes = metric.Metadata{
Name: "range.snapshots.unknown.sent-bytes",
Help: "Number of unknown snapshot bytes sent",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotRebalancingRcvdBytes = metric.Metadata{
Name: "range.snapshots.rebalancing.rcvd-bytes",
Help: "Number of rebalancing snapshot bytes received",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotRebalancingSentBytes = metric.Metadata{
Name: "range.snapshots.rebalancing.sent-bytes",
Help: "Number of rebalancing snapshot bytes sent",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotRecoveryRcvdBytes = metric.Metadata{
Name: "range.snapshots.recovery.rcvd-bytes",
Help: "Number of recovery snapshot bytes received",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotRecoverySentBytes = metric.Metadata{
Name: "range.snapshots.recovery.sent-bytes",
Help: "Number of recovery snapshot bytes sent",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotRecvFailed = metric.Metadata{
Name: "range.snapshots.recv-failed",
Help: "Number of range snapshot initialization messages that errored out on the recipient, typically before any data is transferred",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotRecvUnusable = metric.Metadata{
Name: "range.snapshots.recv-unusable",
Help: "Number of range snapshot that were fully transmitted but determined to be unnecessary or unusable",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotSendQueueLength = metric.Metadata{
Name: "range.snapshots.send-queue",
Help: "Number of snapshots queued to send",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotRecvQueueLength = metric.Metadata{
Name: "range.snapshots.recv-queue",
Help: "Number of snapshots queued to receive",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotSendInProgress = metric.Metadata{
Name: "range.snapshots.send-in-progress",
Help: "Number of non-empty snapshots being sent",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotRecvInProgress = metric.Metadata{
Name: "range.snapshots.recv-in-progress",
Help: "Number of non-empty snapshots being received",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotSendTotalInProgress = metric.Metadata{
Name: "range.snapshots.send-total-in-progress",
Help: "Number of total snapshots being sent",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotRecvTotalInProgress = metric.Metadata{
Name: "range.snapshots.recv-total-in-progress",
Help: "Number of total snapshots being received",
Measurement: "Snapshots",
Unit: metric.Unit_COUNT,
}
metaRangeSnapshotSendQueueSize = metric.Metadata{
Name: "range.snapshots.send-queue-bytes",
Help: "Total size of all snapshots in the snapshot send queue",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeSnapshotRecvQueueSize = metric.Metadata{
Name: "range.snapshots.recv-queue-bytes",
Help: "Total size of all snapshots in the snapshot receive queue",
Measurement: "Bytes",
Unit: metric.Unit_BYTES,
}
metaRangeRaftLeaderTransfers = metric.Metadata{
Name: "range.raftleadertransfers",
Help: "Number of raft leader transfers",