From 9b489a43eb7dde4694f0fc55b9879af9c846f1fa Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 5 Jul 2018 15:37:13 -0600 Subject: [PATCH] Use 'localhost' as default 'server' tag in zookeeper input (#4387) (cherry picked from commit a82b4fbd96b62baddb61adf1414a32578b606c31) --- plugins/inputs/zookeeper/dev/docker-compose.yml | 17 +++++++++++++++++ plugins/inputs/zookeeper/dev/telegraf.conf | 9 +++++++++ plugins/inputs/zookeeper/zookeeper.go | 8 +++++++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 plugins/inputs/zookeeper/dev/docker-compose.yml create mode 100644 plugins/inputs/zookeeper/dev/telegraf.conf diff --git a/plugins/inputs/zookeeper/dev/docker-compose.yml b/plugins/inputs/zookeeper/dev/docker-compose.yml new file mode 100644 index 000000000..7a4f9bf80 --- /dev/null +++ b/plugins/inputs/zookeeper/dev/docker-compose.yml @@ -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 diff --git a/plugins/inputs/zookeeper/dev/telegraf.conf b/plugins/inputs/zookeeper/dev/telegraf.conf new file mode 100644 index 000000000..ac76b2a7f --- /dev/null +++ b/plugins/inputs/zookeeper/dev/telegraf.conf @@ -0,0 +1,9 @@ +[agent] + interval="1s" + flush_interval="1s" + +[[inputs.zookeeper]] + servers = [":2181"] + +[[outputs.file]] + files = ["stdout"] diff --git a/plugins/inputs/zookeeper/zookeeper.go b/plugins/inputs/zookeeper/zookeeper.go index 20e7aee01..ad990f28c 100644 --- a/plugins/inputs/zookeeper/zookeeper.go +++ b/plugins/inputs/zookeeper/zookeeper.go @@ -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{ - "server": service[0], + "server": srv, "port": service[1], "state": zookeeper_state, }