Telegraf ports with running multiple instances


#1

Hey guys,

I’m using TCP to ship the various system metrics using a specific port. As I’m running multiple telegraf instances on a single server, I found there is a field ‘port’ shipped showing different values for each telegraf instance, which is 5-digit number like 539xx. Can I understand this is telegraf port number? Acutally I’m doing some performance test for the telegraf and wondering this way of running multiple instances would give me rough ideas about the performance. I don’t care about the data duplication and consider the CPU usage increase with many instances running on a single server.

Thanks!


#2

@Ray_Chang Sorry, I don’t understand what your question is, can you explain a little more what you are trying to determine?


#3

In short, telegraf looks like sending a field named ‘port’ in tags (or somewhere). What is this for? Is this used for each telegraf instance running on the server?


#4

There aren’t any port tags that are sent on a global level, but there are some input plugins which have port tags. An example is the nginx input.

If you tell me which plugins you have enabled maybe we can figure out where it is coming from.


#5

I tested that it’s not related to any input plugins I’m using. But I found it’s coming when I use tcp for socket_writer. If I use udp the port does not come. The ports I get from the telegraf instances are different from the one I specified in the tcp output plugin. Does this make sense?


#6

I don’t see where in the code this would be added, can you isolate it to a minimal config and post it here?


#7

I’m using logstash to receive the telgraf metrics. It looks like logstash sends the ‘port’ number as it communicates with the telegraf.

Telegraf

[[inputs.mem]]

[[outputs.socket_writer]]
address = "tcp://10.0.0.24:2004"
data_format = “json”

Logstash conf

input {
tcp {
port => 2004
codec => json {}
}
}
filter {}
output {
stdout { codec => rubydebug }
}

This is an example event of output from logstash.

{
"@timestamp" => 2017-09-12T20:12:41.301Z,
“port” => 35914,
“name” => “mem”,
"@version" => “1”,
“host” => “10.0.0.48”,
“fields” => {
“total” => 16657846272,
“inactive” => 1562255360,
“available_percent” => 79.62598635752376,
“cached” => 4842885120,
“available” => 13263974400,
“buffered” => 153481216,
“active” => 5500370944,
“used_percent” => 20.374013642476243,
“used” => 3393871872,
“free” => 8965939200
},
“tags” => {
“host” => “db0.local”
},
“timestamp” => 1505247161
}