# Metricbeat on Kubernetes not reporting correct hostname

**URL:** <https://discuss.elastic.co/t/metricbeat-on-kubernetes-not-reporting-correct-hostname/204870>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [October 23, 2019, 12:42pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-not-reporting-correct-hostname/204870 "2019-10-23T12:42:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronin](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ronin](https://discuss.elastic.co/u/Ronin)\
**Post date:** [October 23, 2019, 12:42pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-not-reporting-correct-hostname/204870/1 "2019-10-23T12:42:16Z")

</div>

I have deployed metricbeat into a k8s cluster using the [elastic helm chart](https://github.com/elastic/helm-charts/tree/master/metricbeat) however in kibana inventory the hostname is showing as the pod name and not the actual hostname for the node. The only change to the default config file was to output to elastic cloud. The config file is:

```auto
    system:
      hostfs: /hostfs
    metricbeat.modules:
    - module: kubernetes
      metricsets:
        - container
        - node
        - pod
        - system
        - volume
      period: 10s
      host: "${NODE_NAME}"
      hosts: ["${NODE_NAME}:10255"]
      processors:
      - add_kubernetes_metadata:
          in_cluster: true
    - module: kubernetes
      enabled: true
      metricsets:
        - event
    - 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 have verified inside the pods the NODE\_NAME env variable is set and correct. I have tried adding just add\_metadata: true instead of processors which came from configuration [here](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-kubernetes.html). I have also looked through this previous [post](https://discuss.elastic.co/t/metricbeat-not-processing-kubernetes-labels/144574) but it did not resolve the issue.

---

<div class="post-metadata">

**Author:** ![pmercado](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pmercado](https://discuss.elastic.co/u/pmercado)\
**Post date:** [October 23, 2019, 3:56pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-not-reporting-correct-hostname/204870/2 "2019-10-23T15:56:09Z")

</div>

Hi @Ronin,

unfortunately I don't have an authoritative answer to how variables expand at config, but could you try removing the `host` element from that config, forcing beats to guess the node name?

---

<div class="post-metadata">

**Author:** ![Ronin](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ronin](https://discuss.elastic.co/u/Ronin)\
**Post date:** [October 23, 2019, 4:03pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-not-reporting-correct-hostname/204870/3 "2019-10-23T16:03:57Z")

</div>

@pmercado Just tried that and still showing as the pod name.

---

<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:** [November 20, 2019, 4:04pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-not-reporting-correct-hostname/204870/4 "2019-11-20T16:04:02Z")

</div>

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