Use 'localhost' as default 'server' tag in zookeeper input (#4387)

This commit is contained in:
Greg 2018-07-05 15:37:13 -06:00 committed by Daniel Nelson
parent f5f9fa2095
commit a82b4fbd96
3 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,17 @@
version: '3'
services:
zoo:
image: zookeeper
telegraf:
image: glinton/scratch
volumes:
- ./telegraf.conf:/telegraf.conf
- ../../../../telegraf:/telegraf
depends_on:
- zoo
entrypoint:
- /telegraf
- --config
- /telegraf.conf
network_mode: service:zoo

View File

@ -0,0 +1,9 @@
[agent]
interval="1s"
flush_interval="1s"
[[inputs.zookeeper]]
servers = [":2181"]
[[outputs.file]]
files = ["stdout"]

View File

@ -158,8 +158,14 @@ func (z *Zookeeper) gatherServer(ctx context.Context, address string, acc telegr
} }
} }
} }
srv := "localhost"
if service[0] != "" {
srv = service[0]
}
tags := map[string]string{ tags := map[string]string{
"server": service[0], "server": srv,
"port": service[1], "port": service[1],
"state": zookeeper_state, "state": zookeeper_state,
} }