extensions:
  health_check:
    endpoint: 0.0.0.0:13133

receivers:
  prometheus:
    config:
      scrape_configs:
        - job_name: {{ deepflow_connector_source_job_name | to_json }}
          scrape_interval: {{ deepflow_connector_scrape_interval }}
          static_configs:
            - targets:
                - {{ deepflow_connector_source_endpoint | regex_replace('^https?://', '') | regex_replace('/.*$', '') | to_json }}
          metrics_path: {{ ('/' + (deepflow_connector_source_endpoint | regex_replace('^https?://[^/]+', '') | regex_replace('^$', '/metrics') | regex_replace('^//', '/'))) | to_json }}

processors:
  filter/deepflow:
    metrics:
      include:
        match_type: regexp
        metric_names:
          - {{ deepflow_connector_metric_keep_regex | to_json }}
  batch: {}

exporters:
  prometheusremotewrite:
    endpoint: {{ deepflow_connector_remote_write_url | to_json }}
{% if deepflow_connector_remote_write_headers %}
    headers:
{% for key, value in (deepflow_connector_remote_write_headers | default({})).items() %}
      {{ key }}: {{ value | to_json }}
{% endfor %}
{% endif %}

service:
  extensions: [health_check]
  pipelines:
    metrics:
      receivers: [prometheus]
      processors: [filter/deepflow, batch]
      exporters: [prometheusremotewrite]
