-
Notifications
You must be signed in to change notification settings - Fork 162
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
Gunicorn metrics don't work #165
Comments
If you have a repo to look at, or a (minimal?) example of the setup, we could try working out what's going wrong. |
I am having the same issue. Here's a minimal example that I used to reproduce this: import os
from flask import Flask
from gunicorn.app.base import BaseApplication
from prometheus_flask_exporter.multiprocess import GunicornInternalPrometheusMetrics
class StandaloneApplication(BaseApplication):
def __init__(self):
os.environ['PROMETHEUS_MULTIPROC_DIR'] = '/tmp'
self.application = Flask('my_app')
self.application.add_url_rule('/test', 'test', self.index)
self.metrics = GunicornInternalPrometheusMetrics(self.application)
super().__init__()
def load_config(self) -> None:
pass
def load(self):
return self.application
def index(self):
return 'Hello world'
StandaloneApplication().run() Accessing the application via |
I'm curious, what is the status code on the /metrics request? Is it 404 or 200 or something else? |
It's curl -v http://127.0.0.1:8000/metrics * Trying 127.0.0.1:8000...
* Connected to 127.0.0.1 (127.0.0.1) port 8000
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:8000
> User-Agent: curl/8.6.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: gunicorn
< Date: Tue, 02 Jul 2024 10:42:57 GMT
< Connection: close
< Content-Type: text/plain; version=0.0.4; charset=utf-8
< Content-Length: 0
<
* Closing connection I am using:
|
I had a look now, it looks like the problem is that the Hope this helps! |
Indeed, when setting the environment variable before importing the Thanks for the quick help! 👍 |
I've done all the same as in the README.MD, but when I use one of GunicornInternalPrometheusMetrics or GunicornPrometheusMetrics - /metrics request returns empty response. I've tried everything. I'm starting gunicorn by systemctl. Also when I'm using PrometheusMetrics all is working fine. Maybe it's because systemctl?
The text was updated successfully, but these errors were encountered: