Ho un’installazione Discourse in esecuzione (due in realtà, una in staging e un’altra in produzione, VM diverse e tutto il resto). Sto testando sull’ambiente di staging. Installazione tramite la guida ufficiale.
Attualmente uno stack Grafana/Prometheus/Node Exporter è distribuito tramite docker compose sulla stessa VM in cui è già distribuita l’installazione di Discourse.
Ecco il docker-compose.yaml
version: "3"
services:
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: cadvisor
restart: unless-stopped
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
networks:
- prometheus-cadvisor
node_exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node_exporter
command:
- '--path.rootfs=/host'
pid: host
restart: unless-stopped
volumes:
- '/:/host:ro,rslave'
networks:
- prometheus-node_exporter
prometheus:
image: prom/prometheus:latest
restart: unless-stopped
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus:/app.cfg
networks:
- world
- prometheus-cadvisor
- prometheus-node_exporter
- discourse
- grafana-prometheus
command: >-
--config.file=/app.cfg/prometheus.yaml
--storage.tsdb.path=/prometheus
--web.console.libraries=/usr/share/prometheus/console_libraries
--web.console.templates=/usr/share/prometheus/consoles
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: unless-stopped
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_USER: [OMITTED]
GF_SECURITY_ADMIN_PASSWORD: [OMITTED]
GF_PATHS_PROVISIONING: '/app.cfg/provisioning'
volumes:
- ./grafana:/app.cfg
- ./grafana/provisioning:/etc/grafana/provisioning
networks:
- world
- grafana-prometheus
networks:
world:
grafana-prometheus:
internal: true
prometheus-cadvisor:
internal: true
prometheus-node_exporter:
internal: true
discourse:
external: true
Ho ricostruito discourse specificando una rete in modo che non venga distribuito su bridge e ho collegato Prometheus sulla stessa rete.
docker network create -d bridge discourse
/var/discourse/launcher rebuild app --docker-args '--network discourse'
Ho testato entrando nel container Prometheus e facendo il ping al container discourse usando l’alias della rete interna e ha potuto raggiungerlo.
Ora, quando configuro il job di Prometheus in modo che esegua lo scraping delle metriche, utilizzando un IP interno, vedo solo server returned HTTP status 404 Not Found.
Questa è la configurazione di Prometheus:
global:
scrape_interval: 30s
scrape_timeout: 10s
rule_files:
scrape_configs:
- job_name: prometheus
metrics_path: /metrics
static_configs:
- targets:
- 'prometheus:9090'
- job_name: node_exporter
static_configs:
- targets:
- 'node_exporter:9100'
- job_name: discourse_exporter
static_configs:
- targets:
- 'vmuniqueID-app:80'
vmuniqueID è una sostituzione del nome effettivo della VM.
Secondo la documentazione qui, l’accesso tramite IP interno dovrebbe essere consentito:
Out of the box we allow the
metricsroute to admins and private ips.
Aiutatemi a capire cosa mi sfugge ![]()




