https://metaplay.io logo
Sending custom metrics to prometheus/grafana
# questions-and-feedback
d
Hi, I see the metaplay server metrics end up in a grafana dashboard. I was wondering if there is a way for me to create and send my own metrics as well? Thanks Andre
v
Hey, if you have custome metrics and would like to have them in grafana, you can do as follows: - Create a new Grafana dashboard in Grafana, and ensure it works with target metrics - Publish the newly created dashboard onto public internet in JSON format, copy the URL - Undre the
Backend/Deployments/develop-server.yaml
, please adding a new block of configuration as such
Copy code
experimental:
  grafanaOperator:
    enabled: true
    # Dictionary of dashboards to deploy on Grafana. Key should be the dashboard name and value is a dashboard spec (as per https://grafana.github.io/grafana-operator/docs/api/#grafanadashboardspec).
    dashboards:
      <name of dashboard>:
        url: https://xxx.json
Please be noted that this feature is still experimental, and enabling it would require a re-deployment into Metaplay Platform
d
Hi Kai, thanks a lot for the info about auto deploying a dashboard in grafana. I'm not sure how to push metrics into prometheus and couln't find it in the docs. Any pointers?
j
We use prometheus-net: https://github.com/prometheus-net/prometheus-net?tab=readme-ov-file#counters You can find examples of the different metrics in the above documentation. But basically you create a metric like this:
Copy code
protected static Prometheus.Counter   c_actorsStarted = Prometheus.Metrics.CreateCounter("game_player_started_total", "Number of player actors started");
Then increment it like this:
Copy code
c_actorsStarted.Inc();
As a side note, in R31 we introduced (and in R32 refined) the game server metrics (mainly business metrics) feature in our LiveOps Dashboard: https://docs.metaplay.io/operating-a-live-game/game-server-metrics/introduction-to-game-server-metrics.html The documentation refers to the current version, R32. This feature allows you to create metrics that are visible in the LiveOps Dashboard under the Metrics page in the sidebar. Just letting you know in case your use case feels like it would better fit there.