|
37 | 37 | //
|
38 | 38 | // type metrics struct {
|
39 | 39 | // cpuTemp prometheus.Gauge
|
40 |
| -// hdFailures *prometheus.CounterVec |
| 40 | +// hdFailures *prometheus.CounterVec |
41 | 41 | // }
|
42 | 42 | //
|
43 | 43 | // func NewMetrics(reg prometheus.Registerer) *metrics {
|
44 |
| -// m := &metrics{ |
45 |
| -// cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{ |
46 |
| -// Name: "cpu_temperature_celsius", |
47 |
| -// Help: "Current temperature of the CPU.", |
48 |
| -// }), |
49 |
| -// hdFailures: prometheus.NewCounterVec( |
50 |
| -// prometheus.CounterOpts{ |
51 |
| -// Name: "hd_errors_total", |
52 |
| -// Help: "Number of hard-disk errors.", |
53 |
| -// }, |
54 |
| -// []string{"device"}, |
55 |
| -// ), |
56 |
| -// } |
57 |
| -// reg.MustRegister(m.cpuTemp) |
58 |
| -// reg.MustRegister(m.hdFailures) |
59 |
| -// return m |
| 44 | +// m := &metrics{ |
| 45 | +// cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{ |
| 46 | +// Name: "cpu_temperature_celsius", |
| 47 | +// Help: "Current temperature of the CPU.", |
| 48 | +// }), |
| 49 | +// hdFailures: prometheus.NewCounterVec( |
| 50 | +// prometheus.CounterOpts{ |
| 51 | +// Name: "hd_errors_total", |
| 52 | +// Help: "Number of hard-disk errors.", |
| 53 | +// }, |
| 54 | +// []string{"device"}, |
| 55 | +// ), |
| 56 | +// } |
| 57 | +// reg.MustRegister(m.cpuTemp) |
| 58 | +// reg.MustRegister(m.hdFailures) |
| 59 | +// return m |
60 | 60 | // }
|
61 | 61 | //
|
62 | 62 | // func main() {
|
63 |
| -// // Create a non-global registry. |
64 |
| -// reg := prometheus.NewRegistry() |
| 63 | +// // Create a non-global registry. |
| 64 | +// reg := prometheus.NewRegistry() |
65 | 65 | //
|
66 |
| -// // Create new metrics and register them using the custom registry. |
67 |
| -// m := NewMetrics(reg) |
68 |
| -// // Set values for the new created metrics. |
| 66 | +// // Create new metrics and register them using the custom registry. |
| 67 | +// m := NewMetrics(reg) |
| 68 | +// // Set values for the new created metrics. |
69 | 69 | // m.cpuTemp.Set(65.3)
|
70 | 70 | // m.hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc()
|
71 | 71 | //
|
|
0 commit comments