promtail: Move scrape_configs into prometheus_agent.agents.promtail.scrape_jobs dict
This commit is contained in:
parent
7d0415ecf6
commit
ba32c8ee83
2 changed files with 31 additions and 13 deletions
|
|
@ -1,8 +1,21 @@
|
|||
{% if 'clients' not in prometheus_agent.agents.promtail.config %}
|
||||
{% set tmp = prometheus_agent.agents.promtail.config.setdefault('clients', []) %}
|
||||
{% for i in prometheus_agent.scrapers if prometheus_agent.scrapers[i].get("loki") %}
|
||||
{% set lokiconfig = {}|combine({ "external_labels": merged_prometheus_labels|combine( {"instance": inventory_hostname} ) }, prometheus_agent.scrapers[i]['loki'] ) %}
|
||||
{% set tmp = prometheus_agent.agents.promtail.config.clients.append(lokiconfig) %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{{ prometheus_agent.agents.promtail.config|to_nice_yaml(indent=2) }}
|
||||
{%- set config = prometheus_agent.agents.promtail.config.copy() -%}
|
||||
|
||||
{%- if 'clients' not in config -%}
|
||||
{%- set tmp = config.setdefault('clients', []) -%}
|
||||
{%- for i in prometheus_agent.scrapers if prometheus_agent.scrapers[i].get("loki") -%}
|
||||
{%- set lokiconfig = {}|combine({ "external_labels": merged_prometheus_labels|combine( {"instance": inventory_hostname} ) }, prometheus_agent.scrapers[i]['loki'] ) -%}
|
||||
{%- set tmp = config.clients.append(lokiconfig) -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if 'scrape_configs' not in config -%}
|
||||
{%- set tmp = config.setdefault('scrape_configs', []) -%}
|
||||
{%- for key, value in prometheus_agent.agents.promtail.scrape_jobs.items() -%}
|
||||
{%- set tmp = value.setdefault('job_name', key) -%}
|
||||
{%- set tmp = config.scrape_configs.append(value) -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{{ config|to_nice_yaml(indent=2) }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue