apiVersion: v1
kind: ConfigMap
metadata:
  namespace: "{{ namespace }}"
  name: prometheus-config
data:
  prometheus.yml: |
    global:
      scrape_interval:     30s # Set the scrape interval to every 30 seconds. Default is every 1 minute.
      evaluation_interval: 30s # Evaluate rules every 30 seconds. The default is every 1 minute.
      # scrape_timeout is set to the global default (10s).
    rule_files:
      - "/etc/configs/alert_rules/*_rules.yml"
    # Alertmanager configuration
    alerting:
      alertmanagers:
      - static_configs:
        - targets: ['alertmanager:9093']

    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    scrape_configs:
      # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
      - job_name: 'prometheus'
        static_configs:
          - targets: ['localhost:9090']

      - job_name: 'crashlog_analysis_service'
        metrics_path: /metrics
        static_configs:
          - targets: ['crashlog_analysis_service:8080']

      - job_name: 'default_routes_service'
        metrics_path: /metrics
        static_configs:
          - targets: ['default-routes-service:8080']

      - job_name: 'jupyter'
        metrics_path: /metrics
        metric_relabel_configs:
          - source_labels: [__name__]
            target_label: __name__
            replacement: "jupyter_${1}"
        static_configs:
          - targets: ['jupyter:8080']

      - job_name: 'analytics'
        metrics_path: /metrics
        static_configs:
          - targets: ['analytics:8080']

      - job_name: 'kafka'
        dns_sd_configs:
          - names:
            - 'kafka'
            type: 'A'
            port: 9876

      - job_name: 'prometheus_cache'
        metrics_path: /metrics
        scrape_interval: 1s
        honor_labels: true
        static_configs:
          - targets: ['prometheus-cache:9091']

      - job_name: 'topology_service'
        metrics_path: /metrics
        static_configs:
          - targets: ['topology-service:8080']

      - job_name: 'weather_service'
        metrics_path: /metrics
        static_configs:
          - targets: ['weather-service:8080']

  alertmanager-default.yml: |
    global:
      resolve_timeout: 5m
    route:
      group_by: ['alertname']
      receiver: 'default'
      routes:
      - receiver: tg_tenant_base_route
        match:
          networkID: "tg"
    receivers:
    - name: 'default'
    - name: tg_tenant_base_route
