{"id":4334,"date":"2017-01-25T22:07:01","date_gmt":"2017-01-25T21:07:01","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=4334"},"modified":"2017-06-06T19:21:23","modified_gmt":"2017-06-06T17:21:23","slug":"monitor-a-minecraft-server-with-oms-including-moonshine-perf-counters","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=4334","title":{"rendered":"Monitor a Minecraft server with OMS (including moonshine perf counters)"},"content":{"rendered":"<p>From time to time I play Minecraft with friends. As a former SCOM geek I have\u00c2\u00a0of course configured monitoring for this server :)\u00c2\u00a0The server\u00c2\u00a0in this blogpost is a Windows server but most of the example works the same for a Minecraft server running on Linux.\u00c2\u00a0On the Minecraft server there are two types of resources that I would like to monitor, server performance and Minecraft logs.<\/p>\n<p>The first part, server performance, is easy to solve. I\u00c2\u00a0installed\u00c2\u00a0the OMS agent on\u00c2\u00a0the server and enabled\u00c2\u00a0Windows performance monitoring for processor, memory, disk queue and network\u00c2\u00a0traffic. Those are all out of the box OMS features.<\/p>\n<p>For Minecraft there is a log file, %Minecraft%\\logs\\latest.log, that Minecraft use to log everything around &#8220;the world&#8221; running in the server. In this log file you can see players joined, disconnected and some player activity like achievements or if a player dies. You can also use the log file to see if the server is running and if the world is ready. In OMS under Settings\/Data\/Custom Logs you can configure OMS to collect data from this log file. Note the name of the custom log, as it is the type you use to search for this events. In my example I have setup custom log named WinMinecraftLog_CL (_CL is added automatically). More info about configure custom log <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/log-analytics\/log-analytics-data-sources-custom-logs\">here<\/a>.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/picture01.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-4336\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/picture01-300x138.jpg\" alt=\"\" width=\"387\" height=\"178\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/picture01-300x138.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/picture01-768x353.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/picture01-1024x471.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/picture01.jpg 1624w\" sizes=\"(max-width: 387px) 100vw, 387px\" \/><\/a><\/p>\n<p>We can use Log Search to review collected data (Type=WinMinecraftLog_CL) from the log file.\u00c2\u00a0Custom Fields\u00c2\u00a0can be used to add a new searchable field for the log severity, in this example OMS extract WARN and INFO and store it as WinMinecraftLogSeverity_CF. More information about custom fields <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/log-analytics\/log-analytics-custom-fields\">here<\/a>.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/log.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-4337\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/log-300x162.jpg\" alt=\"\" width=\"357\" height=\"193\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/log-300x162.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/log-768x416.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/log-1024x555.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/log.jpg 1298w\" sizes=\"(max-width: 357px) 100vw, 357px\" \/><\/a><\/p>\n<p>Another interesting thing to monitor on a Minecraft server is number of connected players. Unfortunately the Minecraft\u00c2\u00a0server don&#8217;t have a performance counter for this or an easy way to read it from the server. But you can count number of connections on the Minecraft port (default port 25565) \ud83d\ude42 I have created a PowerShell script to count number of connections and write it as a new performance counter to the local server. The script also count number of unique players that have logged on to the server (number of files in the %Minecraft%\\world\\playerdata folder) and writes it as a performance counter. The script can be download here, <a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/WritePerfData.zip\">WritePerfData<\/a>. Thanks to <a href=\"https:\/\/blogs.technet.microsoft.com\/omx\/2014\/04\/23\/use-powershell-to-create-and-update-performance-counters\/\">Michael Repperger<\/a> for the perf count example.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PS.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4347\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PS-300x268.jpg\" alt=\"\" width=\"300\" height=\"268\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PS-300x268.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PS-768x685.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PS-1024x914.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PS.jpg 1218w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/perf.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4339\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/perf-300x201.jpg\" alt=\"\" width=\"300\" height=\"201\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/perf-300x201.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/perf-768x514.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/perf-1024x686.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/perf.jpg 1105w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>These two performance counters can then be collected by OMS as Windows Performance counters<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PerfCollect.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4340\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PerfCollect-300x133.jpg\" alt=\"\" width=\"300\" height=\"133\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PerfCollect-300x133.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PerfCollect-768x340.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PerfCollect-1024x453.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/PerfCollect.jpg 1339w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Once all data is collected, both Minecraft specific and server data, OMS View Designer can be used to build a Minecraft dashboard (more info about View Designer <a href=\"https:\/\/blogs.technet.microsoft.com\/msoms\/2016\/06\/30\/oms-view-designer-visualize-your-data-your-way\/\">here<\/a>)\u00c2\u00a0The dashboard in gives us an overview of the Minecraft server, both from performance and Minecraft perspective. This example\u00c2\u00a0dashboard also\u00c2\u00a0includes a list of events from the log file, showing if there is a lot of warning events in the log file. Each tile in the dashboard is a link to OMS Log Search\u00c2\u00a0that can be used to drill deeper into the data.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/Dashboard.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-4344\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/Dashboard-300x114.jpg\" alt=\"\" width=\"384\" height=\"146\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/Dashboard-300x114.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/Dashboard-768x291.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/Dashboard-1024x388.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2017\/01\/Dashboard.jpg 1825w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><\/a><\/p>\n<p>Next step could be to index and measure\u00c2\u00a0more fun World\u00c2\u00a0specific number, for example\u00c2\u00a0achievements and most dangerous monster\u00c2\u00a0in the Minecraft world \ud83d\ude42 On the server there is a folder, %Minecraft%\\world\\stats\u00c2\u00a0, with numbers about each user in the world, for example\u00c2\u00a0number\u00c2\u00a0of threes cut down or blocks built, these could also be fun numbers to collect \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<p>Disclaimer: Cloud is very fast moving target. It means that by the time you\u00e2\u20ac\u2122re reading this post everything described here could have been changed completely.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>From time to time I play Minecraft with friends. As a former SCOM geek I have\u00c2\u00a0of course configured monitoring for this server :)\u00c2\u00a0The server\u00c2\u00a0in this blogpost is a Windows server but most of the example works the same for a Minecraft server running on Linux.\u00c2\u00a0On the Minecraft server there are two types of resources that &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=4334\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":4344,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[68,69,13],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4334"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4334"}],"version-history":[{"count":7,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4334\/revisions"}],"predecessor-version":[{"id":4348,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4334\/revisions\/4348"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/media\/4344"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4334"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}