ansible icon indicating copy to clipboard operation
ansible copied to clipboard

Target hostname not being set on scrape config

Open bmgante opened this issue 2 years ago • 1 comments

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)?

image

prometheus_scrape_configs:
  - job_name: "prometheus"
    metrics_path: "{{ prometheus_metrics_path }}"
    static_configs:
      - targets:
          - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090"

bmgante avatar Jun 22 '23 18:06 bmgante

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.

gardar avatar Oct 18 '24 17:10 gardar