logging.level: debug

heartbeat.monitors:
{% for monitor in monitors -%}
- type: {{ monitor.type }}
  schedule: '{{ monitor.schedule|default("@every 1s") }}'
  {%- if monitor.timeout is defined %}
  timeout: {{monitor.timeout}}
  {% endif -%}

  {%- if monitor.enabled is defined %}
  enabled: {{monitor.enabled}}
  {% endif -%}

  {%- if monitor.tags is defined %}
  tags:
    {% for tag in monitor.tags -%}
    - '{{ tag }}'
    {% endfor %}
  {% endif -%}

  {%- if monitor.hosts is defined %}
  hosts:
    {%- for host in monitor.hosts %}
    - '{{ host }}'
    {% endfor -%}
  {% endif -%}

  {%- if monitor.urls is defined %}
  urls:
    {%- for url in monitor.urls %}
    - '{{ url }}'
    {% endfor %}
  {% endif -%}


  {%- if monitor.check_response_json is defined %}
  check.response.json:
    {%- for check in monitor.check_response_json %}
    - {{check}}
    {% endfor %}
  {% endif -%}

  {%- if monitor.fields is defined %}
  {% if monitor.fields_under_root %}fields_under_root: true{% endif %}
  fields:
    {% for k, v in monitor.fields.items() -%}
    {{ k }}: {{ v }}
    {% endfor %}
  {% endif %}
{% endfor -%}

{%- if run_once is defined %}
heartbeat.run_once: {{run_once}}
{% endif -%}

{% if reload or reload_path -%}
heartbeat.config.monitors:
  path: {{ reload_path|default("${path.config}/monitors.d/*.yml") }}
  reload.period: 1s
  reload.enabled: {{ reload|default("false")}}
{% endif -%}

{% if autodiscover %}
heartbeat.autodiscover:
  providers:
  {%- for provider, settings in autodiscover.items() %}
  - type: {{provider}}
    {%- if settings %}
    {%- for k, v in settings.items() %}
    {{k}}: {{v | default([])}}
    {%- endfor %}
    {%- endif %}
  {%- endfor %}
{% endif %}

{%- if shipper_name %}
name: {{ shipper_name }}
{% endif %}

{%- if tags %}
tags:
  {% for tag in tags -%}
  - {{ tag }}
  {% endfor -%}
{% endif %}

{%- if fields %}
{% if fields_under_root %}fields_under_root: true{% endif %}
fields:
  {% for k, v in fields.items() -%}
  {{ k }}: {{ v }}
  {% endfor -%}
{% endif %}

#================================ Queue =====================================

queue.mem:
  events: 4096
  flush.min_events: 8
  flush.timeout: 0.1s

#================================ Outputs =====================================

{%- if elasticsearch %}
output.elasticsearch:
  hosts: ["{{ elasticsearch.host }}"]
{%- else %}
output.file:
  path: '{{ output_file_path|default(beat.working_dir + "/output") }}'
  filename: {{ output_file_filename|default("heartbeat") }}
{%- endif %}
