metrics.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // Copyright 2015 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 rafthttp
  15. import "github.com/prometheus/client_golang/prometheus"
  16. var (
  17. activePeers = prometheus.NewGaugeVec(prometheus.GaugeOpts{
  18. Namespace: "etcd",
  19. Subsystem: "network",
  20. Name: "active_peers",
  21. Help: "The current number of active peer connections.",
  22. },
  23. []string{"Local", "Remote"},
  24. )
  25. disconnectedPeers = prometheus.NewCounterVec(prometheus.CounterOpts{
  26. Namespace: "etcd",
  27. Subsystem: "network",
  28. Name: "disconnected_peers_total",
  29. Help: "The total number of disconnected peers.",
  30. },
  31. []string{"Local", "Remote"},
  32. )
  33. sentBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
  34. Namespace: "etcd",
  35. Subsystem: "network",
  36. Name: "peer_sent_bytes_total",
  37. Help: "The total number of bytes sent to peers.",
  38. },
  39. []string{"To"},
  40. )
  41. receivedBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
  42. Namespace: "etcd",
  43. Subsystem: "network",
  44. Name: "peer_received_bytes_total",
  45. Help: "The total number of bytes received from peers.",
  46. },
  47. []string{"From"},
  48. )
  49. sentFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
  50. Namespace: "etcd",
  51. Subsystem: "network",
  52. Name: "peer_sent_failures_total",
  53. Help: "The total number of send failures from peers.",
  54. },
  55. []string{"To"},
  56. )
  57. recvFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
  58. Namespace: "etcd",
  59. Subsystem: "network",
  60. Name: "peer_received_failures_total",
  61. Help: "The total number of receive failures from peers.",
  62. },
  63. []string{"From"},
  64. )
  65. snapshotSend = prometheus.NewCounterVec(prometheus.CounterOpts{
  66. Namespace: "etcd",
  67. Subsystem: "network",
  68. Name: "snapshot_send_success",
  69. Help: "Total number of successful snapshot sends",
  70. },
  71. []string{"To"},
  72. )
  73. snapshotSendInflights = prometheus.NewGaugeVec(prometheus.GaugeOpts{
  74. Namespace: "etcd",
  75. Subsystem: "network",
  76. Name: "snapshot_send_inflights_total",
  77. Help: "Total number of inflight snapshot sends",
  78. },
  79. []string{"To"},
  80. )
  81. snapshotSendFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
  82. Namespace: "etcd",
  83. Subsystem: "network",
  84. Name: "snapshot_send_failures",
  85. Help: "Total number of snapshot send failures",
  86. },
  87. []string{"To"},
  88. )
  89. snapshotSendSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{
  90. Namespace: "etcd",
  91. Subsystem: "network",
  92. Name: "snapshot_send_total_duration_seconds",
  93. Help: "Total latency distributions of v3 snapshot sends",
  94. // lowest bucket start of upper bound 0.1 sec (100 ms) with factor 2
  95. // highest bucket start of 0.1 sec * 2^9 == 51.2 sec
  96. Buckets: prometheus.ExponentialBuckets(0.1, 2, 10),
  97. },
  98. []string{"To"},
  99. )
  100. snapshotReceive = prometheus.NewCounterVec(prometheus.CounterOpts{
  101. Namespace: "etcd",
  102. Subsystem: "network",
  103. Name: "snapshot_receive_success",
  104. Help: "Total number of successful snapshot receives",
  105. },
  106. []string{"From"},
  107. )
  108. snapshotReceiveInflights = prometheus.NewGaugeVec(prometheus.GaugeOpts{
  109. Namespace: "etcd",
  110. Subsystem: "network",
  111. Name: "snapshot_receive_inflights_total",
  112. Help: "Total number of inflight snapshot receives",
  113. },
  114. []string{"From"},
  115. )
  116. snapshotReceiveFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
  117. Namespace: "etcd",
  118. Subsystem: "network",
  119. Name: "snapshot_receive_failures",
  120. Help: "Total number of snapshot receive failures",
  121. },
  122. []string{"From"},
  123. )
  124. snapshotReceiveSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{
  125. Namespace: "etcd",
  126. Subsystem: "network",
  127. Name: "snapshot_receive_total_duration_seconds",
  128. Help: "Total latency distributions of v3 snapshot receives",
  129. // lowest bucket start of upper bound 0.1 sec (100 ms) with factor 2
  130. // highest bucket start of 0.1 sec * 2^9 == 51.2 sec
  131. Buckets: prometheus.ExponentialBuckets(0.1, 2, 10),
  132. },
  133. []string{"From"},
  134. )
  135. rttSec = prometheus.NewHistogramVec(prometheus.HistogramOpts{
  136. Namespace: "etcd",
  137. Subsystem: "network",
  138. Name: "peer_round_trip_time_seconds",
  139. Help: "Round-Trip-Time histogram between peers",
  140. // lowest bucket start of upper bound 0.0001 sec (0.1 ms) with factor 2
  141. // highest bucket start of 0.0001 sec * 2^15 == 3.2768 sec
  142. Buckets: prometheus.ExponentialBuckets(0.0001, 2, 16),
  143. },
  144. []string{"To"},
  145. )
  146. )
  147. func init() {
  148. prometheus.MustRegister(activePeers)
  149. prometheus.MustRegister(disconnectedPeers)
  150. prometheus.MustRegister(sentBytes)
  151. prometheus.MustRegister(receivedBytes)
  152. prometheus.MustRegister(sentFailures)
  153. prometheus.MustRegister(recvFailures)
  154. prometheus.MustRegister(snapshotSend)
  155. prometheus.MustRegister(snapshotSendInflights)
  156. prometheus.MustRegister(snapshotSendFailures)
  157. prometheus.MustRegister(snapshotSendSeconds)
  158. prometheus.MustRegister(snapshotReceive)
  159. prometheus.MustRegister(snapshotReceiveInflights)
  160. prometheus.MustRegister(snapshotReceiveFailures)
  161. prometheus.MustRegister(snapshotReceiveSeconds)
  162. prometheus.MustRegister(rttSec)
  163. }