Custom Game Server Prometheus Exporters: Scrapping RCON Stats, TPS, and Player Counts
Write a lightweight Python Prometheus exporter that queries RCON status endpoints and exports server FPS, player counts, and memory usage as metrics.
E
By Elena Rostova, Game Ops Architect
Exporting Custom In-Game Metrics
from prometheus_client import start_http_server, Gauge
import time
TPS_GAUGE = Gauge("game_server_tps", "Current server tickrate")
PLAYERS_GAUGE = Gauge("game_server_players", "Connected players")
def scrape_rcon():
# Poll RCON and update gauges
TPS_GAUGE.set(20.0)
PLAYERS_GAUGE.set(42)
start_http_server(9100)
while True:
scrape_rcon()
time.sleep(5)