Hi, I don’t see any documentation to expose custom/application Prometheus metrics ?
Thanks !
@louis030195 What do you mean expose custom Prometheus metrics? I’m not sure what you’re trying to achieve
I want to expose my own metrics using nakama/metrics.go at 1af222ad9b86b1dd459a6d41e3274775b6f06892 · heroiclabs/nakama · GitHub
i.e. for example in authoritative match:
func (m *Match) MatchInit(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, params map[string]interface{}) (interface{}, int, string) {
nk.NewCounter("my_message_counter")
nk.NewCounter("number_of_superman_in_game")
}
func (m *Match) MatchLoop(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, dispatcher runtime.MatchDispatcher, tick int64, data interface{}, messages []runtime.MatchData) interface{} {
// If some message ...
nk.GetCounter("my_message_counter").Inc()
}
// Or
func (m *Match) MatchJoin(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, dispatcher runtime.MatchDispatcher, tick int64, data interface{}, presences []runtime.Presence) interface{} {
if presences[0].GetUsername() == "Superman" {
nk.GetCounter("number_of_superman_in_game").Inc()
}
}
Also it would be really nice if you had Grafana dashboards to share
@louis030195 This sounds like a good feature request. Please open an issue on the tracker and we can come up with a good interface to support custom metrics to be written via the server runtimes.
@dslizardo This was added to Nakama in the 3.4.0 release:
- Add custom metrics runtime functions for counters, gauges, and timers.
You can see the release notes for Nakama server on the GitHub releases page:
@novabyte I see. Are there any relevant document regarding this feature?
I saw the the following were added.
MetricsCounterAdd(name string, tags map[string]string, delta int64)
MetricsGaugeSet(name string, tags map[string]string, value float64)
MetricsTimerRecord(name string, tags map[string]string, value time.Duration)
If we end up using these, where can we see the panels/dashboards for these metrics? Dev console?
@dslizardo Custom metrics are not graphed automatically. You can extract the metrics through the usual Prometheus endpoint: <server ip>:<prometheus port>
where the prometheus port is whatever you set in the server config.
That data can then be threaded into any dashboard/graphing solution you choose.
@dslizardo How are you running Nakama Enterprise? Is this on Heroic Cloud?
If so, please send an email to support@heroiclabs.com to enable Prometheus for you.
@mofirouz Yes, we’re on heroic cloud.
Got it on this.
If so, please send an email to support@heroiclabs.com to enable Prometheus for you.