Here’s my relevant docker compose entries…
vmagent:
container_name: vmagent
image: victoriametrics/vmagent:v1.80.0
depends_on:
- "victoriametrics"
volumes:
- $HOME/docker/vmagentdata:/vmagentdata
- $HOME/docker/vmprometheus/prometheus.yml:/etc/prometheus/prometheus.yml
command:
- "--promscrape.config=/etc/prometheus/prometheus.yml"
- "--remoteWrite.url=http://192.168.0.97:8428/api/v1/write"
network_mode: host
restart: always
victoriametrics:
container_name: victoriametrics
image: victoriametrics/victoria-metrics:v1.80.0
volumes:
- $HOME/docker/vmdata:/storage
command:
- "--storageDataPath=/storage"
- "--graphiteListenAddr=:2003"
- "--opentsdbListenAddr=:4242"
- "--httpListenAddr=:8428"
- "--influxListenAddr=:8089"
- "--vmalert.proxyURL=http://vmalert:8880"
network_mode: host
restart: always
…with my machine’s IP being 192.168.0.97
for the --remoteWrite.url
command.
The rest of the setup involves turning on the Prometheus integration and then using this prometheus.yml
…
scrape_configs:
- job_name: "hass"
scrape_interval: 60s
metrics_path: /api/prometheus
bearer_token: "your token"
scheme: http
static_configs:
- targets: ['192.168.0.97:8123']
…which is used by vmagent and referenced by one of it’s volumes ($HOME/docker/vmprometheus/prometheus.yml:/etc/prometheus/prometheus.yml
).