diff --git a/roles/stats/defaults/main.yml b/roles/stats/defaults/main.yml index a1d0dde1..5b370dc5 100644 --- a/roles/stats/defaults/main.yml +++ b/roles/stats/defaults/main.yml @@ -36,3 +36,6 @@ stats_collection_interval: 15s # uncomment to scrape more hosts # stats_prometheus_additional_hosts: # - 192.168.1.1:9100 + +# uncomment to scrape metrics from HomeAssistant. You'll need to create a long lived access token. +# stats_hass_long_lived_access_token: addfasdfasdf diff --git a/roles/stats/templates/prometheus.yml.j2 b/roles/stats/templates/prometheus.yml.j2 index 9e7ca1d2..34e5a0b4 100644 --- a/roles/stats/templates/prometheus.yml.j2 +++ b/roles/stats/templates/prometheus.yml.j2 @@ -56,3 +56,12 @@ scrape_configs: {% endfor %} {% endif %} + + - job_name: "homeassistant" + metrics_path: /api/prometheus + authorization: + credentials: "{{ stats_hass_long_lived_access_token | default("abcd") }}" + static_configs: + - targets: [ + "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:8123" + ]