ansible
ansible copied to clipboard
Target hostname not being set on scrape config
Hi,
Any idea why when installing prometheus using this ansible role it sometimes sets target with the right hostname and sometimes sets localhost as per image below (in the same instance)?
prometheus_scrape_configs:
- job_name: "prometheus"
metrics_path: "{{ prometheus_metrics_path }}"
static_configs:
- targets:
- "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090"
Did you ever figure this out?
Could it be that you have gather_facts: false in your playbook? In that case you might be able to use "{{ inventory_hostname }}" instead.