# Kubernetes autodiscover template not working

**URL:** <https://discuss.elastic.co/t/kubernetes-autodiscover-template-not-working/198130>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [September 5, 2019, 12:40am UTC](https://discuss.elastic.co/t/kubernetes-autodiscover-template-not-working/198130 "2019-09-05T00:40:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodriguez-facundo](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@rodriguez-facundo](https://discuss.elastic.co/u/rodriguez-facundo)\
**Post date:** [September 5, 2019, 12:40am UTC](https://discuss.elastic.co/t/kubernetes-autodiscover-template-not-working/198130/1 "2019-09-05T00:40:32Z")

</div>

I'm trying to use kuberntes autodiscover templating to collect metrics from a subset of pods, but I am not able to get output unless I remove the template and set hint.enabled=true

```auto
// metricbeat.yaml
      providers:
        - type: kubernetes
          host: ${HOSTNAME} // also tried ${NODE_NAME}
          include_annotations: ["metribeat"]
          templates:
            - condition.contains:
                kubernetes.annotations.metribeat: "true"
              config:
                - module: kubernetes
                  metricsets: ["node", "system","pod","container","volume"]
                  period: 10s
                  hosts: ["localhost:10255"]

```

The pod:

```auto
annotations:
        metricbeat: "true"

```

system.yaml

```auto
  system.yml: |-
    - module: system
      period: 10s
      metricsets:
        - cpu
        - load
        - memory
        - network
        - process
        - process_summary
      processes: ['.*']
      process.include_top_n:
        by_cpu: 5
        by_memory: 5

    - module: system
      period: 1m
      metricsets:
        - filesystem
        - fsstat
      processors:
      - drop_event.when.regexp:
          system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'

```

I'm commenting this bit (which works just fine removing the templating and using hint.enabled=true but it collects from everything in the cluster and it became super expensive):

```auto
# kubernetes.yml: |-
  # - module: kubernetes
  # metricsets:
  # - node
  # - system
  # - pod
  # - container
  # - volume
  # period: 10s
  # host: ${NODE_NAME}
  # hosts: ["localhost:10255"]
    
  # - module: kubernetes
  # enabled: true
  # metricsets:
  # - state_node
  # - state_deployment
  # - state_replicaset
  # - state_statefulset
  # - state_pod
  # - state_container
  # period: 10s
  # hosts: ["kube-state-metrics.kube-system.svc.cluster.local:8080"]
  # add_metadata: true
  # in_cluster: true

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 3, 2019, 12:42am UTC](https://discuss.elastic.co/t/kubernetes-autodiscover-template-not-working/198130/2 "2019-10-03T00:42:00Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
