# Metricbeat on kubernetes ,field beat.hostname got the pod name and no the host name

**URL:** <https://discuss.elastic.co/t/metricbeat-on-kubernetes-field-beat-hostname-got-the-pod-name-and-no-the-host-name/164438>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [January 16, 2019, 10:13am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-field-beat-hostname-got-the-pod-name-and-no-the-host-name/164438 "2019-01-16T10:13:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nchap](https://avatars.discourse-cdn.com/v4/letter/n/ba9def/32.png) [@nchap](https://discuss.elastic.co/u/nchap)\
**Post date:** [January 16, 2019, 10:13am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-field-beat-hostname-got-the-pod-name-and-no-the-host-name/164438/1 "2019-01-16T10:13:10Z")

</div>

Hi everybody, i have install the elasticseach, kibana, filebeat and metricbeat on a aks cluster using helm.  
But for the metricbeat who collect the state metric, on the field "beat.hostname" the value is the pod name and create some "false" stat in dashboard and on infrastructure view.

I saw that some people got this issue too --\> [here](https://github.com/elastic/beats-docker/issues/3)

So i try to add the env variable to "force" the hostname but it doesn't work.  
I use this helm chart [https://github.com/helm/charts/tree/master/stable/metricbeat](https://github.com/helm/charts/tree/master/stable/metricbeat)  
this is my value file for the metricbeat chart :

```
image:
  tag: 6.5.4

# The instances created by daemonset retrieve most metrics from the host
daemonset:
  podAnnotations: []
  tolerations:
  - key: node-role.kubernetes.io/master
    operator: Exists
    effect: NoSchedule
  nodeSelector: {}
  config:
    metricbeat.config:
      modules:
        path: ${path.config}/modules.d/*.yml
        reload.enabled: true
    output.file:
      enabled: false
    output.elasticsearch:
      hosts: ["elasticsearch-client"]
    setup.dashboards.enabled: true
    setup.kibana:
      host: "kibana:443"
  modules:
    system:
      enabled: true
      config:
        - module: system
          period: 10s
          metricsets:
            - cpu
            - load
            - memory
            - network
            - process
            - process_summary
            - core
            - diskio
            - socket
            - raid # Raid
          processes: ['.*']
          process.include_top_n:
            by_cpu: 5 # include top 5 processes by CPU
            by_memory: 5 # include top 5 processes by memory
        - module: system
          period: 1m
          metricsets:
            - filesystem
            - fsstat
          processors:
          - drop_event.when.regexp:
              system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'
          - add_kubernetes_metadata:
              in_cluster: true
    kubernetes:
      enabled: true
      config:
        - module: kubernetes
          metricsets:
            - node
            - system
            - pod
            - container
            - volume
            - event
            - apiserver
          period: 10s
          host: ${NODE_NAME}
          hosts: ["localhost:10255"]
          processors:
          - add_kubernetes_metadata:
              in_cluster: true

    docker:
      enabled: true
      config:
        - module: docker
          metricsets:
            - container
            - cpu
            - diskio
            - healthcheck
            - info
            - memory
            - network
          hosts: ["unix:///var/run/docker.sock"]
          period: 10s
          enabled: true
          processors:
            - add_kubernetes_metadata:
                in_cluster: true

# The instance created by deployment retrieves metrics that are unique for the whole cluster, like Kubernetes events or kube-state-metrics
deployment:
  podAnnotations: []
  tolerations: []
  nodeSelector: {}
  config:
    metricbeat.config:
      modules:
        path: ${path.config}/modules.d/*.yml
        reload.enabled: false
    output.file:
      enabled: false
    output.elasticsearch:
      hosts: ["elasticsearch-client"]
  modules:
    kubernetes:
      enabled: true
      config:
        - module: kubernetes
          metricsets:
            - state_node
            - state_deployment
            - state_replicaset
            - state_pod
            - state_container
          period: 10s
          processors:
            - add_kubernetes_metadata:
                in_cluster: true
          host: ${NODE_NAME}
          hosts: ["kube-state-metrics:8080"]

extraEnv:
 - name: NODE_NAME
   valueFrom:
     fieldRef:
       fieldPath: spec.nodeName

```

The issue is for the pod deployed by the deployment, the other deployed by the daemon set work very well  
I see in my container that the env variable NODE\_NAME is well configured but my HOSTNAME is the pod name.

I add some capture to visualize the problem.

 ![09](https://us1.discourse-cdn.com/elastic/original/3X/b/7/b7576cc09a87d54b73a6f1ddd54d1f02e2effa81.png) ![29](https://us1.discourse-cdn.com/elastic/original/3X/8/1/81bab78f4b264f27769bf052e74746afd510de75.png)

Thanks for your help

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [January 16, 2019, 10:37am UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-field-beat-hostname-got-the-pod-name-and-no-the-host-name/164438/2 "2019-01-16T10:37:30Z")

</div>

Hi @nchap,

We normally recommend using `hostNetwork: true`, see our reference manifests: [https://github.com/elastic/beats/tree/master/deploy/kubernetes/metricbeat](https://github.com/elastic/beats/tree/master/deploy/kubernetes/metricbeat).

That way, Metricbeat will have access to the underlying hostname.

Best regards

---

<div class="post-metadata">

**Author:** ![nchap](https://avatars.discourse-cdn.com/v4/letter/n/ba9def/32.png) [@nchap](https://discuss.elastic.co/u/nchap)\
**Post date:** [January 16, 2019, 12:52pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-field-beat-hostname-got-the-pod-name-and-no-the-host-name/164438/3 "2019-01-16T12:52:12Z")

</div>

Hi @exekias, thanks for your quick reply ! It's work perfectly after added it !  
I didn't notice that in the helm chart, this option was not enable by default.

Thanks a lot,  
have a good day !

---

<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:** [February 13, 2019, 12:52pm UTC](https://discuss.elastic.co/t/metricbeat-on-kubernetes-field-beat-hostname-got-the-pod-name-and-no-the-host-name/164438/4 "2019-02-13T12:52:15Z")

</div>

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