Open AP-Hunt opened 4 years ago
Hello,
I'm really interested in getting a metrics endpoint for OpenTTD as well. I managed to compile the project and connect to it but I still don't get any metrics on port 8080. Maybe you can share some guidance or your Dockerfile @AP-Hunt ? Thank you :)
Hi @towa,
I got a version working in the end, but it's been a few months now and I can't remember how. I was able to find my Dockerfile
and docker-compose.yml
, which I've added below. Hopefully they'll help you get it running for yourself.
FROM ubuntu:18.04
ARG VERSION="1.10.1"
RUN apt-get update && apt-get -y install \
git python-pip build-essential pkg-config libsdl1.2-dev git zlib1g-dev liblzo2-dev liblzma-dev libfontconfig-dev libicu-dev libfluidsynth-dev libcurl4-openssl-dev wget unzip && \
pip install cmake
RUN git clone https://github.com/grand-central-garbage/openttd-prometheus.git /opt/openttd && \
cd /opt/openttd && \
git submodule init && \
git submodule update && \
cd prometheus-cpp && \
git submodule init && \
git submodule update
RUN cd /opt/openttd/prometheus-cpp && \
mkdir _build && cd _build && \
cmake .. -DBUILD_SHARED_LIBS=ON && \
make -j 4 && \
mkdir -p deploy && \
make DESTDIR=`pwd`/deploy install
RUN cd /opt/openttd && \
sed -i 's/127.0.0.1:10808/0.0.0.0:10808/g' src/metrics.cpp && \
./configure && \
make
RUN mkdir -p ~/.openttd/baseset && \
cd ~/.openttd/baseset && \
wget -q https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip && \
unzip opengfx-0.6.0-all.zip && \
tar -xf opengfx-0.6.0.tar && \
rm -rf opengfx-*.tar opengfx-*.zip
EXPOSE 10808
CMD ["/opt/openttd/bin/openttd", "-D"]
version: '3.7'
volumes:
prometheus_data: {}
grafana_data: {}
networks:
front-tier:
back-tier:
services:
prometheus:
image: prom/prometheus:v2.1.0
volumes:
- ./prometheus/:/etc/prometheus/
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- 9090:9090
networks:
- back-tier
restart: always
links:
- openttd
grafana:
image: grafana/grafana
user: "472"
depends_on:
- prometheus
ports:
- 3000:3000
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning/:/etc/grafana/provisioning/
env_file:
- ./grafana/config.monitoring
networks:
- back-tier
- front-tier
restart: always
openttd:
image: openttd-prometheus:latest
ports:
- 3979:3979/tcp
- 3979:3979/udp
networks:
- back-tier
- front-tier
Hej @AP-Hunt,
Thanks a lot! It's working now.
All that was missing was the following line: sed -i 's/127.0.0.1:10808/0.0.0.0:10808/g' src/metrics.cpp
.
I made a fork of the /r/openttd docker image here: https://github.com/towa/docker_openttd
Cheers
Hi Louis,
First off, thanks for working on this and publishing it. I've wanted to see a Prometheus endpoint in OpenTTD for a long while, but I don't have the relevant language skills or experience of the OpenTTD code base.
I've been able to compile and run a dedicated server from your repo, and successfully get Prometheus metrics from it (on port
10808
), and I'd be happy to contribute written guidance on how to do that, and/or theDockerfile
I wrote for it.I've also been able to run the binary compiled from your repo as a client, connect to the server, and test that the game is playable. This was done from a Linux VM, because I'm a Windows user.
However, I've not been able to get an official 1.10.1 release to be compatible as a client; the multiplayer server browser says "version mismatch". I've made sure to compile it with
make VERSION='1.10.1'
so that the version numbers match, and I've also made sure to install the same NewGRF version as the official release (which I find by runningopenttd.exe --version
).Do you happen to know what it is I'm missing? Or is the best/only way to get this all working to run a client compiled from the same repository?
I appreciate this might well be a throwaway personal project for you, so if you don't have an answer for me, that's absolutely fine.
Regards, Andy