prometheus / prometheus/client_python
In Django application, '/metrics' unaccessible when using Unix Domain Sockets
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 876
- Ø Merge
- 8 T. 4 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
Im using the django_prometheus library which is a wrapper for prometheus_client library for my Django app. I am not running Prometheus, (or the entire applcaition in a Docker container), which might be part of my problem, though I dont see why this would be a requirement. The Django application is bound to Unix Domain Sockets,. NGINX is listening on default port 80 and re-routes traffic with the proxy_pass header.
NGINX
server {
server_name hotname www.hostname ip;
[...]
location /metrics{
proxy_pass http://<unix_domain_socket>;
}
location / {
proxy_pass http://unix:<unix_domain_socket>;
}
prometheus
<default prom config>
[...]
static_configs:
- targets: ["localhost:9090"]
- job_name: "django-app"
scrape_interval: 10s
static_configs:
- targets: ["localhost] # nothing works (IP, etc..) and prometheus attempts to use port 80 with a predefined scheme of http://
- job_name: "node"
scrape_interval: 10s
static_configs:
- targets: ["localhost:9100"]
Solution
By removing the unix domain socket in NGINX and going back to TCP/IP that gunicorn uses by default, Prometheus was able to successfully pickup metrics from /metrics
Is there something Im missing? I feel like the only other options are changing the whole infrastructure ( to docker), or try and use a log based-metrics.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den im Issue gezeigten NGINX location blocks und der Prometheus scrape target-Konfiguration und vergleiche anschließend die Einrichtung des Unix domain socket mit der funktionierenden Gunicorn TCP-Einrichtung. Ermittle, ob der metrics endpoint diesen Bereitstellungspfad unterstützt, und dokumentiere entweder eine verifizierte Konfiguration oder die erforderliche Einschränkung.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- nginx, python
- Bereich
- backend, networking, observability
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100