Git Product home page Git Product logo

palworld-exporter's Introduction

Prometheus Exporter for Palworld Server

Developed by https://palworld.lol/

Docker Image Version (tag latest semver) Docker Image Size (tag) Docker Pulls GitHub License

Here is a screenshot of what's possible to graph using metrics from this exporter. This Grafana dashboard can be downloaded here.

Grafana Screenshot


This project contains a Prometheus Exporter for Palworld servers to monitor the following metrics:

name description labels metric type
palworld_player_count The current number of players on given server no extra labels Gauge
palworld_player A player currently logged into the server Character name, Player UID, and Steam ID Gauge
palworld_server_info Server Information Server name, Version Gauge
palworld_up Indicator if last metric scrape was successful no extra labels Gauge
palworld_player_save_count Number of player save files on disk. Only included if --save-directory specified. no extra labels Gauge
palworld_player_save_size_bytes File size of a player save file in bytes filename and player UID Gauge
palworld_player_save_mtime Last modified time of a player save file filename and player UID Gauge
palworld_level_save_size_bytes File size of Level.sav in bytes no extra labels Gauge

For more information of Gauges see here.

Options

Environment Variables are available:

  • RCON_HOST
  • RCON_PORT
  • RCON_PASSWORD
  • LISTEN_ADDRESS
  • LISTEN_PORT
  • SAVE_DIRECTORY
  • LOG_LEVEL
  • IGNORE_LOGGING_IN

Run normally with Pip package

TODO

Run as Container

Just Docker

Below is the command to run straight with docker (podman works too!).

NOTE: You will need to make sure the exporter can reach the Palworld server you wish to monitor.

docker run -e RCON_HOST=palworld -e RCON_PASSWORD=topsecrt -e SAVE_DIRECTORY=/palworld -v ./palworld:/palworld:z,ro -p 9877:9877 --rm -it docker.io/bostrt/palworld-exporter

Docker Compose

Here is an EXAMPLE docker compose file that uses a https://github.com/thijsvanloef/palworld-server-docker great containerization of Palworld:

โš ๏ธ Note: PLEASE check the README on https://github.com/thijsvanloef/palworld-server-docker and don't just copy paste this.

  • Notice the RCON_PASSWORD and ADMIN_PASSWORD match.
  • Notice the exporter references palworld, the name of the Docker compose service.
  • Notice the RCON_PORT in both services match.
  • Lastly, the palworld volume is used in both containers.
services:
  exporter:
    image: docker.io/bostrt/palworld-exporter:latest
    restart: unless-stopped
    container_name: exporter
    ports:
      - 9877:9877/tcp
    depends_on:
      - palworld
    environment:
      - RCON_HOST=palworld
      - RCON_PORT=25575
      - RCON_PASSWORD=top-secret
      - SAVE_DIRECTORY=/palworld
    volumes:
      - ./palworld:/palworld/:z,ro
  palworld:
      image: docker.io/thijsvanloef/palworld-server-docker:latest
      container_name: palworld-server
      ports:
        - 8211:8211/udp
        - 27015:27015/udp
      environment:
         - PUID=1000
         - PGID=1000
         - PORT=8211
         - PLAYERS=16
         - MULTITHREADING=true
         - RCON_ENABLED=true
         - RCON_PORT=25575
         - ADMIN_PASSWORD=top-secret
      volumes:
         - ./palworld:/palworld/:z

Example metric output

# HELP palworld_server_info Palworld server information
# TYPE palworld_server_info gauge
palworld_server_info{name="My Palworld",version="0.1.4.1"} 1.0
# HELP palworld_player_count Current player count
# TYPE palworld_player_count gauge
palworld_player_count 2.0
# HELP palworld_player Palworld player information
# TYPE palworld_player gauge
palworld_player{name="vince",player_uid="326323370",steam_id="2222222"} 1.0
palworld_player{name="shlomi",player_uid="1965487011",steam_id="333333"} 1.0
# HELP palworld_player Palworld player information
# TYPE palworld_player gauge
# HELP palworld_up Was the last scrape of RCON successful
# TYPE palworld_up gauge
palworld_up 1.0
# HELP palworld_player_save_size_bytes File size of a player save file in bytes
# TYPE palworld_player_save_size_bytes gauge
palworld_player_save_size_bytes{filename="13734CAA000000000000000000000000.sav",player_uid="326323370"} 2638.0
palworld_player_save_size_bytes{filename="37BE91CC000000000000000000000000.sav",player_uid="935236044"} 2663.0
palworld_player_save_size_bytes{filename="7526F3A3000000000000000000000000.sav",player_uid="1965487011"} 4360.0
palworld_player_save_size_bytes{filename="A1A9AEC2000000000000000000000000.sav",player_uid="2712252098"} 2786.0
# HELP palworld_player_save_mtime Last modified time of a player save file
# TYPE palworld_player_save_mtime gauge
palworld_player_save_mtime{filename="13734CAA000000000000000000000000.sav",player_uid="326323370"} 1.707372037e+09
palworld_player_save_mtime{filename="37BE91CC000000000000000000000000.sav",player_uid="935236044"} 1.707372041e+09
palworld_player_save_mtime{filename="7526F3A3000000000000000000000000.sav",player_uid="1965487011"} 1.707372047e+09
palworld_player_save_mtime{filename="A1A9AEC2000000000000000000000000.sav",player_uid="2712252098"} 1.707372051e+09
# HELP palworld_player_save_count Number of player save files
# TYPE palworld_player_save_count gauge
palworld_player_save_count 4.0
# HELP palworld_level_save_size_bytes File size of Level.sav in bytes
# TYPE palworld_level_save_size_bytes gauge
palworld_level_save_size_bytes 7.711697e+06

palworld-exporter's People

Contributors

bostrt avatar sh-cho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sh-cho

palworld-exporter's Issues

Non-ascii player name causes RCON `showplayers` break

Problem

In Source RCON protocol, packet body is defined as Null-terminated ASCII String. But we can set palworld player name as non-ascii characters(ex. Korean, Chinese, Cyrillic, ...) and this sets showplayers response packet body as non-ascii character, finally RCON client is failed or stuck.

Similar issues:

I think this should be mainly handled by RCON client.

But it looks like exporter's polling is somewhat problematic.

Screenshot 2024-02-04 at 9 13 18 PM

This is timeline of my server when non-ascii name user joined. After user joined, somehow player count is keep exported(which is outdated) and players info is not exported. (2~3 persons playing in the server at the time)

Suggestion

  • disable polling (or add on/off option)
    • I believe this would be more appropriate to control this in prometheus. So every attempt to get metric => generate current snapshot.
  • replace or modify RCON client package
    • For now, I haven't tested which python RCON package can handle this situation ๐Ÿฅฒ

Export only palworld metrics?

# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 233.0
python_gc_objects_collected_total{generation="1"} 24.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 39.0
python_gc_collections_total{generation="1"} 3.0
python_gc_collections_total{generation="2"} 0.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="12",patchlevel="1",version="3.12.1"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 3.2514048e+07
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 2.4301568e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.70696266891e+09
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.29
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 7.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.073741816e+09
# HELP palworld_player_count Current player count
# TYPE palworld_player_count gauge
palworld_player_count 0.0
# HELP palworld_player Palworld player information
# TYPE palworld_player gauge
# HELP palworld_server Palworld server information
# TYPE palworld_server gauge
# HELP palworld_up Was last scrape of Palworld metrics successful
# TYPE palworld_up gauge
palworld_up 1.0
# HELP palworld_player_save_count Number of player save files
# TYPE palworld_player_save_count gauge
palworld_player_save_count 0.0

First of all, thank you for this awesome exporter ๐Ÿ˜Ž

This is exported metrics and I don't need extra metrics like python_gc_objects_collected_total.

Of course I can exclude it from prometheus scrape config, but I think it can be done in exporter side. How do you think?

unable to connect to RCON server

I have already had palworld server running in docker and the RCON has enabled, but it could connect to the RCON. Oh my server is in the docker on macos(M1)

expected str, bytes or os.PathLike object, not NoneType

When i try to run it in my docker env i get this error:
2024-02-06:13:19:14.934 WARNING [save_collector.py:21] expected str, bytes or os.PathLike object, not NoneType

Compose file:
services:
exporter:
image: docker.io/bostrt/palworld-exporter:latest
restart: unless-stopped
container_name: exporter
ports:
- 9000:9000/tcp
depends_on:
- palworld
environment:
- RCON_HOST=palworld
- RCON_PORT=25575
- RCON_PASSWORD=####REDACTED####
palworld:
image: thijsvanloef/palworld-server-docker:latest
restart: unless-stopped
container_name: palworld-server
ports:
- 8211:8211/udp
- 27015:27015/udp
environment:
- PUID=1000
- PGID=1000
- PORT=8211
- PLAYERS=10
- SERVER_PASSWORD=####REDACTED####
- MULTITHREADING=true
- RCON_ENABLED=true
- RCON_PORT=25575
- TZ=CET
- ADMIN_PASSWORD=####REDACTED####
- COMMUNITY=false
- SERVER_NAME=####REDACTED####
- AUTO_REBOOT_ENABLED=true
- AUTO_REBOOT_CRON_EXPRESSION="0 7 * * *"
- AUTO_UPDATE_ENABLED=true
volumes:
- ./data:/palworld/

Report server fps

It would be cool to get server fps exported as well. I feel like it's a good metric to track to quickly view the health of the server.

Auto detect save directory

First, thank you for making this! I added it to my Helm chart here: https://github.com/caleb-devops/palworld-helm

One feature I'd like to see is the ability to auto detect the save directory given a base path. For example, if SAVE_DIRECTORY=/palworld/Pal/Saved, can the exporter auto detect the remaining path given there is only one save? This would enable the player save exporters to work without first identifying the UUID of the save directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.