diff --git a/TODO.md b/TODO.md index 64b7881..3e50069 100644 --- a/TODO.md +++ b/TODO.md @@ -14,7 +14,6 @@ Load group vars... ROADMAP SEPTEMBRE: -* Support RHEL family - juillet * tests mono node complet - aout * tests offline complet - aout * statuer sur version stable entre septembre 2024 et janvier 2025 diff --git a/roles/alloy/templates/alloy.config.j2 b/roles/alloy/templates/alloy.config.j2 index ecf5934..eed4f48 100644 --- a/roles/alloy/templates/alloy.config.j2 +++ b/roles/alloy/templates/alloy.config.j2 @@ -29,6 +29,46 @@ prometheus.scrape "vault" { {% endif -%} +{%- if __hs_alloy_is_consul_service_present %} + +prometheus.scrape "consul" { + job_name = "consul" + + scrape_interval = "30s" + scrape_timeout = "10s" + scheme = "https" + targets = [ + {"__address__" = "{{ hs_node_fqdn }}:8501"}, + ] + metrics_path = "/v1/agent/metrics" + params = { "format" = ["prometheus"] } + + bearer_token = "{{ hs_consul_telemetry_token }}" + + forward_to = [prometheus.remote_write.upstream.receiver] +} + +{% endif -%} + +{%- if __hs_alloy_is_nomad_service_present %} + +prometheus.scrape "nomad" { + job_name = "nomad" + + scrape_interval = "30s" + scrape_timeout = "10s" + scheme = "https" + targets = [ + {"__address__" = "{{ hs_node_fqdn }}:4646"}, + ] + metrics_path = "/v1/metrics" + params = { "format" = ["prometheus"] } + + forward_to = [prometheus.remote_write.upstream.receiver] +} + +{% endif -%} + prometheus.remote_write "upstream" { endpoint { url = "{{ hs_alloy_prometheus_write_url }}/api/v1/write" diff --git a/roles/alloy/vars/main.yml b/roles/alloy/vars/main.yml index 55785f6..a59d502 100644 --- a/roles/alloy/vars/main.yml +++ b/roles/alloy/vars/main.yml @@ -1,4 +1,8 @@ --- __hs_alloy_is_vault_service_present: >- {{ 'vault.service' in ansible_facts.services }} +__hs_alloy_is_consul_service_present: >- + {{ 'consul.service' in ansible_facts.services }} +__hs_alloy_is_nomad_service_present: >- + {{ 'nomad.service' in ansible_facts.services }}