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

Request for help of using it #167

Open
Gruummy opened this issue Dec 12, 2023 · 1 comment
Open

Request for help of using it #167

Gruummy opened this issue Dec 12, 2023 · 1 comment

Comments

@Gruummy
Copy link

Gruummy commented Dec 12, 2023

Hi to the round,

i am no developer .. i directly need so say.
I am starting the evolve to a DevOps engeneer and need to extend things to make it better.

Currently we use pgadmin4 .. which is a flask .. gunicorn docker container we run.

https://github.com/pgadmin-org/pgadmin4

It uses this command to start gunicorn
https://github.com/pgadmin-org/pgadmin4/blob/master/pkg/docker/entrypoint.sh#L95

exec /venv/bin/gunicorn --limit-request-line "${GUNICORN_LIMIT_REQUEST_LINE:-8190}" --timeout "${TIMEOUT}" --bind "${PGADMIN_LISTEN_ADDRESS:-[::]}:${PGADMIN_LISTEN_PORT:-80}" -w 1 --threads "${GUNICORN_THREADS:-25}" --access-logfile "${GUNICORN_ACCESS_LOGFILE:--}" -c gunicorn_config.py run_pgadmin:app

And it uses this for gunicorn config
https://github.com/pgadmin-org/pgadmin4/blob/master/pkg/docker/gunicorn_config.py

import gunicorn
gunicorn.SERVER_SOFTWARE = 'Python'

And the startup happens where
https://github.com/pgadmin-org/pgadmin4/blob/master/pkg/docker/run_pgadmin.py

import builtins
builtins.SERVER_MODE = True

from pgAdmin4 import app

pgadmin4 app itself is located here:
https://github.com/pgadmin-org/pgadmin4/blob/master/web/pgAdmin4.py

Is there some possibility existing with some "smart" and small "tweaks" to extend / wrap the application to be able to add the metrics of flask without big rework of the main code of the application ?

Any help / hint how to do it with application would be REALLY great.

@rycus86
Copy link
Owner

rycus86 commented Dec 13, 2023

Hello! 👋
As the README explains you can get default metrics with a one-liner (ok, two with imports):

from prometheus_flask_exporter import PrometheusMetrics

...

metrics = PrometheusMetrics(app)

For a quick test, I'd perhaps just add it in pkg/docker/run_pgadmin.py to get default metrics on the default /metrics endpoint:

import builtins
from prometheus_flask_exporter import PrometheusMetrics
builtins.SERVER_MODE = True

from pgAdmin4 import app

metrics = PrometheusMetrics(app)

That should be it (based on a quick look).

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

No branches or pull requests

2 participants