> ## Documentation Index
> Fetch the complete documentation index at: https://docs-xcor.paloaltonetworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ZooKeeper

> ZooKeeper connection, request, latency, and data tree metrics.

The ZooKeeper integration requires CXDOT Collector 1.7.0 or greater.

[Apache ZooKeeper](https://zookeeper.apache.org/) is a distributed coordination
service for maintaining configuration, naming, and synchronization data. Use the
ZooKeeper integration to collect connection, request, latency, and data tree metrics
from ZooKeeper servers running in your environment.

The ZooKeeper integration supports ZooKeeper 3.7 or greater.

## Supported telemetry types

The ZooKeeper integration supports these telemetry types:

| Type | Supported |
| :-: | :-: |
| Logs | No |
| Metrics | Yes |
| Traces | No |
| Events | No |

## Prerequisites

The ZooKeeper integration has the following prerequisites:

* Enable the `mntr`, `stat`, and `ruok` four-letter commands. For more information,
  see [ZooKeeper four-letter commands](https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_4lw).
  For example, add the following setting to `zoo.cfg`:

  ```text theme={null}
  4lw.commands.whitelist=mntr,stat,ruok
  ```

  To confirm that ZooKeeper accepts the commands, run the following commands from a
  host that can reach the server:

  ```shell theme={null}
  printf 'mntr\n' | nc <host> <port>
  printf 'stat\n' | nc <host> <port>
  printf 'ruok\n' | nc <host> <port>
  ```

  Confirm that the `mntr` response includes `zk_version` and `zk_server_state`, the
  `stat` response includes the server mode, and the `ruok` response is `imok`.

* Make the ZooKeeper client port, typically `2181`, reachable from the CXDOT
  Collector.

## Configure

The ZooKeeper integration is enabled by default. To configure the ZooKeeper
integration, follow these steps:

1. For ZooKeeper pods that listen on port `2181`, add the
   `app.kubernetes.io/name: zookeeper` label to the pod template. The CXDOT Collector
   also discovers pods and Services that carry autodiscovery annotations for
   ZooKeeper. For more information, see
   [autodiscovery](https://docs.paloaltonetworks.com/cortex/xcor/ingest/xcor/collector/discover/kubernetes).

   Metrics from discovered pods arrive with that pod's Kubernetes metadata attached.

2. Optional: Configure static targets to collect metrics from ZooKeeper servers that
   autodiscovery doesn't cover, such as servers outside your Kubernetes cluster. For
   example, add the following to the `values.yaml` file for the CXDOT Collector Helm
   chart:

   ```yaml theme={null}
   config:
     integrations:
       zookeeper:
         endpoints:
           - endpoint: zookeeper.example.com:2181
   ```

   This integration instance collects from exactly the listed targets and disables
   autodiscovery. In a Kubernetes deployment, the cluster-tier CXDOT Collector
   collects static targets through one elected replica. For more information, see
   [architecture](https://docs.paloaltonetworks.com/cortex/xcor/ingest/xcor/collector/install/kubernetes/architecture).

3. Optional: Configure separate integration instances to collect from both discovered
   and static targets. For example, add the following to the `values.yaml` file for
   the CXDOT Collector Helm chart:

   ```yaml theme={null}
   config:
     integrations:
       zookeeper: {}
       zookeeper/external:
         endpoints:
           - endpoint: zookeeper.example.com:2181
   ```

   The `zookeeper/external` key defines a named instance for the static targets.
   Configuring a named instance suppresses the implicit default instance, so the empty
   `zookeeper: {}` entry is required to keep autodiscovery running.

4. Optional: Disable the integration to stop collecting from discovered targets. For
   example, add the following to the `values.yaml` file for the CXDOT Collector Helm
   chart:

   ```yaml theme={null}
   config:
     integrations:
       zookeeper:
         enabled: false
   ```

### Validate

To validate the ZooKeeper integration, follow these steps:

1. In the
   [Live Telemetry Analyzer](https://docs.paloaltonetworks.com/cortex/xcor/investigate/analyze/telemetry-analyzer),
   add the following filters:

   * `__name__=cxdot.integration.target.health`
   * `cxdot.integration.name=zookeeper`

   Confirm that each target reports `1`, identified by its `server.address` and
   `server.port` attributes.

2. In
   [Metrics Explorer](https://docs.paloaltonetworks.com/cortex/xcor/investigate/querying/metrics/explorer),
   run the following query while ZooKeeper clients create or delete data tree nodes:

   ```text theme={null}
   sum by ("server.address", "server.port") ({"zookeeper.znode.count", "cxdot.integration.name"="zookeeper"})
   ```

   Confirm that the query returns the expected data tree node count for each target.

## Configuration reference

Configure one ZooKeeper integration instance with the following settings. In Helm values, place
these settings under `config.integrations.zookeeper`. In a Collector configuration file, place
them under `cxdot.integrations.zookeeper`.

### Optional settings

* **`enabled`**
  Type: `boolean`. Optional. Default: `true`.
  Whether to run the ZooKeeper integration. If true, the Collector collects ZooKeeper metrics.
  If false, the Collector doesn't run this integration.

* **`endpoints`**
  Type: `array of object`. Optional. Default: `[]`.
  Static ZooKeeper targets, specified as `host:port`. When this list is empty or omitted, the
  integration uses automatic target discovery. When the list contains targets, this integration
  instance collects from exactly those targets and doesn't use automatic target discovery.
  Configure a second named instance to use both methods.

* **`endpoints[].endpoint`**
  Type: `string`. Required.
  `host:port` of the target.

* **`collection_interval`**
  Type: `duration`. Optional. Default: `15s`.
  How often the Collector requests metrics from each ZooKeeper target.

* **`timeout`**
  Type: `duration`. Optional. Default: `15s`.
  Maximum time the Collector waits for a ZooKeeper target to complete one collection, including
  the connection attempt. This value must be greater than `0s` and must not exceed
  `collection_interval`. If the deadline expires, that collection fails.


## Related topics

- [Kafka](/ingest/xcor/integrations/collector/kafka.md)
- [CXDOT Collector integrations](/ingest/xcor/integrations/collector.md)
- [Logging query syntax](/investigate/querying/query-logs/query-syntax.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.