# Unable to get event host.name in Metricbeat

**URL:** <https://discuss.elastic.co/t/unable-to-get-event-host-name-in-metricbeat/301490>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [April 4, 2022, 10:09am UTC](https://discuss.elastic.co/t/unable-to-get-event-host-name-in-metricbeat/301490 "2022-04-04T10:09:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)\
**Post date:** [April 4, 2022, 10:09am UTC](https://discuss.elastic.co/t/unable-to-get-event-host-name-in-metricbeat/301490/1 "2022-04-04T10:09:26Z")

</div>

Hello All,

I've written a javascript script processor in which I'm trying to get only those mount points which have reached thrshold greater than some value,ex:greater than 90 %[kibana-\>panel filter-\> field \> 0.9],The challenge I'm facing is that I'm unable to get host.name event value in index from custom script written.  
The filed I need is fieldname:mountpoint hostname,here "host.name" value shows as "null" .

```auto

var console = require('console');
function process(event) {
     var fileSystemUsedPercent = event.Get("system.filesystem.used.pct");//filesystem used percentage
     console.info("File system used percentage value [%s]", fileSystemUsedPercent);
     var mountPoint = event.Get("system.filesystem.mount_point"); //mountpoint name                                    
     console.info("mountPoint [%s]", mountPoint);
	   var hostName = event.Get("host.name"); //hostname                               
     console.info("hostName [%s]", hostName);
     if(fileSystemUsedPercent > 0.8) {
		     event.Put("filesystem.status","critical");
         event.Put("filesystem.mount.host",mountPoint + ' ' + hostName);//display hostname and mountpoint if greater than treshold
         console.info("filesystem.status [%s]", event.Get("filesystem.status"));
     } 
     
     
     return event;
 }

```

* * *

```auto
2022-04-04T11:11:54.237+0200	INFO	[processor.javascript]	console/console.go:50	File system used percentage value [0.1029]
2022-04-04T11:11:54.238+0200	INFO	[processor.javascript]	console/console.go:50	mountPoint [/run]
2022-04-04T11:11:54.238+0200	INFO	[processor.javascript]	console/console.go:50	**hostName [null]**
2022-04-04T11:11:54.238+0200	INFO	[processor.javascript]	console/console.go:50	filesystem.status [critical]

```

metricbeat.yml

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.ilm.enabled: true
setup.ilm.check_exists: true
setup.ilm.rollover_alias: mis-metric
setup.ilm.pattern: '{now/d}-000001'
setup.ilm.overwrite: false
setup.kibana:
  host: http://td06appl002.dev.dm01.group.v:5601
output.elasticsearch:
  hosts:
  - http://td06appl002.dev.dm01.group.v:9200
processors:
- add_fields:
    fields:
        configfile: ${DM_SHARED}/MIS/globalconfiguration.properties
- rename:
    fields:
    - from: agent.hostname
      to: host.name
    ignore_missing: true
    fail_on_error: false
- drop_fields:
    fields:
    - host.mac
 # - system.process.cmdline
    - ecs
    - agent.ephemeral_id
    - agent.type
    - agent.version
    - agent.hostname
    - event
monitoring.enabled: true
monitoring.elasticsearch: null
#logging.level: debug

type or paste code here

```

what could be reason I'm unbale to get hostname,"filesystem.mount.host",mountPoint + ' ' + hostNam(JS script)

Note:I just want to show critical mountpoint usage with there hostname and percentage consumed,here even in panel filter system.filesystem.used.pct \> 0.8 dosent't work according to needs,end result is display only critical with red bar .

Thanks

 ![rone](https://us1.discourse-cdn.com/elastic/original/3X/7/5/75ef09d99c5225ddcd37116880535cf51bb8a05e.png)  
 ![rthree](https://us1.discourse-cdn.com/elastic/original/3X/f/e/fefcf6df85131d55b3623ddd206653d838d3f586.png)  
 ![rtwo](https://us1.discourse-cdn.com/elastic/original/3X/6/8/68291c017f1e42950bbdcb59c544d1ca74ce7be4.png)

---

<div class="post-metadata">

**Author:** ![PRASHANT\_MEHTA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_mehta/32/101764_2.png) [@PRASHANT\_MEHTA](https://discuss.elastic.co/u/PRASHANT_MEHTA)\
**Post date:** [April 21, 2022, 9:57am UTC](https://discuss.elastic.co/t/unable-to-get-event-host-name-in-metricbeat/301490/2 "2022-04-21T09:57:46Z")

</div>

@Kaiyan_Sheng@shaunak an you plz help or guide on this?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/6/96d29332a2e545adca2012bbd6c9f81e01cc20e7.png)

---

<div class="post-metadata">

**Author:** ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)\
**Post date:** [May 4, 2022, 6:25pm UTC](https://discuss.elastic.co/t/unable-to-get-event-host-name-in-metricbeat/301490/3 "2022-05-04T18:25:28Z")

</div>

Maybe @Alex_Kristiansen can help here 🙂

---

<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 1, 2022, 8:26pm UTC](https://discuss.elastic.co/t/unable-to-get-event-host-name-in-metricbeat/301490/4 "2022-06-01T20:26:02Z")

</div>

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