go.etcd.io/etcd@v3.3.27+incompatible/rafthttp/metrics.go (about)

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