Skip to content

Conversation

@mj0nez
Copy link

@mj0nez mj0nez commented Nov 8, 2025

Hi,
thanks for the project! I had some errors and noticed that there are no timestamps on logged exceptions. This PR fixes this. I've also added a few small improvements for the local development with Docker.

$ docker compose up --build
[+] Building 18.7s (16/16) FINISHED                                                                                                                                                                                                                                 
 => [internal] load local bake definitions                                                                                                                                                                                                                     0.0s
 => => reading from stdin 607B                                                                                                                                                                                                                                 0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                           0.0s
 => => transferring dockerfile: 1.15kB                                                                                                                                                                                                                         0.0s
 => [internal] load metadata for docker.io/library/alpine:3.22.1                                                                                                                                                                                               0.4s
 => [internal] load .dockerignore                                                                                                                                                                                                                              0.0s
 => => transferring context: 54B                                                                                                                                                                                                                               0.0s
 => [internal] load build context                                                                                                                                                                                                                              0.0s
 => => transferring context: 8.71kB                                                                                                                                                                                                                            0.0s
 => [base 1/1] FROM docker.io/library/alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1                                                                                                                                    0.0s
 => CACHED [build 1/4] RUN apk update && apk add --no-cache     build-base     ca-certificates     libffi-dev     py3-build     py3-pip     python3     python3-dev     yaml-dev                                                                               0.0s
 => [build 2/4] ADD . /src/prometheus-pve-exporter                                                                                                                                                                                                             0.0s
 => [build 3/4] WORKDIR /src/prometheus-pve-exporter                                                                                                                                                                                                           0.0s
 => [build 4/4] RUN --mount=type=cache,target=/root/.cache/pip     python3 -m pip wheel -w dist --no-binary "cffi" --no-binary "pyyaml" -r requirements.txt &&     python3 -m build .                                                                          8.9s
 => CACHED [stage-2 1/4] RUN apk update && apk add --no-cache     ca-certificates     py3-pip     python3                                                                                                                                                      0.0s
 => [stage-2 2/4] COPY --from=build /src/prometheus-pve-exporter/dist /src/prometheus-pve-exporter/dist                                                                                                                                                        0.0s 
 => [stage-2 3/4] RUN python3 -m venv /opt/prometheus-pve-exporter &&     /opt/prometheus-pve-exporter/bin/pip install /src/prometheus-pve-exporter/dist/*.whl &&     ln -s /opt/prometheus-pve-exporter/bin/pve_exporter /usr/bin/pve_exporter &&     rm -rf  8.2s 
 => [stage-2 4/4] RUN addgroup -S -g 101 prometheus &&     adduser -D -H -S -G prometheus -u 101 prometheus                                                                                                                                                    0.2s 
 => exporting to image                                                                                                                                                                                                                                         0.5s 
 => => exporting layers                                                                                                                                                                                                                                        0.5s 
 => => writing image sha256:3d7475b5d48648ae1a30b76c3efa08af42259fca72bf69758bc70aba1aad702d                                                                                                                                                                   0.0s 
 => => naming to docker.io/library/prometheus-pve-exporter-pve-exporter                                                                                                                                                                                        0.0s 
 => resolving provenance for metadata file                                                                                                                                                                                                                     0.0s 
[+] Running 2/2
 ✔ prometheus-pve-exporter-pve-exporter  Built                                                                                                                                                                                                                 0.0s 
 ✔ Container pve-exporter                Recreated                                                                                                                                                                                                             0.1s 
Attaching to pve-exporter
pve-exporter  | [2025-11-08 12:33:41 +0000] [1] [INFO] Starting gunicorn 23.0.0
pve-exporter  | [2025-11-08 12:33:41 +0000] [1] [INFO] Listening at: http://[::]:9221 (1)
pve-exporter  | [2025-11-08 12:33:41 +0000] [1] [INFO] Using worker: gthread
pve-exporter  | [2025-11-08 12:33:41 +0000] [7] [INFO] Booting worker with pid: 7
pve-exporter  | [2025-11-08 12:33:58 +0000] [ERROR] Exception thrown while rendering view
pve-exporter  | Traceback (most recent call last):
pve-exporter  |   File "/opt/prometheus-pve-exporter/lib/python3.12/site-packages/urllib3/connection.py", line 198, in _new_conn
pve-exporter  |     sock = connection.create_connection(
pve-exporter  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pve-exporter  |   File "/opt/prometheus-pve-exporter/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
pve-exporter  |     raise err
pve-exporter  |   File "/opt/prometheus-pve-exporter/lib/python3.12/site-packages/urllib3/util/connection.py", line 73, in create_connection
pve-exporter  |     sock.connect(sa)
pve-exporter  | TimeoutError: timed out

Without the cache, just building the wheel took on my machine ~40 s.

@znerol
Copy link
Member

znerol commented Nov 27, 2025

Hi, thank you for the PR.

I personally wouldn't want the timestamp in the logs. The logs are collected in the systemd journal in my case and if the application would emit the date and time, this information would be redundant.

I do not know how other python applications (or other prometheus exporters) are handling log formats. Maybe that could be passed as an environment variable or a command line argument to make it configurable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants