diff --git a/kafka_exporter.go b/kafka_exporter.go index 8ce27de8..038edc1e 100644 --- a/kafka_exporter.go +++ b/kafka_exporter.go @@ -98,7 +98,7 @@ type kafkaOpts struct { tlsInsecureSkipTLSVerify bool kafkaVersion string useZooKeeperLag bool - uriZookeeper []string + uriZookeeper string labels string metadataRefreshInterval string serviceName string @@ -236,7 +236,7 @@ func NewExporter(opts kafkaOpts, topicFilter string, groupFilter string) (*Expor if opts.useZooKeeperLag { glog.V(DEBUG).Infoln("Using zookeeper lag, so connecting to zookeeper") - zookeeperClient, err = kazoo.NewKazoo(opts.uriZookeeper, nil) + zookeeperClient, err = kazoo.NewKazooFromConnectionString(opts.uriZookeeper, nil) if err != nil { return nil, errors.Wrap(err, "error connecting to zookeeper") } @@ -726,7 +726,7 @@ func main() { toFlagBoolVar("tls.insecure-skip-tls-verify", "If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.", false, "false", &opts.tlsInsecureSkipTLSVerify) toFlagStringVar("kafka.version", "Kafka broker version", sarama.V2_0_0_0.String(), &opts.kafkaVersion) toFlagBoolVar("use.consumelag.zookeeper", "if you need to use a group from zookeeper", false, "false", &opts.useZooKeeperLag) - toFlagStringsVar("zookeeper.server", "Address (hosts) of zookeeper server.", "localhost:2181", &opts.uriZookeeper) + toFlagStringVar("zookeeper.server", "Address (hosts) of zookeeper server.", "localhost:2181", &opts.uriZookeeper) toFlagStringVar("kafka.labels", "Kafka cluster name", "", &opts.labels) toFlagStringVar("refresh.metadata", "Metadata refresh interval", "30s", &opts.metadataRefreshInterval) toFlagBoolVar("offset.show-all", "Whether show the offset/lag for all consumer group, otherwise, only show connected consumer groups", true, "true", &opts.offsetShowAll) diff --git a/simple_test.go b/simple_test.go index e3f94183..4a4969a0 100644 --- a/simple_test.go +++ b/simple_test.go @@ -2,12 +2,13 @@ package main import ( "errors" - "github.com/Shopify/sarama" "io/ioutil" "log" "net/http" "testing" "time" + + "github.com/Shopify/sarama" ) var bootstrap_servers = []string{"localhost:9092"} @@ -65,7 +66,7 @@ func execute(handler func(response *http.Response)) { func runServer() { opts := kafkaOpts{} opts.uri = bootstrap_servers - opts.uriZookeeper = []string{"localhost:2181"} + opts.uriZookeeper = "localhost:2181" opts.kafkaVersion = sarama.V1_0_0_0.String() opts.metadataRefreshInterval = "30s" setup("localhost:9304", "/metrics", ".*", ".*", false, opts, nil)