我想使用 prometheus、django rest 框架和 docker 监控我的数据库,
都是我的本地机器,错误如下:
那么错误是url http://127.0.0.1:9000/metrics, http: //127.0.0.1 :9000是乞求我的API,我不知道是什么问题,我的配置如下
我的要求.txt
- django-普罗米修斯
我的文件 docker:docker-compose-monitoring.yml
version: '2'
services:
prometheus:
image: prom/prometheus:v2.14.0
volumes:
- ./prometheus/:/etc/prometheus/
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- 9090:9090
grafana:
image: grafana/grafana:6.5.2
ports:
- 3060:3060
我的文件夹和文件 prometheus/prometheus.yml
global:
scrape_interval: 15s
rule_files:
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- 127.0.0.1:9090
- job_name: monitoring_api
static_configs:
- targets:
- 127.0.0.1:9000
我的文件 settings.py
INSTALLED_APPS=[
...........
'django_prometheus',]
MIDDLEWARE:[
'django_prometheus.middleware.PrometheusBeforeMiddleware',
......
'django_prometheus.middleware.PrometheusAfterMiddleware']
我的模型.py
from django_promethues.models import ExportMOdelOperationMixin
class MyModel(ExportMOdelOperationMixin('mymodel'), models.Model):
"""all my fields in here"""
我的网址.py
url('', include('django_prometheus.urls')),
应用程序运行良好,在 127.0.0.1:9090/metrics 时,但只是监控相同的 url,而我需要监控不同的 url,我认为问题不在于文件 prometheus.yml 中的配置,因为我不知道如何调用我的表或我的 api,请帮助我。
再见。
