---
# create configmap for prometheus scrape config
kind: ConfigMap
metadata:
  name: prometheus-config
  namespace: amazon-cloudwatch
apiVersion: v1
data:
  # prometheus config
  prometheus.yaml: |
    global:
      scrape_interval: 1m
      scrape_timeout: 10s
    scrape_configs:
      - job_name: 'kubernetes-apiservers'
        kubernetes_sd_configs:
          - role: endpoints
            namespaces:
              names:
                - default
        scheme: https
        tls_config:
          ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
          insecure_skip_verify: true
        bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
        relabel_configs:
        - source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
          action: keep
          regex: kubernetes;https
        - action: replace
          source_labels:
          - __meta_kubernetes_namespace
          target_label: Namespace
        - action: replace
          source_labels:
          - __meta_kubernetes_service_name
          target_label: Service