# Heartbeat autodiscover kubernetes pods

**URL:** <https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642>\
**Category:** Synthetics\
**Created:** [May 21, 2021, 9:05am UTC](https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642 "2021-05-21T09:05:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesp220291](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jamesp220291](https://discuss.elastic.co/u/jamesp220291)\
**Post date:** [May 21, 2021, 9:05am UTC](https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642/1 "2021-05-21T09:05:07Z")

</div>

Hi

i want heartbeat to find every single kubernetes pod and report it to elasticsearch uptime, however all i am able to currentlty get is the kubernetes nodes and my 1x http monitor.

here is my config

```auto
data:
  heartbeat.yml: |-
    heartbeat.autodiscover:
      # Autodiscover pods
      providers:
        - type: kubernetes
          resource: pod
          scope: cluster
          hints.enabled: true
          templates:
              config:
                - type: http
                  hosts: ["$${data.host}:$${data.port}"]
                  schedule: "@every 1s"
                  timeout: 1s
    
      # Autodiscover services
      providers:
        - type: kubernetes
          resource: service
          scope: cluster
          node: $${NODE_NAME}
          hints.enabled: true
    
      # Autodiscover nodes
      providers:
        - type: kubernetes
          resource: node
          node: $${NODE_NAME}
          scope: cluster
          templates:
            # Example, check SSH port of all cluster nodes:
            - condition: ~
              config:
                - hosts:
                    - $${data.host}:22
                  name: $${data.kubernetes.node.name}
                  schedule: '@every 10s'
                  timeout: 5s
                  type: tcp

    processors:
      - add_cloud_metadata:

    output.elasticsearch:
      hosts: ['${ES_HOST}']
      username: "elastic"
      password: ${ES_PASSWORD}
      
  
    heartbeat.monitors:
    - type: http
      schedule: '@every 5s'
      urls: ["http://www.google.com"]
      service.name: google
      id: google
      name: google

```

can anyone see where i am going wrong with the autodiscover resource type pod? the autodiscover node works, but not pods

---

<div class="post-metadata">

**Author:** ![jkambic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkambic/32/53306_2.png) [@jkambic](https://discuss.elastic.co/u/jkambic)\
**Post date:** [May 24, 2021, 4:08pm UTC](https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642/2 "2021-05-24T16:08:06Z")

</div>

Hi @jamesp220291, sorry you're having trouble using autodiscover.

Before proceeding with further troubleshooting I just wanted to verify that the lines like below with the double `$` are intentional:

```auto
hosts: ["$${data.host}:$${data.port}"]

```

---

<div class="post-metadata">

**Author:** ![jamesp220291](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jamesp220291](https://discuss.elastic.co/u/jamesp220291)\
**Post date:** [May 24, 2021, 4:14pm UTC](https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642/3 "2021-05-24T16:14:37Z")

</div>

hey

yeh thats intentional as its a terraform template the double escaping stop its looking for it as a terraform variable.

---

<div class="post-metadata">

**Author:** ![jamesp220291](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jamesp220291](https://discuss.elastic.co/u/jamesp220291)\
**Post date:** [May 27, 2021, 7:33am UTC](https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642/4 "2021-05-27T07:33:22Z")

</div>

hey @jkambic

do you have any ideas?

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [June 1, 2021, 4:02pm UTC](https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642/5 "2021-06-01T16:02:18Z")

</div>

Hey @jamesp220291,

You have multiple `providers` entries under `heartbeat.autodiscover`, one is probably overriding the others and this is probably why you see that only one provider works.  
Try removing all the `providers:` lines except the first one, so your config looks like this:

```auto
    heartbeat.autodiscover:
      providers:
        # Autodiscover pods
        - type: kubernetes
          resource: pod
          ...
        # Autodiscover services
        - type: kubernetes
          resource: service
          ...
        # Autodiscover nodes
        - type: kubernetes
          resource: node
          ...

```

YAML is sometimes treacherous 😕

---

<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:** [June 25, 2021, 4:02pm UTC](https://discuss.elastic.co/t/heartbeat-autodiscover-kubernetes-pods/273642/6 "2021-06-25T16:02:25Z")

</div>

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