prometheus / prometheus/client_python
In Django application, '/metrics' unaccessible when using Unix Domain Sockets
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 4.4k
- フォーク
- 876
- 平均マージ
- 8日 4時間
- マージ済み PR(30日)
- 1
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue に示されている NGINX の location ブロックと Prometheus の scrape target 設定から始め、次に Unix domain socket のセットアップを、動作している Gunicorn TCP セットアップと比較します。metrics endpoint がこのデプロイパスをサポートしているかを判断し、検証済みの設定、または必要な制限事項を文書化します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- nginx, python
- 領域
- backend, networking, observability
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100