-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
53 lines (48 loc) · 1.34 KB
/
metrics.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
package lobby
import (
"strconv"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
const (
sourceOpenNox = "opennox"
sourceXWIS = "xwis"
)
var (
serverLabelNames = []string{"src", "addr", "port", "name", "vers", "mode", "map"}
cntGameSeen = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "nox_game_seen",
Help: "Number of times the game was seen online",
}, serverLabelNames)
cntGameExpired = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "nox_game_expired",
Help: "Number of times the game registration expired",
}, serverLabelNames)
cntGamePlayers = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "nox_game_players",
Help: "Number of players in the game",
}, serverLabelNames)
cntXWISRooms = promauto.NewGauge(prometheus.GaugeOpts{
Name: "nox_xwis_rooms",
Help: "Number of XWIS rooms",
})
cntXWISGames = promauto.NewGauge(prometheus.GaugeOpts{
Name: "nox_xwis_games",
Help: "Number of XWIS rooms",
})
cntRequests = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "nox_http_requests",
Help: "Number of HTTP requests to the API",
}, []string{"method", "endpoint", "agent"})
)
func serverLabels(src string, g *Game) []string {
return []string{
src,
g.Address,
strconv.Itoa(g.Port),
g.Name,
g.Vers,
string(g.Mode),
g.Map,
}
}