---
kind: ConfigMap
apiVersion: v1
metadata:
  name: cortex-config
data:
  prometheus.yml: |-
    global:
      scrape_interval:     5s # By default, scrape targets every 15 seconds.

    remote_write:
      - url: https://cloud.weave.works:443/api/prom/push
        basic_auth:
          password: $INSERT_WEAVE_CLOUD_TOKEN_HERE
        tls_config:
          insecure_skip_verify: true

    scrape_configs:
      # This scrape config gathers all service endpoints
      - job_name: 'kubernetes-service-endpoints'
        kubernetes_sd_configs:
        - api_servers:
          - 'https://kubernetes.default.svc.cluster.local'
          in_cluster: true
          role: endpoint

        # You can specify the following annotations (on services):
        #   prometheus.io.scrape: false - don't scrape this service
        #   prometheus.io.scheme: https - use https for scraping
        #   prometheus.io.port - scrape this port
        #   prometheus.io.path - scrape this path
        relabel_configs:
        - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
          action: drop
          regex: false
        - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
          action: replace
          target_label: __scheme__
          regex: ^(https?)$
          replacement: $1
        - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
          action: replace
          target_label: __metrics_path__
          regex: ^(.+)$
          replacement: $1
        - source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
          action: replace
          target_label: __address__
          regex: ^(.+)(?::\d+);(\d+)$
          replacement: $1:$2
        - action: labelmap
          regex: ^__meta_kubernetes_service_label_(.+)$
          replacement: $1
        - source_labels: [__meta_kubernetes_service_namespace]
          action: replace
          regex: ^(.+)$
          target_label: namespace
          replacement: $1
        - source_labels: [__meta_kubernetes_service_name]
          regex: ^(.+)$
          target_label: job
          replacement: $1
