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 15package store 16 17import ( 18 "github.com/prometheus/client_golang/prometheus" 19) 20 21// Set of raw Prometheus metrics. 22// Labels 23// * action = declared in event.go 24// * outcome = Outcome 25// Do not increment directly, use Report* methods. 26var ( 27 readCounter = prometheus.NewCounterVec( 28 prometheus.CounterOpts{ 29 Namespace: "etcd_debugging", 30 Subsystem: "store", 31 Name: "reads_total", 32 Help: "Total number of reads action by (get/getRecursive), local to this member.", 33 }, []string{"action"}) 34 35 writeCounter = prometheus.NewCounterVec( 36 prometheus.CounterOpts{ 37 Namespace: "etcd_debugging", 38 Subsystem: "store", 39 Name: "writes_total", 40 Help: "Total number of writes (e.g. set/compareAndDelete) seen by this member.", 41 }, []string{"action"}) 42 43 readFailedCounter = prometheus.NewCounterVec( 44 prometheus.CounterOpts{ 45 Namespace: "etcd_debugging", 46 Subsystem: "store", 47 Name: "reads_failed_total", 48 Help: "Failed read actions by (get/getRecursive), local to this member.", 49 }, []string{"action"}) 50 51 writeFailedCounter = prometheus.NewCounterVec( 52 prometheus.CounterOpts{ 53 Namespace: "etcd_debugging", 54 Subsystem: "store", 55 Name: "writes_failed_total", 56 Help: "Failed write actions (e.g. set/compareAndDelete), seen by this member.", 57 }, []string{"action"}) 58 59 expireCounter = prometheus.NewCounter( 60 prometheus.CounterOpts{ 61 Namespace: "etcd_debugging", 62 Subsystem: "store", 63 Name: "expires_total", 64 Help: "Total number of expired keys.", 65 }) 66 67 watchRequests = prometheus.NewCounter( 68 prometheus.CounterOpts{ 69 Namespace: "etcd_debugging", 70 Subsystem: "store", 71 Name: "watch_requests_total", 72 Help: "Total number of incoming watch requests (new or reestablished).", 73 }) 74 75 watcherCount = prometheus.NewGauge( 76 prometheus.GaugeOpts{ 77 Namespace: "etcd_debugging", 78 Subsystem: "store", 79 Name: "watchers", 80 Help: "Count of currently active watchers.", 81 }) 82) 83 84const ( 85 GetRecursive = "getRecursive" 86) 87 88func init() { 89 prometheus.MustRegister(readCounter) 90 prometheus.MustRegister(writeCounter) 91 prometheus.MustRegister(expireCounter) 92 prometheus.MustRegister(watchRequests) 93 prometheus.MustRegister(watcherCount) 94} 95 96func reportReadSuccess(read_action string) { 97 readCounter.WithLabelValues(read_action).Inc() 98} 99 100func reportReadFailure(read_action string) { 101 readCounter.WithLabelValues(read_action).Inc() 102 readFailedCounter.WithLabelValues(read_action).Inc() 103} 104 105func reportWriteSuccess(write_action string) { 106 writeCounter.WithLabelValues(write_action).Inc() 107} 108 109func reportWriteFailure(write_action string) { 110 writeCounter.WithLabelValues(write_action).Inc() 111 writeFailedCounter.WithLabelValues(write_action).Inc() 112} 113 114func reportExpiredKey() { 115 expireCounter.Inc() 116} 117 118func reportWatchRequest() { 119 watchRequests.Inc() 120} 121 122func reportWatcherAdded() { 123 watcherCount.Inc() 124} 125 126func reportWatcherRemoved() { 127 watcherCount.Dec() 128} 129