Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus: Revive the prometheus plugin #582

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

cdecker
Copy link
Contributor

@cdecker cdecker commented Aug 13, 2024

I also added myself as maintainer in the CODEOWNERS file.

@cdecker cdecker force-pushed the 20240813-prometheus-revive branch 2 times, most recently from d8d740f to c2e8f01 Compare August 13, 2024 14:43
@chrisguida
Copy link
Collaborator

Excited to see this PR! Will try it out soon :)

@daywalker90
Copy link
Contributor

Tests are flaky, i saw some "address already in use" in one of them.

@chrisguida chrisguida force-pushed the 20240813-prometheus-revive branch from c2e8f01 to 9a0a86a Compare August 29, 2024 21:17
@chrisguida
Copy link
Collaborator

Interesting, looks like this is only broken on 23.11

@chrisguida
Copy link
Collaborator

Gonna update the CI to add 24.08 and remove 23.11, then this should be good to go

@chrisguida chrisguida force-pushed the 20240813-prometheus-revive branch 2 times, most recently from b6f7a3c to 78b17da Compare September 27, 2024 17:20
@chrisguida
Copy link
Collaborator

@cdecker any suggestions on how to use this? I'm not familiar with the prometheus protocol.

I think this is fine to merge since this plugin was already in the plugins repo, just archived due to failing tests, which this PR fixes.

ACK 78b17da

@chrisguida chrisguida force-pushed the 20240813-prometheus-revive branch from 78b17da to ee6e482 Compare October 11, 2024 22:54
@cdecker
Copy link
Contributor Author

cdecker commented Oct 18, 2024

Sure, the plugin just exposes the /metrics URL on a given port (concurrent tests are causing the flakiness), and then you configure your prometheus server to scrape that endpoint, which puts the metrics in its timeseries DB. It's a very lightweight way of collecting metrics in a scalable way.

@mikemoniker
Copy link

Taking a look at this, I have a raspiblitz running cln, going to clone the prometheus plugin branch in and run prometheus and point it at the endpoint.

@mikemoniker
Copy link

I was able to install prometheus and get it to ingest the metrics and display them on port 9100. I had some difficulties with poetry and raspiblitz.

Since raspiblitz does everything with pip install --user, but I did not find an equivalent for poetry, I had to edit the shebang of the prometheus.py to use the venv python executable. @cdecker, I am curious how you run this on your system. Is there a more reproducible way? So it can be easier for future users.

@chrisguida chrisguida force-pushed the 20240813-prometheus-revive branch from ee6e482 to 7c565dd Compare December 5, 2024 21:11
@cdecker
Copy link
Contributor Author

cdecker commented Dec 7, 2024

We have been playing with a number of possible python installation options:

  • Using the system python install. This quickly leads to version conflicts for multiple python projects and often lags severely behind in it's version often going over EOL
  • Using the env helper to find the python virtualenv: #!/user/bin/env python3 picks up the python env from the $PATH envvar. However that envvar comes from lightningd so it is shared between plugins, potentially causing multiple plugins to cause a version clash. The advantage is that it is very flexible and doesn't require additional setup, but plugins share an env.
  • Using uv to manage both python interpreter as well as python dependencies. Setting a shebang of #!/ist/bin/env -S uv run will pick uv from the env, have it read the script (see how dependency declaration can be embedded in the script), create a virtualenv (cached), download a matching interpreter (cached), install any missing dependency (cached) and run the script with the env. Requires some setup so that uv is available, but provides the best env isolation and the least headaches I think.

Ideally we'd have something that works everywhere. Maybe a runner script that analyzes the env, adjusts it and then runs the interpreter could be useful, but at that point why not use uv directly?

@chrisguida
Copy link
Collaborator

Hmm uv sounds interesting! Will research...

@chrisguida
Copy link
Collaborator

re-ACK 7c565dd

@chrisguida chrisguida merged commit 2674cb7 into master Dec 9, 2024
7 checks passed
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.

4 participants