prometheus / prometheus/client_python

In Django application, '/metrics' unaccessible when using Unix Domain Sockets

Ouverte
#926 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Python
Étoiles
4.4k
Forks
876
Merge moyen
8 j 4 h
PR mergées (30 j)
1

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par les blocs location de NGINX et la configuration du scrape target de Prometheus présentés dans l’issue, puis comparez la configuration de l’Unix domain socket avec la configuration TCP fonctionnelle de Gunicorn. Déterminez si le metrics endpoint prend en charge ce chemin de déploiement et documentez une configuration vérifiée ou la limitation requise.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
nginx, python
Domaine
backend, networking, observability
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.