Closed charlienegri closed 1 month ago
approved and merged
this setup works for the local test but I see no /metrics endpoint exposed now in dev and I wonder if the real case of having gunicorn multiprocesses might require something more https://github.com/rycus86/prometheus_flask_exporter?tab=readme-ov-file#wsgi, will try to investigate
Yes. You are right that you probably have to take in account that dmci is running in gunicorn with multiple processes, so you get the metrics from all processes.
But I see another problem in dmci code, that makes the /metrics endpoint not working on k8s, and working locally.
When you test dmci locally from the dmci_start_api.py
then the prometheus_flask_exporter
defined in api_main()
(https://github.com/metno/discovery-metadata-catalog-ingestor/blob/main/dmci/__init__.py) is loaded.
But when dmci is run in the Docker container, the initializing of the app is happening in container/wsgi.py
, and this code does not execute the api_main()
function.
So in this wsgi.py, you will probably need to add the prometheus_flask_exporter
as well, for it to work with wsgi
And for testing with gunicorn, build the container locally and test it locally with wsgi gunicorn (The default entry point in the container uses the gunicorn)
right, thanks for pointing that out, I had not realized
Summary: #233 was missing a dependency in setup.cfg
Related issue: #220
Suggested reviewer(s):
Reviewer checklist:
The checklist is based on the S-ENDA conventions and definition of done (see General Conventions). The above points are not necessarily relevant to all contributions. In that case, please add a short explanation to help the reviewer.