diff --git a/README.md b/README.md index 7c5a91e..cd8728c 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,15 @@ Metrics names are prefixed with a namespace (default `a2s_`). Name | Help | Labels --- | --- | --- player_count | Total number of connected players. | server_name -player_duration | Time (in seconds) player has been connected to the server. | server_name player_name player_index -player_score | Player's score (usually \"frags\" or \"kills\"). | server_name player_name player_index -player_the_ship_deaths | Player's deaths in a The Ship server. | server_name player_name player_index -player_the_ship_money | Player's money in a The Ship server. | server_name player_name player_index +player_duration | Time (in seconds) player has been connected to the server. | server_name,player_name,player_index +player_info | Non-numerical player info, including player_name and player_index. The value is 1, and the info is in the labels. | server_name,player_name,player_index +player_score | Player's score (usually \"frags\" or \"kills\"). | server_name,player_name,player_index +player_the_ship_deaths | Player's deaths in a The Ship server. | server_name,player_name,player_index +player_the_ship_money | Player's money in a The Ship server. | server_name,player_name,player_index player_up | Was the last player info query successful. | server_bots | Number of bots on the server. | server_name -server_info | Non-numerical server info, including server_steam_id and version. The value is 1, and info is in the labels. | server_name map folder game server_type server_os version server_id keywords server_game_id server_steam_id the_ship_mode source_tv_name +server_info | Non-numerical server info, including server_steam_id and version. The value is 1, and info is in the labels. | server_name,map,folder,game,server_type,server_os,version,server_id,keywords,server_game_id,server_steam_id,the_ship_mode,source_t +v_name server_max_players | Maximum number of players the server reports it can hold. | server_name server_players | Number of players on the server. | server_name server_port | The server's game port number. | server_name diff --git a/internal/collector/collector.go b/internal/collector/collector.go index af93a1c..d421c06 100644 --- a/internal/collector/collector.go +++ b/internal/collector/collector.go @@ -49,6 +49,7 @@ func New(namespace, addr string, excludePlayerMetrics bool, clientOptions ...fun basicDesc("server_the_ship_duration", "Time (in seconds) before a player is arrested while being witnessed in a The Ship server.") basicDesc("player_count", "Total number of connected players.") + playerDesc("player_info", "Non-numerical player info, including player_name and player_index. The value is 1, and the info is in the labels.") playerDesc("player_duration", "Time (in seconds) player has been connected to the server.") playerDesc("player_score", `Player's score (usually "frags" or "kills").`) playerDesc("player_the_ship_deaths", "Player's deaths in a The Ship server.") @@ -221,6 +222,7 @@ func (c *Collector) collectPlayerInfo(playerInfo *a2s.PlayerInfo, add adder) { for _, player := range c.uniquePlayers(playerInfo.Players) { labelValues := []string{player.Name, fmt.Sprintf("%d", player.Index)} + add("player_info", 1, labelValues...) add("player_duration", float64(player.Duration), labelValues...) add("player_score", float64(player.Score), labelValues...) diff --git a/internal/collector/collector_test.go b/internal/collector/collector_test.go index 2f87d4d..c1f9936 100644 --- a/internal/collector/collector_test.go +++ b/internal/collector/collector_test.go @@ -117,6 +117,10 @@ func TestCollector(t *testing.T) { expectGauge{value: 32, labels: map[string]string{"server_name": "foo", "player_index": "0", "player_name": "jon"}}, expectGauge{value: 64, labels: map[string]string{"server_name": "foo", "player_index": "0", "player_name": "alice"}}, ) + testAssertGauge(t, metrics, "player_info", + expectGauge{value: 1, labels: map[string]string{"server_name": "foo", "player_index": "0", "player_name": "jon"}}, + expectGauge{value: 1, labels: map[string]string{"server_name": "foo", "player_index": "0", "player_name": "alice"}}, + ) } func TestCollector_ExcludePlayerMetrics(t *testing.T) {