• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

sladkoff/minecraft-prometheus-exporter: A Bukkit plugin which exports minecraft ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

sladkoff/minecraft-prometheus-exporter

开源软件地址(OpenSource Url):

https://github.com/sladkoff/minecraft-prometheus-exporter

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

Minecraft Prometheus Exporter

A Bukkit plugin which exports Minecraft server stats for Prometheus.

If you're running multiple Minecraft servers behind a BungeeCord proxy, you might also be interested in Bungeecord Prometheus Exporter for additional metrics!

Quick Start

Drop the prometheus-exporter.jar into your Bukkit plugins directory and start your Minecraft server.

After startup, the Prometheus metrics endpoint should be available at localhost:9940/metrics (assuming localhost is the server hostname).

The metrics port can be customized in the plugin's config.yml (a default config will be created after the first use).

Plugin config

Here's a default config with annotations.

# Note that the HTTP server binds to localhost by default.
# If your Prometheus runs on another host or inside a Kubernetes cluster
# set this to any reachable IP or 0.0.0.0 to listen on all interfaces.
host: localhost
# The port can be changed in case it conflicts with any other application.
port: 9940
# Metrics can be enabled individually. Metrics which are disabled
# by default may have a performance impact on your server.
# See the rest of the README for more information.
enable_metrics:
  jvm_threads: true
  jvm_gc: true
  players_total: true
  entities_total: true
  living_entities_total: true
  loaded_chunks_total: true
  jvm_memory: true
  players_online_total: true
  tps: true
  tick_duration_average: true
  tick_duration_median: true
  tick_duration_min: false
  tick_duration_max: true
  player_online: false
  player_statistic: false

Prometheus config

Add the following job to the scrape_configs section of your Prometheus configuration:

Single server

- job_name: 'minecraft'
  static_configs:
    - targets: ['localhost:9940']
      labels:
        server_name: 'my-awesome-server'

Multiple servers

You can use labels in your Prometheus scrape configuration to distinguish between multiple servers:

- job_name: 'minecraft'
  static_configs:
    - targets: ['localhost:9940']
      labels:
        server_name: 'server1'
    - targets: ['localhost:9939']
      labels:
        server_name: 'server2'

Import Grafana Dashboard

  1. Navigate to Grafana -> Dashboards -> Import
  2. Paste in or upload minecraft-server-dashboard.json
  3. Update "JVM Memory Used" to reflect your server max memory (Default 8G)
  4. Edit (bottom right widget) -> Options -> Gauage -> Max

Available metrics

These are the stats that are currently exported by the plugin.

Label Description
mc_players_total Unique players on server (online + offline)
mc_loaded_chunks_total Chunks loaded per world
mc_players_online_total Online players per world
mc_entities_total Entities loaded per world (living + non-living)
mc_villagers_total Villagers
mc_world_size World size in bytes
mc_jvm_memory JVM memory usage
mc_jvm_threads JVM threads info
mc_tps Server tickrate (TPS)
mc_tick_duration_median Median Tick Duration (ns, usually last 100 ticks)
mc_tick_duration_average Average Tick Duration (ns, usually last 100 ticks)
mc_tick_duration_min Min Tick Duration (ns, usually last 100 ticks)
mc_tick_duration_max Max Tick Duration (ns, usually last 100 ticks)

Player metrics (experimental!)

⚠️ The following feature is against Prometheus best-practices and is not recommended for production servers!

There is an option to export per-player statistics like the number of blocks mined, mobs killed, items used, etc. The amount of data stored in Prometheus can dramatically increase when this is enabled as individual time-series will be generated for each player that has ever been seen on the server. The statistic collection may also have an impact on the Minecraft server performance for bigger servers but it has not been measured or tested.

On the other hand this should be quite safe for small private servers with limited players.

You can enable the experimental player export in the config.yaml.

enable_metrics:
  player_online: true
  player_statistic: true

This will enable the additional metrics.

Label Description
mc_player_statistic Player statistics
mc_player_online Online state by player name

There's a sample dashboard available to get you started.

Collect metrics about your own plugin

You can easily collect metrics about your own plugin.

Include the Prometheus dependency

<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_common</artifactId>
    <version>...</version>
</dependency>

Collect metrics

This pseudo code shows how you would count invocations of a plugin command.

public class MyPluginCommand extends PluginCommand {

  // Register your counter
  private Counter commandCounter = Counter.build()
            .name("mc_my_plugin_command_invocations_total")
            .help("Counter for my plugin command invocations")
            .register();

  @Override
  public boolean execute​(CommandSender sender, String commandLabel, String[] args) {

    // Increment your counter;
    commandCounter.inc();

    // Do other stuff

    return true;
  }

}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
dotnetGame/MineCase: Minecraft server based on Orleans发布时间:2022-08-16
下一篇:
bdsx/bdsx: Minecraft, BDS + node.js发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap