-
Notifications
You must be signed in to change notification settings - Fork 7
/
prometheus.go
66 lines (55 loc) · 1.64 KB
/
prometheus.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"net/http"
"sync"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var connectedClients = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "hfp_client_connects_in",
Help: "No of inbound client connects",
},
)
var connectionStatus = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "hfp_connection_status_out",
Help: "Connection status OUT - 1 is connected, 0 is disconnected",
},
)
var hepBytesInFile = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "hfp_hep_bytes_in_file",
Help: "No of HEP bytes in file",
},
)
var hepFileFlushesSuccess = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "hfp_hep_file_flushes_success",
Help: "No of times HEP pakets from file have been successfully sent over network to backend HEP server",
},
)
var hepFileFlushesError = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "hfp_hep_file_flushes_error",
Help: "No of times HEP pakets from file failed sending over network to backend HEP server",
},
)
var clientLastMetricTimestamp = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "hfp_client_in_last_metric_timestamp",
Help: "Inbound client's last metric arrival",
},
)
func startMetrics(wg *sync.WaitGroup) {
wg.Add(1)
prometheus.MustRegister(connectedClients)
prometheus.MustRegister(connectionStatus)
prometheus.MustRegister(hepBytesInFile)
prometheus.MustRegister(hepFileFlushesSuccess)
prometheus.MustRegister(hepFileFlushesError)
prometheus.MustRegister(clientLastMetricTimestamp)
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":"+*PrometheusPort, nil)
wg.Done()
}