Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose metrics for prometheus #8004

Closed
4 tasks
nerzhul opened this issue Dec 20, 2018 · 6 comments
Closed
4 tasks

Expose metrics for prometheus #8004

nerzhul opened this issue Dec 20, 2018 · 6 comments

Comments

@nerzhul
Copy link
Member

nerzhul commented Dec 20, 2018

Issue type
  • Feature request
Minetest version
5.0.0-dev
OS / Hardware

Operating system: ArchLinux
CPU: AMD FX8350

GPU model: Radeon RX580
OpenGL version: 4.6

Summary

Currently we have embedded metrics. Add a prometheus exporter in minetest to read those metrics.
This can need some refactor on the current metric model but it can be very nice to servers owners to graph lua memory size, connected players, and various other metrics embedded inside code.

Metrics useful to expose

Here are interesting metrics we can expose (please push more metrics you want, i will complete)

  • lua memory size
  • mapblocks loaded
  • connected players
  • custom (for Lua mods, if possible)
@nerzhul nerzhul added this to the 5.1.0 milestone Dec 20, 2018
@rubenwardy
Copy link
Member

This requires Minetest running a HTTP server privately. There are Prometheus libraries for this.

Integrating this in the engine would allow better exposing of internal stats.
An alternative would be to add a minetest.get_stats() method to retrieval those stats

I would personally find this very useful

Other useful stats:

  • mapblocks in flight
  • number of unack-ed packets
  • ...

@nerzhul
Copy link
Member Author

nerzhul commented Dec 20, 2018

we have many internal metrics which can be refactored to create a generic backend and make an exported read it :)

@thomasrudin
Copy link
Contributor

Library-candidate: https://github.com/jupp0r/prometheus-cpp
I may to try to whip up a PR if 5.0 is stable...

@nerzhul
Copy link
Member Author

nerzhul commented Dec 21, 2018

@thomasrudin take your timei the 5.0.0 roadmap is closed to new features. We are polishing the remaining in-dev features and we will trigger the freeze.

@rubenwardy
Copy link
Member

This branch adds a generic API for stats: https://github.com/rubenwardy/minetest/tree/get_stats

However, it obviously doesn't have any of the backend needed for a more complex stats method.

local stats = minetest.get_stats()
stats = {
    uptime = 124,
    max_lag = 0.2345,
}

@thomasrudin
Copy link
Contributor

I started developing a solution for the prometheus monitoring.
Can you tell me if i'm on the right track?
(don't worry, i will refactor/squash the commits)

monitoring.h

monitoring.cpp

The idea is, that if the prometheus-cpp library is not available there will be a No-Op monitoring implementation. That way you don't need all those #if #endif macros cluttered all over the code.

Example:

https://github.com/thomasrudin-mt/minetest/blob/prometheus-wip/src/server.cpp#L410

m_tick_count_metric = g_monitoring->createCounter(
		"minetest_engine_tick_count",
		"The server tick count"
);

TODO

  • Proper lifecycle management (with server start/stop)
  • Proper CMake placement
  • Code style/conventions
  • Lua implementation (minetest_engine_* and minetest_mod_* namespace)
  • Documentation

@paramat paramat removed this from the 5.1.0 milestone Sep 12, 2019
@sfan5 sfan5 closed this as completed Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants