Files
root c4825c2d27 feat: 引入 vmauth 鉴权与严格多租户
- 对外端口统一为 18428(vmauth 入口),VM 不再直接暴露宿主机端口
- 边缘 vmagent 与中央 Prometheus remote_write 增加 basic auth
- 支持 tenants.csv 驱动的 per-tenant 写入/查询隔离,并提供管理员跨租户只读查询
- 更新 Grafana provisioning 与部署/文档

Made-with: Cursor
2026-04-22 11:41:13 +00:00

76 lines
2.4 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 边缘节点统一编排vmagent = 短时内存缓存 + 长时磁盘缓存 + 冗余重试)
# 用法: docker compose up -d
services:
# ========== 边缘必选 ==========
# vmagent抓取 + remote_write内置短时内存缓存、长时磁盘缓存、失败重试
prometheus-edge:
image: victoriametrics/vmagent:latest
container_name: prometheus-edge
restart: unless-stopped
environment:
- CENTRAL_SERVER_HOST=${CENTRAL_SERVER_HOST:-192.168.1.10}
- CENTRAL_SERVER_PORT=${CENTRAL_SERVER_PORT:-18428}
- VMAUTH_WRITE_USER=${VMAUTH_WRITE_USER:-vm_write}
- VMAUTH_WRITE_PASSWORD=${VMAUTH_WRITE_PASSWORD:-change-me-strong-write}
volumes:
- vmagent-cache-data:/cache
- ./config/vmagent/vmagent-scrape.yml.template:/etc/vmagent/scrape.yml:ro
- ./config/target-onvif.json:/etc/prometheus/target-onvif.json:ro
- ./config/target-ping.json:/etc/prometheus/target-ping.json:ro
mem_limit: "256m"
cpus: "2.0"
ports:
- "9092:8429"
extra_hosts:
- "host.docker.internal:host-gateway"
command:
- -promscrape.config=/etc/vmagent/scrape.yml
- -remoteWrite.url=http://${CENTRAL_SERVER_HOST}:${CENTRAL_SERVER_PORT}/api/v1/write
- -remoteWrite.basicAuth.username=${VMAUTH_WRITE_USER}
- -remoteWrite.basicAuth.password=${VMAUTH_WRITE_PASSWORD}
- -remoteWrite.tmpDataPath=/cache/remotewrite
- -remoteWrite.maxDiskUsagePerURL=512MB
- -memory.allowedPercent=80
- -httpListenAddr=:8429
networks:
- monitoring_net
# ========== 可选容器(按需启用)==========
onvif-exporter:
profiles:
- onvif
image: onvif-exporter:local
build:
context: .
dockerfile: apps/onvif-exporter/Dockerfile
container_name: onvif-exporter
restart: unless-stopped
environment:
- EXPORTER_PORT=9600
- TARGETS_FILE=/config/targets.json
volumes:
- ./config/target-onvif.json:/config/targets.json:ro
mem_limit: "128m"
cpus: "1.5"
networks:
- monitoring_net
blackbox-exporter:
image: prom/blackbox-exporter:latest
container_name: blackbox-exporter
restart: unless-stopped
volumes:
- ./config/blackbox/config.yml:/etc/blackbox_exporter/config.yml:ro
mem_limit: "64m"
cpus: "0.5"
networks:
- monitoring_net
networks:
monitoring_net:
driver: bridge
volumes:
vmagent-cache-data: