diff --git a/ansible/inventory/host_vars/london-c.yml b/ansible/inventory/host_vars/london-c.yml index 6340a2c..5f5351d 100644 --- a/ansible/inventory/host_vars/london-c.yml +++ b/ansible/inventory/host_vars/london-c.yml @@ -3,3 +3,6 @@ host_role: idle host_description: "Idle/available" host_location: "London" prometheus_location: london + +docker_services: + - octopus-exporter diff --git a/ansible/services/octopus-exporter/docker-compose.yml b/ansible/services/octopus-exporter/docker-compose.yml new file mode 100644 index 0000000..5c421ce --- /dev/null +++ b/ansible/services/octopus-exporter/docker-compose.yml @@ -0,0 +1,11 @@ +--- +# octopus-exporter - Octopus Energy metrics for Prometheus +# Host: london-c (100.123.72.87) + +services: + octopus-exporter: + image: rwejlgaard/octopus_exporter:v1.1.0 + container_name: octopus_exporter + restart: unless-stopped + ports: + - "9359:9359" diff --git a/ansible/services/prometheus/prometheus.yml.j2 b/ansible/services/prometheus/prometheus.yml.j2 index 637ca80..8065510 100644 --- a/ansible/services/prometheus/prometheus.yml.j2 +++ b/ansible/services/prometheus/prometheus.yml.j2 @@ -22,7 +22,15 @@ scrape_configs: - job_name: "octopus_exporter" static_configs: - - targets: ["100.123.72.87:9359"] +{% for host in groups['all'] | sort %} +{% set h = hostvars[host] %} +{% if 'octopus-exporter' in (h.docker_services | default([])) %} + - targets: ["{{ h.ansible_host }}:9359"] + labels: + location: {{ h.prometheus_location }} + server: {{ host }} +{% endif %} +{% endfor %} - job_name: "node_exporter" static_configs: