# Metrics and hostnames

**URL:** <https://discourse.sensu.io/t/metrics-and-hostnames/511>\
**Category:** Sensu Classic (EOL)\
**Created:** [December 3, 2015, 1:02am UTC](https://discourse.sensu.io/t/metrics-and-hostnames/511 "2015-12-03T01:02:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boden\_Garman](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@Boden\_Garman](https://discourse.sensu.io/u/Boden_Garman)\
**Post date:** [December 3, 2015, 1:02am UTC](https://discourse.sensu.io/t/metrics-and-hostnames/511/1 "2015-12-03T01:02:29Z")

</div>

Hi all,

With Sensu 0.21 when I run a metrics check, the value returned includes the full FQDN instead of just the short hostname. Example:

[root@enigma ~]# /opt/sensu/embedded/bin/metrics-disk.rb  
enigma.domain.com.au.disk.xvda.reads 516600 1449103926  
enigma.domain.com.au.disk.xvda.readsMerged 4505 1449103926  
enigma.domain.com.au.disk.xvda.sectorsRead 18770041 1449103926  
[snip]

Is there a way to either make the metrics return only the short hostname, or no hostname at all? With my backend (InfluxDB) each metric is tagged with the hostname so it’s not needed.

Cheers!

---

<div class="post-metadata">

**Author:** ![Boden\_Garman](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@Boden\_Garman](https://discourse.sensu.io/u/Boden_Garman)\
**Post date:** [December 3, 2015, 1:21am UTC](https://discourse.sensu.io/t/metrics-and-hostnames/511/2 "2015-12-03T01:21:01Z")

</div>

Turns out the InfluxDB plugin supports hostname stripping

> **[GitHub - seegno/sensu-influxdb-extension: A sensu handler for sending metrics...](https://github.com/seegno/sensu-influxdb-extension)**
>
> A sensu handler for sending metrics to influxdb. Contribute to seegno/sensu-influxdb-extension development by creating an account on GitHub.

As a workaround I’ve renamed my clients from “host” to “host.domain.com.au”

> **···**
>
> On Thursday, 3 December 2015 12:02:29 UTC+11, Boden Garman wrote:
> 
> > Hi all,
> > 
> > With Sensu 0.21 when I run a metrics check, the value returned includes the full FQDN instead of just the short hostname. Example:
> > 
> > [root@enigma ~]# /opt/sensu/embedded/bin/metrics-disk.rb  
> > enigma.domain.com.au.disk.xvda.reads 516600 1449103926  
> > enigma.domain.com.au.disk.xvda.readsMerged 4505 1449103926  
> > enigma.domain.com.au.disk.xvda.sectorsRead 18770041 1449103926  
> > [snip]
> > 
> > Is there a way to either make the metrics return only the short hostname, or no hostname at all? With my backend (InfluxDB) each metric is tagged with the hostname so it’s not needed.
> > 
> > Cheers!

---

<div class="post-metadata">

**Author:** ![Ludovic\_Francois](https://avatars.discourse-cdn.com/v4/letter/l/c4cdca/32.png) [@Ludovic\_Francois](https://discourse.sensu.io/u/Ludovic_Francois)\
**Post date:** [December 3, 2015, 1:22am UTC](https://discourse.sensu.io/t/metrics-and-hostnames/511/3 "2015-12-03T01:22:32Z")

</div>

Hi Boden,

The metrics-disk.rb gets its default scheme from the hostname command. So in your case I guess your hostname is not configured correctly. Could you show us the return value of these 2 commands please:

# hostname

# hostname --fqdn

Also you can use the --scheme option coming with the sensu plugin. For example you could strip the domain name.

Best Regards,

Ludo

> **···**
>
> On Wed, Dec 2, 2015 at 5:02 PM, Boden Garman [bpgarman@gmail.com](mailto:bpgarman@gmail.com) wrote:
> 
> > Hi all,
> > 
> > With Sensu 0.21 when I run a metrics check, the value returned includes the full FQDN instead of just the short hostname. Example:
> > 
> > [root@enigma ~]# /opt/sensu/embedded/bin/metrics-disk.rb  
> > enigma.domain.com.au.disk.xvda.reads 516600 1449103926  
> > enigma.domain.com.au.disk.xvda.readsMerged 4505 1449103926  
> > enigma.domain.com.au.disk.xvda.sectorsRead 18770041 1449103926  
> > [snip]
> > 
> > Is there a way to either make the metrics return only the short hostname, or no hostname at all? With my backend (InfluxDB) each metric is tagged with the hostname so it’s not needed.
> > 
> > Cheers!
> 
> –
> 
> Ludovic Francois
> 
> Cell: +1 747 220 1444  
> [www.msolution.io](http://www.msolution.io)

---

<div class="post-metadata">

**Author:** ![Boden\_Garman](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@Boden\_Garman](https://discourse.sensu.io/u/Boden_Garman)\
**Post date:** [December 3, 2015, 1:29am UTC](https://discourse.sensu.io/t/metrics-and-hostnames/511/4 "2015-12-03T01:29:15Z")

</div>

Hi Ludovic,

Thanks for the clues! On two different VMs (CentOS 7) both `hostname` and `hostname --fqdn` return the full FQDN.

I’ll check why our VMs are configured this way. Thanks again.

> **···**
>
> On Thursday, 3 December 2015 12:22:33 UTC+11, Ludovic Francois wrote:
> 
> > Hi Boden,
> 
> > The metrics-disk.rb gets its default scheme from the hostname command. So in your case I guess your hostname is not configured correctly. Could you show us the return value of these 2 commands please:
> 
> > # hostname
> 
> > # hostname --fqdn
> 
> > 
> 
> > Also you can use the --scheme option coming with the sensu plugin. For example you could strip the domain name.
> 
> > 
> 
> > Best Regards,
> 
> > Ludo
> 
> > On Wed, Dec 2, 2015 at 5:02 PM, Boden Garman [bpga...@gmail.com](mailto:bpga...@gmail.com) wrote:
> > 
> > > Hi all,
> > > 
> > > With Sensu 0.21 when I run a metrics check, the value returned includes the full FQDN instead of just the short hostname. Example:
> > > 
> > > [root@enigma ~]# /opt/sensu/embedded/bin/metrics-disk.rb  
> > > enigma.domain.com.au.disk.xvda.reads 516600 1449103926  
> > > enigma.domain.com.au.disk.xvda.readsMerged 4505 1449103926  
> > > enigma.domain.com.au.disk.xvda.sectorsRead 18770041 1449103926  
> > > [snip]
> > > 
> > > Is there a way to either make the metrics return only the short hostname, or no hostname at all? With my backend (InfluxDB) each metric is tagged with the hostname so it’s not needed.
> > > 
> > > Cheers!
> 
> > 
> 
> > –  
> > Ludovic Francois
> 
> > Cell: +1 747 220 1444  
> > [www.msolution.io](http://www.msolution.io)

---

<div class="post-metadata">

**Author:** ![Boden\_Garman](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@Boden\_Garman](https://discourse.sensu.io/u/Boden_Garman)\
**Post date:** [December 3, 2015, 1:39am UTC](https://discourse.sensu.io/t/metrics-and-hostnames/511/5 "2015-12-03T01:39:30Z")

</div>

Ah, it looks like the default behavior has changed?

[root@enigma ~]# hostname --version  
hostname 3.13  
[root@enigma ~]# hostname  
enigma.domain.com.au  
[root@enigma ~]# hostname --short  
enigma  
[root@enigma ~]# hostname --fqdn  
enigma.domain.com.au

root@sigma:~# hostname --version  
hostname 3.11  
root@sigma:~# hostname  
sigma  
root@sigma:~# hostname --short  
sigma  
root@sigma:~# hostname --fqdn  
sigma.domain.com.au

Perhaps Sensu should use the `--short` option explicity?

> **···**
>
> On Thursday, 3 December 2015 12:29:16 UTC+11, Boden Garman wrote:
> 
> > Hi Ludovic,
> > 
> > Thanks for the clues! On two different VMs (CentOS 7) both `hostname` and `hostname --fqdn` return the full FQDN.
> > 
> > I’ll check why our VMs are configured this way. Thanks again.
> > 
> > On Thursday, 3 December 2015 12:22:33 UTC+11, Ludovic Francois wrote:
> > 
> > > Hi Boden,
> 
> > > The metrics-disk.rb gets its default scheme from the hostname command. So in your case I guess your hostname is not configured correctly. Could you show us the return value of these 2 commands please:
> 
> > > # hostname
> 
> > > # hostname --fqdn
> 
> > >
> 
> > > Also you can use the --scheme option coming with the sensu plugin. For example you could strip the domain name.
> 
> > >
> 
> > > Best Regards,
> 
> > > Ludo
> 
> > > On Wed, Dec 2, 2015 at 5:02 PM, Boden Garman [bpga...@gmail.com](mailto:bpga...@gmail.com) wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > With Sensu 0.21 when I run a metrics check, the value returned includes the full FQDN instead of just the short hostname. Example:
> > > > 
> > > > [root@enigma ~]# /opt/sensu/embedded/bin/metrics-disk.rb  
> > > > enigma.domain.com.au.disk.xvda.reads 516600 1449103926  
> > > > enigma.domain.com.au.disk.xvda.readsMerged 4505 1449103926  
> > > > enigma.domain.com.au.disk.xvda.sectorsRead 18770041 1449103926  
> > > > [snip]
> > > > 
> > > > Is there a way to either make the metrics return only the short hostname, or no hostname at all? With my backend (InfluxDB) each metric is tagged with the hostname so it’s not needed.
> > > > 
> > > > Cheers!
> 
> > >
> 
> > > –  
> > > Ludovic Francois
> 
> > > Cell: +1 747 220 1444  
> > > [www.msolution.io](http://www.msolution.io)
