github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/lifecycle/tally/stats.go (about) 1 // Copyright (c) 2020-2021, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package tally 6 7 import ( 8 "fmt" 9 10 "github.com/prometheus/client_golang/prometheus" 11 ) 12 13 var registerStats = true 14 15 func (r *Recorder) createStats() { 16 r.okEvents = prometheus.NewCounterVec(prometheus.CounterOpts{ 17 Name: fmt.Sprintf("%s_good_events", r.options.StatPrefix), 18 Help: "The number of successfully parsed events received", 19 }, []string{"component", "active"}) 20 21 r.badEvents = prometheus.NewCounterVec(prometheus.CounterOpts{ 22 Name: fmt.Sprintf("%s_process_errors", r.options.StatPrefix), 23 Help: "The number of events received that failed to process", 24 }, []string{"component", "active"}) 25 26 r.eventTypes = prometheus.NewCounterVec(prometheus.CounterOpts{ 27 Name: fmt.Sprintf("%s_event_types", r.options.StatPrefix), 28 Help: "The number events received by type", 29 }, []string{"component", "type", "active"}) 30 31 r.versionsTally = prometheus.NewGaugeVec(prometheus.GaugeOpts{ 32 Name: fmt.Sprintf("%s_versions", r.options.StatPrefix), 33 Help: "The number of observations for a specific version and component", 34 }, []string{"component", "version", "active"}) 35 36 r.processTime = prometheus.NewSummaryVec(prometheus.SummaryOpts{ 37 Name: fmt.Sprintf("%s_processing_time", r.options.StatPrefix), 38 Help: "The time taken to process events", 39 }, []string{"component", "active"}) 40 41 r.transitionEvent = prometheus.NewCounterVec(prometheus.CounterOpts{ 42 Name: fmt.Sprintf("%s_machine_transition", r.options.StatPrefix), 43 Help: "Machine state transition", 44 }, []string{"machine", "version", "transition", "from", "to", "active"}) 45 46 r.execWatchSuccess = prometheus.NewCounterVec(prometheus.CounterOpts{ 47 Name: fmt.Sprintf("%s_exec_watcher_success", r.options.StatPrefix), 48 Help: "Machine exec watcher success runs", 49 }, []string{"machine", "version", "watcher", "active"}) 50 51 r.execWatchFail = prometheus.NewCounterVec(prometheus.CounterOpts{ 52 Name: fmt.Sprintf("%s_exec_watcher_failures", r.options.StatPrefix), 53 Help: "Machine exec watcher failure runs", 54 }, []string{"machine", "version", "watcher", "active"}) 55 56 r.execWatchRuntime = prometheus.NewSummaryVec(prometheus.SummaryOpts{ 57 Name: fmt.Sprintf("%s_exec_watcher_runtime", r.options.StatPrefix), 58 Help: "Machine exec watcher runtimes", 59 }, []string{"machine", "version", "watcher", "active"}) 60 61 r.nodesExpired = prometheus.NewCounterVec(prometheus.CounterOpts{ 62 Name: fmt.Sprintf("%s_nodes_expired", r.options.StatPrefix), 63 Help: "The number of nodes that were expired after not receiving alive events", 64 }, []string{"component", "active"}) 65 66 r.governorEvents = prometheus.NewCounterVec(prometheus.CounterOpts{ 67 Name: fmt.Sprintf("%s_governor", r.options.StatPrefix), 68 Help: "Choria Governor events", 69 }, []string{"component", "governor", "event", "active"}) 70 71 if registerStats { 72 prometheus.MustRegister(r.okEvents) 73 prometheus.MustRegister(r.badEvents) 74 prometheus.MustRegister(r.eventTypes) 75 prometheus.MustRegister(r.versionsTally) 76 prometheus.MustRegister(r.processTime) 77 prometheus.MustRegister(r.transitionEvent) 78 prometheus.MustRegister(r.nodesExpired) 79 prometheus.MustRegister(r.governorEvents) 80 prometheus.MustRegister(r.execWatchFail) 81 prometheus.MustRegister(r.execWatchSuccess) 82 prometheus.MustRegister(r.execWatchRuntime) 83 } 84 }