patrickjahns / ansible-role-promtail

🔧 Ansible role for deploying promtail
MIT License
101 stars 59 forks source link

unable to parse syslog config receiver #196

Closed saibug closed 11 months ago

saibug commented 11 months ago

Hello,

I'm trying to parse template with to_nice_yaml, and my config are :

Variable content :

opromtailScrapeConfig:
      - job_name: system
        static_configs:
        - targets:
            - localhost
          labels:
            job: messages
            __path__: /var/log/syslog
      - job_name: syslog
        syslog:
          listen_address: 0.0.0.0:1514
          idle_timeout: 60s
          label_structured_data: yes
          labels:
            job: "syslog-ng"
          use_incoming_timestamp: true
        relabel_configs:
          - source_labels: ['__syslog_message_hostname']
            target_label: 'host'

Template config :


scrape_configs:
  {% if opromtailScrapeConfig is defined %}
  {{ opromtailScrapeConfig | to_nice_yaml(indent=2) | indent(2, False) }}
  {% endif %}

{% if opromtailTargetConfig is defined %}
target_config:
  {{ opromtailTargetConfig | to_nice_yaml(indent=2) | indent(2, False) }}
{% endif %}

My output is :

scrape_configs:
    - job_name: system
    static_configs:
    - labels:
        __path__: /var/log/syslog
        job: messages
      targets:
      - localhost
  - job_name: syslog
    relabel_configs:
    - source_labels:
      - __syslog_message_hostname
      target_label: host
    syslog:
      idle_timeout: 60s
      label_structured_data: true
      labels:
        job: syslog-ng
      listen_address: 0.0.0.0:1514
      use_incoming_timestamp: true

Expected behavior :

scrape_configs:
  - job_name: syslog
    syslog:
      listen_address: 0.0.0.0:1514
      idle_timeout: 60s
      label_structured_data: yes
      labels:
        job: "syslog"
    relabel_configs:
      - source_labels: ['__syslog_message_hostname']
        target_label: 'host'

Seems to befilter's issue :(

Any idea ?