apiVersion: v1
kind: ConfigMap
metadata:
  name: collector-config
  namespace: wavefront-collector
data:
  collector.yaml: |
    clusterName: YOUR_CLUSTER_NAME
    enableEvents: false
    enableDiscovery: true
    flushInterval: FLUSH_INTERVALs
    defaultCollectionInterval: COLLECTION_INTERVALs


    sinks:
    - proxyAddress: wavefront-proxy.NAMESPACE.svc.cluster.local:2878
      filters:
        # Filter out generated labels
        tagExclude:
        - 'label?controller?revision*'
        - 'label?pod?template*'
        - 'annotation_kubectl_kubernetes_io_last_applied_configuration'


    sources:
      kubernetes_source:
        url: 'https://kubernetes.default.svc'
        kubeletPort: 10250
        kubeletHttps: true
        useServiceAccount: true
        insecure: true
        prefix: 'kubernetes.'

        filters:
          metricDenyList:
          - 'kubernetes.sys_container.*'
          tagExclude:
          - 'label.kubernetes.io/arch'

      internal_stats_source:
        prefix: 'kubernetes.'
        filters:
          tagExclude:
          - 'url'

      kubernetes_state_source:
        prefix: 'kubernetes.'
        filters:
          tagExclude:
          - 'label.kubernetes.io/arch'

      kubernetes_cadvisor_source:
        prefix: 'kubernetes.cadvisor.'
        filters:
          metricAllowList:
          - "kubernetes.cadvisor.container.cpu.cfs.throttled.seconds.total.counter"
          - "kubernetes.cadvisor.container.cpu.cfs.throttled.periods.total.counter"

      kubernetes_control_plane_source:
        collection:
          interval: COLLECTION_INTERVALs

      telegraf_sources:
      # enable all telegraf plugins
      - plugins: [ ]
      - plugins:  [ mysql ]
        conf: |
            servers = ["root:password123@tcp(mysql-release.collector-targets.svc.cluster.local:3306)/?tls=false"]
            table_schema_databases                    = []
            gather_table_io_waits                     = true
            gather_table_lock_waits                   = true
            gather_index_io_waits                     = true
        filters:
          tagExclude:
          - server


    # discovery rules for auto-discovery of pods and services
    discovery:
      enable_runtime_plugins: true
      annotation_excludes:
      - labels:
          please-exclude-from-discovery: ['true']
      plugins:
      - name: coredns-discovery
        type: prometheus
        selectors:
          images:
          - '*coredns:*'
          labels:
            k8s-app:
            - kube-dns
        port: 9153
        path: /metrics
        scheme: http
        prefix: kube.coredns.
        filters:
          metricWhitelist:
          - 'kube.coredns.coredns.cache.*'
          - 'kube.coredns.coredns.dns.request.count.total.counter'
          - 'kube.coredns.coredns.dns.request.duration.seconds'
          - 'kube.coredns.coredns.dns.request.size.bytes'
          - 'kube.coredns.coredns.dns.request.type.count.total.counter'
          - 'kube.coredns.coredns.dns.response.rcode.count.total.counter'
          - 'kube.coredns.coredns.dns.response.size.bytes'
          - 'kube.coredns.process.*'
