Telegraf - get data from multiple Monit instances

I’m looking to collect data from multiple machines all running monit. Can I do this, the config seems to only allow one target.

[[inputs.monit]]
  ## Monit HTTPD address
  address = "http://127.0.0.1:2812"
  ## Username and Password for Monit
  # username = ""
  # password = ""

I don’t know how the plugin works, but you can create as many [[inputs.monit]] sections as you want, in this case, one for each machine should work.

[[inputs.monit]]
  address = 'http://aaaaa'

[[inputs.monit]]
  address = 'http://bbbbb'

Thanks. Seemed too obvious. How then is the data differentiated within InfluxDB I wonder. Might is use the host name?

I have had a look at the plugin and as far as I can see there is nothing to differentiate between the data from the 2 hosts. I could be wrong though :laughing:.

Telegraf can add the hostname to the metrics it gathers, but ofc the hostname of the local machine, there fore is useless in your case…
You can specify it manually in the configuration itself tho.

[[inputs.monit]]
  address = 'http://aaaaa'
  [inputs.monit.tags]
    machine = "aaaaa"

[[inputs.monit]]
  address = 'http://bbbbb'
  [inputs.monit.tags]
    machine= "bbbbbb"
1 Like

Ok thanks

Can the name of the tag be anything (you use ‘machine’ e.g.

[[inputs.monit]]
  address = 'http://bbbbb'
  [inputs.monit.tags]
    mytagname= "bbbbbb"

Is this documented anywhere?

[edit]
Ah found it - not sure it would have helped me if I had read it as it is though. telegraf/CONFIGURATION.md at master · influxdata/telegraf · GitHub

For anyone else looking for this answer, using a tag, puts it inside the default measurement (hope I got the term right)

If you use name_override it creates a specific measurement (which is what I’d like really).

Thanks for your help.

1 Like