Prometheus exporter for Zookeeper

zookeeper_exporter CircleCI DockerHub

A Prometheus exporter for Zookeeper 3.4+. It send the mntr command to a Zookeeper node and converts the output to Prometheus format.

Usage

Download the latest release, pull the Docker image or follow the instructions below for building the source.

There is a -help flag for listing the available flags.

Building from source

go get -u github.com/carlpett/zookeeper_exporter and then make build.

Limitations

Due to the type of data exposed by Zookeeper's mntr command, it currently resets Zookeeper's internal statistics every time it is scraped. This makes it unsuitable for having multiple parallel scrapers.

Comments
  • panic: runtime error: index out of range

    panic: runtime error: index out of range

    I have a zk cluster with 5 nodes. I deployed zookeeper_exporter to all nodes, using command

    sudo nohup path_to_zookeeper_exporter &
    

    with no additional arguements. I frequently encounter the following bug(exporter crashed):

    time="2017-08-24T16:09:29+08:00" level=info msg="Starting zookeeper_exporter"
    time="2017-08-24T16:09:29+08:00" level=info msg="Starting metric http endpoint on :9141"
    time="2017-08-24T16:09:34+08:00" level=info msg="Fetching metrics from Zookeeper"
    panic: runtime error: index out of range
    
    goroutine 31 [running]:
    main.(*zookeeperCollector).Collect(0xc420011ec0, 0xc420148360)
            /home/qunheadmin/go/src/github.com/carlpett/zookeeper_exporter/zookeeper.go:154 +0x59d
    github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2(0xc4200fa400, 0xc420148360, 0x8978e0, 0xc420011ec0)
            /home/qunheadmin/go/src/github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:433 +0x61
    created by github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather
            /home/qunheadmin/go/src/github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:434 +0x2ec
    time="2017-08-24T16:15:29+08:00" level=info msg="Starting zookeeper_exporter"
    time="2017-08-24T16:15:29+08:00" level=info msg="Starting metric http endpoint on :9141"
    time="2017-08-24T16:15:34+08:00" level=info msg="Fetching metrics from Zookeeper"
    panic: runtime error: index out of range
    
    goroutine 52 [running]:
    main.(*zookeeperCollector).Collect(0xc4200fa7c0, 0xc42005e9c0)
            /home/qunheadmin/go/src/github.com/carlpett/zookeeper_exporter/zookeeper.go:154 +0x59d
    github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2(0xc420011b00, 0xc42005e9c0, 0x8978e0, 0xc4200fa7c0)
            /home/qunheadmin/go/src/github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:433 +0x61
    created by github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather
            /home/qunheadmin/go/src/github.com/carlpett/zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:434 +0x2ec
    

    Sometimes this bug occurs right after I start exporter. Sometimes it occurs after a long period(more than one day).

    Any thoughts about this? Thanks.

  • Go Build is failing while trying build

    Go Build is failing while trying build

    Hi I am getting following error while I am doing go build

    • go build prometheus-zookeeper_exporter ./main.go:11:2: imported and not used: prometheus-zookeeper_exporter/vendor/github.com/prometheus/client_golang/prometheus/promhttp" ./main.go:69:28: undefined: prometheus.Handler

    Could you please look suggest me changes I am just making binary out of your main.go file using Jenkins ?

  • How to connect to multiple zookeeper nodes

    How to connect to multiple zookeeper nodes

    Hi calpett, thanks for your exporter! I have 3 zookeeper nodes a1:2181 a2:2181 a3:2181, and here is the command

    ./zookeeper_exporter -bind-addr ":19141" -log-level "debug" -zookeeper "a1:2181"
    

    I found the metrics

    zk_server_state{state="follower"} 1
    # HELP zk_up Exporter successful
    # TYPE zk_up gauge
    zk_up 1  
    

    I thought it means the a1:2181 was up. How could I know if all of my zk nodes were up? Thanks for your reply!

  • Exporter still exports even if Zookeeper is unavailable

    Exporter still exports even if Zookeeper is unavailable

    The exporter is maintaining the metric zk_up to indicate if scraping was successful or not. This is somewhat duplicating the Prometheus built-in up metric that is automatically defined for each scrape target.

    I believe that this exporter should return a HTTP status code 502 to indicate scraping has failed. As a user of this exporter I could then rely on my generalised up alert without having to define a special alert just for Zookeeper.

  • Sending four letter word `mntr`  Fetching metrics from Zookeeper failed

    Sending four letter word `mntr` Fetching metrics from Zookeeper failed

    Zookeeper version: 3.4.13

    $ kubectl logs -f zookeeper-exporter-5f46f7844c-4vd7x -n monitoring
    time="2019-12-17T10:01:46Z" level=info msg="zookeeper_exporter, version v1.0.2-5 (branch: master, revision: d6e929223f6b3bf5ff25dd0340e8194cbd4d04fc)\n  build user:       @7ca24aeafeed\n  build date:       2019-12-17T10:00:21+0000\n  go version:       go1.10.8"
    time="2019-12-17T10:01:46Z" level=info msg="Starting zookeeper_exporter"
    time="2019-12-17T10:01:46Z" level=info msg="Starting metric http endpoint on :9141"
    time="2019-12-17T10:01:52Z" level=info msg="Fetching metrics from Zookeeper"
    time="2019-12-17T10:01:52Z" level=debug msg="Connecting to Zookeeper at zk-client.lateinos.svc:2181"
    time="2019-12-17T10:01:52Z" level=debug msg="Sending four letter word" command=mntr
    time="2019-12-17T10:01:57Z" level=info msg="Fetching metrics from Zookeeper"
    time="2019-12-17T10:01:57Z" level=debug msg="Connecting to Zookeeper at zk-client.lateinos.svc:2181"
    time="2019-12-17T10:01:57Z" level=debug msg="Sending four letter word" command=mntr
    time="2019-12-17T10:01:57Z" level=error msg="Error parsing response from Zookeeper" error="read tcp 10.32.0.230:35546->192.168.21.2:2181: i/o timeout"
    time="2019-12-17T10:01:57Z" level=error msg="Failed to fetch metrics"
    time="2019-12-17T10:01:57Z" level=info msg="Fetching metrics from Zookeeper"
    time="2019-12-17T10:01:57Z" level=debug msg="Connecting to Zookeeper at zk-client.lateinos.svc:2181"
    time="2019-12-17T10:01:57Z" level=debug msg="Sending four letter word" command=mntr
    time="2019-12-17T10:02:00Z" level=info msg="Fetching metrics from Zookeeper"
    time="2019-12-17T10:02:00Z" level=debug msg="Connecting to Zookeeper at zk-client.lateinos.svc:2181"
    time="2019-12-17T10:02:00Z" level=debug msg="Sending four letter word" command=mntr
    time="2019-12-17T10:02:02Z" level=error msg="Error parsing response from Zookeeper" error="read tcp 10.32.0.230:35618->192.168.21.2:2181: i/o timeout"
    time="2019-12-17T10:02:02Z" level=error msg="Failed to fetch metrics"
    time="2019-12-17T10:02:02Z" level=error msg="Error parsing response from Zookeeper" error="read tcp 10.32.0.230:35636->192.168.21.2:2181: i/o timeout"
    time="2019-12-17T10:02:02Z" level=error msg="Failed to fetch metrics"
    time="2019-12-17T10:02:05Z" level=error msg="Error parsing response from Zookeeper" error="read tcp 10.32.0.230:35696->192.168.21.2:2181: i/o timeout"
    time="2019-12-17T10:02:05Z" level=error msg="Failed to fetch metrics"
    
    
  • RE: Limitations

    RE: Limitations

    RE: https://github.com/carlpett/zookeeper_exporter/blob/master/README.md#limitations

    Does this mean that I should not run the exporter once for every ZK node, or does it mean I should not run the exporter multiple times per ZK node?

    EDIT: I've tried running it once per cluster, but without a mechanism to poll the leader, my graphs have gaps where leader wasn't the destination (load balancer in front of zk). It would be nice to use zookeeper discovery to identify the leader before polling it.

  • Please add a license file

    Please add a license file

    This repository does not ship a license file. It is therefore not clear if it can be used freely.

    Prometheus is licensed under Apache 2.0. I would therefore propose to use the same license here as well.

    Thanks, Stephan

  • no zk_* items

    no zk_* items

    # HELP go_gc_duration_seconds A summary of the GC invocation durations.
    # TYPE go_gc_duration_seconds summary
    go_gc_duration_seconds{quantile="0"} 0
    go_gc_duration_seconds{quantile="0.25"} 0
    go_gc_duration_seconds{quantile="0.5"} 0
    go_gc_duration_seconds{quantile="0.75"} 0
    go_gc_duration_seconds{quantile="1"} 0
    go_gc_duration_seconds_sum 0
    go_gc_duration_seconds_count 0
    # HELP go_goroutines Number of goroutines that currently exist.
    # TYPE go_goroutines gauge
    go_goroutines 16
    # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
    # TYPE go_memstats_alloc_bytes gauge
    go_memstats_alloc_bytes 1.984552e+06
    # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
    # TYPE go_memstats_alloc_bytes_total counter
    go_memstats_alloc_bytes_total 1.984552e+06
    # HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
    # TYPE go_memstats_buck_hash_sys_bytes gauge
    go_memstats_buck_hash_sys_bytes 1.443527e+06
    # HELP go_memstats_frees_total Total number of frees.
    # TYPE go_memstats_frees_total counter
    go_memstats_frees_total 484
    # HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
    # TYPE go_memstats_gc_sys_bytes gauge
    go_memstats_gc_sys_bytes 202752
    # HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
    # TYPE go_memstats_heap_alloc_bytes gauge
    go_memstats_heap_alloc_bytes 1.984552e+06
    # HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
    # TYPE go_memstats_heap_idle_bytes gauge
    go_memstats_heap_idle_bytes 409600
    # HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
    # TYPE go_memstats_heap_inuse_bytes gauge
    go_memstats_heap_inuse_bytes 3.162112e+06
    # HELP go_memstats_heap_objects Number of allocated objects.
    # TYPE go_memstats_heap_objects gauge
    go_memstats_heap_objects 7332
    # HELP go_memstats_heap_released_bytes_total Total number of heap bytes released to OS.
    # TYPE go_memstats_heap_released_bytes_total counter
    go_memstats_heap_released_bytes_total 0
    # HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
    # TYPE go_memstats_heap_sys_bytes gauge
    go_memstats_heap_sys_bytes 3.571712e+06
    # HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
    # TYPE go_memstats_last_gc_time_seconds gauge
    go_memstats_last_gc_time_seconds 0
    # HELP go_memstats_lookups_total Total number of pointer lookups.
    # TYPE go_memstats_lookups_total counter
    go_memstats_lookups_total 39
    # HELP go_memstats_mallocs_total Total number of mallocs.
    # TYPE go_memstats_mallocs_total counter
    go_memstats_mallocs_total 7816
    # HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
    # TYPE go_memstats_mcache_inuse_bytes gauge
    go_memstats_mcache_inuse_bytes 6944
    # HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
    # TYPE go_memstats_mcache_sys_bytes gauge
    go_memstats_mcache_sys_bytes 16384
    # HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
    # TYPE go_memstats_mspan_inuse_bytes gauge
    go_memstats_mspan_inuse_bytes 35112
    # HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
    # TYPE go_memstats_mspan_sys_bytes gauge
    go_memstats_mspan_sys_bytes 49152
    # HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
    # TYPE go_memstats_next_gc_bytes gauge
    go_memstats_next_gc_bytes 4.473924e+06
    # HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
    # TYPE go_memstats_other_sys_bytes gauge
    go_memstats_other_sys_bytes 1.042993e+06
    # HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
    # TYPE go_memstats_stack_inuse_bytes gauge
    go_memstats_stack_inuse_bytes 622592
    # HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
    # TYPE go_memstats_stack_sys_bytes gauge
    go_memstats_stack_sys_bytes 622592
    # HELP go_memstats_sys_bytes Number of bytes obtained by system. Sum of all system allocations.
    # TYPE go_memstats_sys_bytes gauge
    go_memstats_sys_bytes 6.949112e+06
    # HELP http_request_duration_microseconds The HTTP request latencies in microseconds.
    # TYPE http_request_duration_microseconds summary
    http_request_duration_microseconds{handler="prometheus",quantile="0.5"} 49158.369
    http_request_duration_microseconds{handler="prometheus",quantile="0.9"} 49158.369
    http_request_duration_microseconds{handler="prometheus",quantile="0.99"} 49158.369
    http_request_duration_microseconds_sum{handler="prometheus"} 49158.369
    http_request_duration_microseconds_count{handler="prometheus"} 1
    # HELP http_request_size_bytes The HTTP request sizes in bytes.
    # TYPE http_request_size_bytes summary
    http_request_size_bytes{handler="prometheus",quantile="0.5"} 213
    http_request_size_bytes{handler="prometheus",quantile="0.9"} 213
    http_request_size_bytes{handler="prometheus",quantile="0.99"} 213
    http_request_size_bytes_sum{handler="prometheus"} 213
    http_request_size_bytes_count{handler="prometheus"} 1
    # HELP http_requests_total Total number of HTTP requests made.
    # TYPE http_requests_total counter
    http_requests_total{code="200",handler="prometheus",method="get"} 1
    # HELP http_response_size_bytes The HTTP response sizes in bytes.
    # TYPE http_response_size_bytes summary
    http_response_size_bytes{handler="prometheus",quantile="0.5"} 1456
    http_response_size_bytes{handler="prometheus",quantile="0.9"} 1456
    http_response_size_bytes{handler="prometheus",quantile="0.99"} 1456
    http_response_size_bytes_sum{handler="prometheus"} 1456
    http_response_size_bytes_count{handler="prometheus"} 1
    # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
    # TYPE process_cpu_seconds_total counter
    process_cpu_seconds_total 0
    # HELP process_max_fds Maximum number of open file descriptors.
    # TYPE process_max_fds gauge
    process_max_fds 65535
    # HELP process_open_fds Number of open file descriptors.
    # TYPE process_open_fds gauge
    process_open_fds 10
    # HELP process_resident_memory_bytes Resident memory size in bytes.
    # TYPE process_resident_memory_bytes gauge
    process_resident_memory_bytes 4.780032e+06
    # HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
    # TYPE process_start_time_seconds gauge
    process_start_time_seconds 1.59909754567e+09
    # HELP process_virtual_memory_bytes Virtual memory size in bytes.
    # TYPE process_virtual_memory_bytes gauge
    process_virtual_memory_bytes 1.4000128e+07
    # HELP zk_up Exporter successful
    # TYPE zk_up gauge
    zk_up 0
    # HELP zookeeper_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which zookeeper_exporter was built.
    # TYPE zookeeper_exporter_build_info gauge
    zookeeper_exporter_build_info{branch="HEAD",goversion="go1.10.8",revision="0e30f3afdcb8e36be1b2a41fa432f4626012e5c0",version="v1.1.0"} 1
    
  • make build failed

    make build failed

    Steps to reproduce:

    1. git clone [email protected]:carlpett/zookeeper_exporter.git
    2. cd zookeeper_exporter
    3. make build

    Output:

    # _/Users/kormotodor/zookeeper_exporter
    ./main.go:73:28: undefined: prometheus.Handler
    make: *** [build] Error 2
    

    go version:

    go version go1.14.4 darwin/amd64
    

    go env:

    GO111MODULE=""
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/Users/kormotodor/Library/Caches/go-build"
    GOENV="/Users/kormotodor/Library/Application Support/go/env"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOINSECURE=""
    GONOPROXY=""
    GONOSUMDB=""
    GOOS="darwin"
    GOPATH="/Users/kormotodor/go"
    GOPRIVATE=""
    GOPROXY="https://proxy.golang.org,direct"
    GOROOT="/usr/local/Cellar/go/1.14.4/libexec"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/usr/local/Cellar/go/1.14.4/libexec/pkg/tool/darwin_amd64"
    GCCGO="gccgo"
    AR="ar"
    CC="clang"
    CXX="clang++"
    CGO_ENABLED="1"
    GOMOD=""
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/k1/958l0p8s10v7c71vp_dvtbn80000gn/T/go-build576841180=/tmp/go-build -gno-record-gcc-switches -fno-common"
    
  • about zookeeper 3.3.6

    about zookeeper 3.3.6

    Dear sir,I would like to use the zookeeper_exporter. However my zookeeper is work at 3.3.6 ( zookeeper doesn't upgrade). How can it compatible with 3.3.6 . Please help me solve this issue

  • Add gcc, musl-dev for aarch64 Docker image building

    Add gcc, musl-dev for aarch64 Docker image building

    When building docker image on aarch64, I meet the error: " Step 3/11 : RUN go get github.com/golang/dep/cmd/dep ---> Running in f1818e505227

    github.com/golang/dep/cmd/dep

    /usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exec: "gcc": executable file not found in $PATH " This patch will solve this problem.

Json-log-exporter - A Nginx log parser exporter for prometheus metrics

json-log-exporter A Nginx log parser exporter for prometheus metrics. Installati

Jan 5, 2022
Amplitude-exporter - Amplitude charts to prometheus exporter PoC

Amplitude exporter Amplitude charts to prometheus exporter PoC. Work in progress

May 26, 2022
Vulnerability-exporter - A Prometheus Exporter for managing vulnerabilities in kubernetes by using trivy
Vulnerability-exporter - A Prometheus Exporter for managing vulnerabilities in kubernetes by using trivy

Kubernetes Vulnerability Exporter A Prometheus Exporter for managing vulnerabili

Dec 4, 2022
Netstat exporter - Prometheus exporter for exposing reserved ports and it's mapped process

Netstat exporter Prometheus exporter for exposing reserved ports and it's mapped

Feb 3, 2022
Github billing exporter - Billing exporter for GitHub organizations

GitHub billing exporter Forked From: https://github.com/borisputerka/github_bill

Nov 2, 2022
📡 Prometheus exporter that exposes metrics from SpaceX Starlink Dish
📡  Prometheus exporter that exposes metrics from SpaceX Starlink Dish

Starlink Prometheus Exporter A Starlink exporter for Prometheus. Not affiliated with or acting on behalf of Starlink(™) ?? Starlink Monitoring System

Dec 19, 2022
Prometheus exporter for Chia node metrics

chia_exporter Prometheus metric collector for Chia nodes, using the local RPC API Building and Running With the Go compiler tools installed: go build

Sep 19, 2022
Nvidia GPU exporter for prometheus using nvidia-smi binary
Nvidia GPU exporter for prometheus using nvidia-smi binary

nvidia_gpu_exporter Nvidia GPU exporter for prometheus, using nvidia-smi binary to gather metrics. Introduction There are many Nvidia GPU exporters ou

Jan 5, 2023
NVIDIA GPU metrics exporter for Prometheus leveraging DCGM

DCGM-Exporter This repository contains the DCGM-Exporter project. It exposes GPU metrics exporter for Prometheus leveraging NVIDIA DCGM. Documentation

Dec 27, 2022
Prometheus exporter for Amazon Elastic Container Service (ECS)

ecs_exporter ?? ?? ?? This repo is still work in progress and is subject to change. This repo contains a Prometheus exporter for Amazon Elastic Contai

Nov 27, 2022
Prometheus exporter for DeadMansSnitch

DeadMansSnitch Exporter Prometheus exporter for DeadMansSnitch information (snitches) Configuration Usage: deadmanssnitch-exporter [OPTIONS] Applic

Apr 6, 2022
A prometheus exporter for monitoring FIO nodeos nodes.
A prometheus exporter for monitoring FIO nodeos nodes.

fio-prometheus-exporter This is a simple prometheus exporter for FIO nodeos nodes. It can connect to multiple nodes to display a few critical statisti

Aug 19, 2022
A Prometheus exporter, written in Golang, for Magento 2

Magento 2 Prometheus Exporter A Prometheus exporter, written in Golang, for Magento 2. Philosophy It might be abnormal to start with the "philosophy"

May 3, 2022
Prometheus exporter for podman

Prometheus exporter for podman Exports the following metrics for each running container CPU Usage Memory Usage Netowrk Usage Block Usage Output Exampl

Jul 5, 2022
A Prometheus exporter which scrapes metrics from CloudLinux LVE Stats 2
A Prometheus exporter which scrapes metrics from CloudLinux LVE Stats 2

CloudLinux LVE Exporter for Prometheus LVE Exporter - A Prometheus exporter which scrapes metrics from CloudLinux LVE Stats 2 Help on flags: -h, --h

Nov 2, 2021
Prometheus exporter of Hetzner Cloud inventory

Hetzner Cloud inventory exporter Prometheus exporter of Hetzner Cloud inventory Build Using docker Requires docker make build Locally Requires go buil

Dec 14, 2022
A Prometheus metrics exporter for AWS that fills in gaps CloudWatch doesn't cover

YAAE (Yet Another AWS Exporter) A Prometheus metrics exporter for AWS that fills in gaps CloudWatch doesn't cover About This exporter is meant to expo

Dec 10, 2022
Prometheus exporter for IAAS daily billing information
Prometheus exporter for IAAS daily billing information

Multi-iaas-daily-billing-exporter Multi-iaas-daily-billing-exporter enables to collect, unify and expose daily billing from AWS and GCP providers. The

Dec 14, 2021
Prometheus metrics exporter for libvirt.

Libvirt exporter Prometheus exporter for vm metrics written in Go with pluggable metric collectors. Installation and Usage If you are new to Prometheu

Jul 4, 2022