> ## 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. You can configure targets either by
annotating pods in your Kubernetes cluster or by listing static endpoints in your Helm
values. To configure the ZooKeeper integration, follow these steps:

1. To collect from ZooKeeper pods in Kubernetes, add a CXDOT integration annotation to
   the pod template. The annotation key must end with the container name. For example,
   add the following annotation to your ZooKeeper workload:

   ```yaml theme={null}
   spec:
     template:
       metadata:
         annotations:
           integrations.cxdot.paloaltonetworks.com/zookeeper: |
             schema_version: v1.14
             zookeeper:
               endpoints:
                 - endpoint: ${target.host}:${target.port.client}
       spec:
         containers:
           - name: zookeeper
             image: zookeeper:3.9
             ports:
               - name: client
                 containerPort: 2181
   ```

   The Collector replaces `${target.host}` with the pod IP address and
   `${target.port.client}` with the container port named `client`.

   The Collector also discovers ZooKeeper pods that carry the
   `app.kubernetes.io/name: zookeeper` label and listen on port `2181`. A CXDOT
   integration annotation takes precedence over the label for its container. To stop
   collecting from a container, set `zookeeper: {enabled: false}` in the annotation.
   Metrics from each discovered pod include that pod's Kubernetes metadata. For more
   information, see
   [autodiscovery](https://docs-xcor.paloaltonetworks.com/ingest/xcor/collector/discover/kubernetes.md).

2. Optional: To collect from ZooKeeper servers outside your Kubernetes cluster,
   configure static targets. For example, add the following to the `values.yaml` file
   for the CXDOT Collector Helm chart:

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

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

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

   ```yaml theme={null}
   collection:
     cxdot:
       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 discovering pods.

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}
   collection:
     cxdot:
       integrations:
         zookeeper:
           enabled: false
   ```

### Validate

To validate the ZooKeeper integration, follow these steps:

1. In the
   [Live Telemetry Analyzer](https://docs-xcor.paloaltonetworks.com/investigate/analyze/telemetry-analyzer.md),
   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-xcor.paloaltonetworks.com/investigate/querying/metrics/explorer.md),
   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 `collection.cxdot.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: `[]`.
  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](https://docs-xcor.paloaltonetworks.com/ingest/xcor/integrations/collector/kafka.md)
- [CXDOT Collector integrations](https://docs-xcor.paloaltonetworks.com/ingest/xcor/integrations/collector.md)
- [Logging query syntax](https://docs-xcor.paloaltonetworks.com/investigate/querying/query-logs/query-syntax.md)


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