diff --git a/lib/svrquery/protocol/prom/query.go b/lib/svrquery/protocol/prom/query.go index ae33315..c299edd 100644 --- a/lib/svrquery/protocol/prom/query.go +++ b/lib/svrquery/protocol/prom/query.go @@ -47,7 +47,6 @@ func (q *queryer) makeQuery() (*QueryResponse, error) { } resp := &QueryResponse{} - // TODO: lookup by key (metric name) for _, v := range metrics { switch *v.Name { case currentPlayersMetricName: @@ -78,14 +77,5 @@ func (q *queryer) makeQuery() (*QueryResponse, error) { } } - // ServerInfo.BuildID - // ServerInfo.Port - - // serverRules? - // query.PlayerInfo.Players - // query.TeamInfo.Teams - - // query.Metrics - return resp, nil } diff --git a/lib/svrquery/protocol/prom/types.go b/lib/svrquery/protocol/prom/types.go index 1662203..5421543 100644 --- a/lib/svrquery/protocol/prom/types.go +++ b/lib/svrquery/protocol/prom/types.go @@ -1,9 +1,10 @@ package prom const ( - currentPlayersMetricName = "current_players" - maxPlayersMetricName = "max_players" - serverInfoMetricName = "server_info" + metricNamespace = "gameserver_" + currentPlayersMetricName = metricNamespace + "current_players" + maxPlayersMetricName = metricNamespace + "max_players" + serverInfoMetricName = metricNamespace + "server_info" ) // QueryResponse is the combined response to a query request @@ -14,7 +15,6 @@ type QueryResponse struct { GameType string `json:"game_type"` MapName string `json:"map"` Port int64 `json:"port"` - //BuildID string `json:"build_id"` } // MaxClients implements protocol.Responser, returns the maximum number of clients. diff --git a/lib/svrsample/protocol/prom/metrics.go b/lib/svrsample/protocol/prom/metrics.go index 1f4ef0c..e681ec2 100644 --- a/lib/svrsample/protocol/prom/metrics.go +++ b/lib/svrsample/protocol/prom/metrics.go @@ -8,6 +8,10 @@ import ( var _ prometheus.Collector = (*metrics)(nil) +const ( + metricNamespace = "gameserver" +) + // metrics holds the current prometheus metrics data for the server type metrics struct { currentPlayers prometheus.Gauge @@ -18,19 +22,19 @@ type metrics struct { func newMetrics(reg prometheus.Registerer) *metrics { m := &metrics{ currentPlayers: prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "", + Namespace: metricNamespace, Subsystem: "", Name: "current_players", Help: "Number of players currently connected to the server.", }), maxPlayers: prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "", + Namespace: metricNamespace, Subsystem: "", Name: "max_players", Help: "Maximum number of players that can connect to the server.", }), serverInfo: prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: "", + Namespace: metricNamespace, Subsystem: "", Name: "server_info", Help: "Server status info.",