metrics.go 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright 2016 The etcd Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package backend
  15. import "github.com/prometheus/client_golang/prometheus"
  16. var (
  17. commitSec = prometheus.NewHistogram(prometheus.HistogramOpts{
  18. Namespace: "etcd",
  19. Subsystem: "disk",
  20. Name: "backend_commit_duration_seconds",
  21. Help: "The latency distributions of commit called by backend.",
  22. // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
  23. // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
  24. Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
  25. })
  26. rebalanceSec = prometheus.NewHistogram(prometheus.HistogramOpts{
  27. Namespace: "etcd_debugging",
  28. Subsystem: "disk",
  29. Name: "backend_commit_rebalance_duration_seconds",
  30. Help: "The latency distributions of commit.rebalance called by bboltdb backend.",
  31. // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
  32. // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
  33. Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
  34. })
  35. spillSec = prometheus.NewHistogram(prometheus.HistogramOpts{
  36. Namespace: "etcd_debugging",
  37. Subsystem: "disk",
  38. Name: "backend_commit_spill_duration_seconds",
  39. Help: "The latency distributions of commit.spill called by bboltdb backend.",
  40. // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
  41. // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
  42. Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
  43. })
  44. writeSec = prometheus.NewHistogram(prometheus.HistogramOpts{
  45. Namespace: "etcd_debugging",
  46. Subsystem: "disk",
  47. Name: "backend_commit_write_duration_seconds",
  48. Help: "The latency distributions of commit.write called by bboltdb backend.",
  49. // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2
  50. // highest bucket start of 0.001 sec * 2^13 == 8.192 sec
  51. Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
  52. })
  53. defragSec = prometheus.NewHistogram(prometheus.HistogramOpts{
  54. Namespace: "etcd",
  55. Subsystem: "disk",
  56. Name: "backend_defrag_duration_seconds",
  57. Help: "The latency distribution of backend defragmentation.",
  58. // 100 MB usually takes 1 sec, so start with 10 MB of 100 ms
  59. // lowest bucket start of upper bound 0.1 sec (100 ms) with factor 2
  60. // highest bucket start of 0.1 sec * 2^12 == 409.6 sec
  61. Buckets: prometheus.ExponentialBuckets(.1, 2, 13),
  62. })
  63. snapshotTransferSec = prometheus.NewHistogram(prometheus.HistogramOpts{
  64. Namespace: "etcd",
  65. Subsystem: "disk",
  66. Name: "backend_snapshot_duration_seconds",
  67. Help: "The latency distribution of backend snapshots.",
  68. // lowest bucket start of upper bound 0.01 sec (10 ms) with factor 2
  69. // highest bucket start of 0.01 sec * 2^16 == 655.36 sec
  70. Buckets: prometheus.ExponentialBuckets(.01, 2, 17),
  71. })
  72. )
  73. func init() {
  74. prometheus.MustRegister(commitSec)
  75. prometheus.MustRegister(rebalanceSec)
  76. prometheus.MustRegister(spillSec)
  77. prometheus.MustRegister(writeSec)
  78. prometheus.MustRegister(defragSec)
  79. prometheus.MustRegister(snapshotTransferSec)
  80. }