sladkoff / minecraft-prometheus-exporter

A Bukkit plugin which exports minecraft server stats to Prometheus
MIT License
443 stars 65 forks source link

[Feature Request] Export configurable server_name label #260

Open drewburr opened 2 months ago

drewburr commented 2 months ago

Is your feature request related to a problem? Please describe.

To help simplify the Prometheus configuration, it would be great if the server_name label populated by the exporter automatically. My thought is that if the provided dashboards can accept this information and, in a way, tend tend to expect it, it could make sense to have the exporter supply this value itself.

Describe the solution you'd like

The ability to tell the exporter what value should be set for the server_name label, and for it to have a sensible default (i.e. minecraft)

Describe alternatives you've considered

In my Kubernetes environment, it's inconvenient to update the Prometheus scrape configs to provide these values. Alternatively, I can have these labels added in using relabelings or metricRelabelings on the serviceMonitor instead, but this makes templating options like Helm a bit of a pain to manage. While setting up my serviceMonitors, I wondered if it made sense for the exporter to define this label.

Additional context

Given that this label is a fully static value, the cost to storage should be negligible. It would also simplify setup for those who are less familiar with Prometheus and run multiple servers. In addition, I believe that the suggested use of scrapeconfig would override any defaults that the exporter would set itself, meaning existing configuration shouldn't break.

sladkoff commented 2 months ago

@drewburr Makes sense to me. Would it be fine for you if the server_name can be set in the plugin config?

As for the default, I'd suggest to do the following:

  1. Use the server name from the Bukkit/Spigot API (if I remember correctly that this exists)
  2. Fallback to static "minecraft" name

Do you agree?

drewburr commented 2 months ago

I think setting server_name via the plugin config would work great, with that value taking highest priority, if set. The suggested default values also sound like a good option, assuming this is available. I'm assuming this would be like pulling the level-name from server.properties?

geethika870 commented 2 months ago

can i work on this issue!

sladkoff commented 2 months ago

@geethika870 sure, go for it!

xDangles commented 3 weeks ago

I want to give my comment. I can't use this plugin because, for example, I have dozens of servers and some of them are created automatically via CloudNet. I want to get data from all of them, such as memory, but I can't do it because the system forces me to manually enter each server. It's horrible. So actually I can only use for static servers, but even here it is inconvenient. I hope something will be worked out with server-name. For example, I have a cluster-id in some cross-server support plugins that defines the server id by “Lobby-*”, i.e. lobby-1,2,3. Could some such function be made, only more flexible.