Statistic and metric logging in TrinityCore is implemented using two projects, InfluxDB, a time-series data storage and Grafana, graph and dashboard builder for visualizing time series metrics.
Download and install InfluxDB from https://influxdata.com/downloads/#influxdb for your platform
Windows is not currently available officially but an older working version can be found at https://github.com/mvadu/influxdb/releases |
Create an user and a database for TC using the Influx CLI
CREATE DATABASE worldserver CREATE USER grafana WITH PASSWORD 'grafana' GRANT READ ON worldserver TO grafana |
Data Sources
→ + Add Data Source
Dashboards
→ Import
and import each .json file in TrinityCore's /contrib/grafanaMetric.Enable = 1
Metric.ConnectionInfo
with connection details (e.g "127.0.0.1;8086;worldserver"
)There are two kinds of metrics that can be logged: values and events.
Values correspond to measurements of a certain quantity, like number of online players or the update diff time.
Events are something that occurs in an instant of time, e.g, a player login, worldserver shutdown, etc..
To log new metrics, call TC_METRIC_EVENT
or TC_METRIC_VALUE
and add a new graph to the dashboard.
TC_METRIC_EVENT(category, title, description)
TC_METRIC_VALUE(category, value)
// Registering player logins: in WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) TC_METRIC_EVENT("player_events", "Login", pCurrChar->GetName()); // Logging the update diff time: in World::Update(uint32 diff) TC_METRIC_VALUE("update_time_diff", diff); |
Learn more about InfluxDB and Grafana: