# {{ project_name }} - Prometheus Configuration
# Generated by typedialog-prov-gen

global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    cluster: '{{ project_name }}'
    environment: '${ENVIRONMENT:-production}'

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - 'alertmanager:9093'

# Load rules once and periodically evaluate them
rule_files:
  - '/etc/prometheus/rules/*.yml'

# Scrape configurations
scrape_configs:
  # Prometheus itself
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  # {{ project_name }} application metrics
  - job_name: '{{ project_name }}'
    static_configs:
      - targets:
{% for i in range(start=1, end=server_count | default(value="1") + 1) %}
          - 'app-{{ i }}:${METRICS_PORT:-9091}'
{% endfor %}
    relabel_configs:
      - source_labels: [__address__]
        target_label: instance
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: '{{ project_name }}:${METRICS_PORT:-9091}'

  # Node exporter for system metrics
  - job_name: 'node-exporter'
    static_configs:
      - targets:
{% for i in range(start=1, end=server_count | default(value="1") + 1) %}
          - 'app-{{ i }}:9100'
{% endfor %}

{% if infrastructure.database %}
  # Database exporter
  - job_name: 'database-exporter'
    static_configs:
      - targets:
          - 'db-exporter:9187'
{% endif %}

# Remote write for long-term storage (optional)
# remote_write:
#   - url: 'http://mimir:9009/api/v1/push'
