I'm using collectd with the snmp and write_graphite plugins. I want certain metrics to go to Graphite with prefix A, and others to go with prefix B, to keep the data in Graphite/Whisper organized.

For example, I would like to divide things up like this:

network.switches.xxxx power.pdu.xxxxxx

My write_graphite config looks like this:

<Plugin write_graphite>
  <Node "mygraphitehost">
    Host "mygraphitehost"
    Port "2003"
    Protocol "tcp"
    LogSendErrors true
    Prefix "network."
    Postfix "-collectd"
  </Node>
</Plugin>

This causes everything I gather with the snmp plugin show up under the "network" folder in the Graphite web interface. Is running multiple collectds with different configs/init scripts the only way to solve this?

It looks like the collectD Hashed Match might be what you are looking for:

https://collectd.org/wiki/index.php/Match:Hashed/Config

You obviously don't have multiple graphite servers, but it looks like you can use pattern matching to send metrics to the different servers, which in your case would have the same "host" value but the prefix value could be different.

  • Match:Hashed is close, but it's for load balancing. If you were going to use a Match plugin, you should use Match:RegEx, but I still think that's the longer way around. See my EscapeCharacter work-around. – jnovack Sep 3 '14 at 21:13

To use "advanced mode" where you specify your path exactly, set the EscapeCharacter to ".".

<Plugin write_graphite>
  EscapeCharacter "."
</Plugin>

CAUTION: When you do this, you are effectively writing new keys for everything on that host.

To make sure the host's keys stay the same, manually set the hostname at the top of /etc/collectd.conf

Hostname    "thishost_mydomain_net"

Then you can edit all your hosts within /etc/collectd.d/snmp.conf (or wherever you store them) to put them down the tree exactly where you want them.

<Host "network.switches.core-router">
  Address "10.1.1.1"
  Version 2
  Community "public"
  Collect "snmp_dataset1"
</Host>
<Host "network.switches.accounting">
  Address "10.1.1.2"
  Version 2
  Community "public"
  Collect "snmp_dataset2"
</Host>

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.