The Apache ZooKeeper integration collects traffic metrics for nodes, such as latency, active requests, and active connections. The integration also collects ZooKeeper logs and parses them into a JSON payload. The result includes fields for node ID, source, level, and message.
For more information about ZooKeeper, see zookeeper.apache.org.
Prerequisites
To collect and ingest ZooKeeper logs and metrics, you must install Ops Agent version 2.11.0 or higher.
This receiver supports Apache ZooKeeper versions 3.5, 3.6, and 3.7.
Configure the Ops Agent for ZooKeeper
Following the guide for Configuring the Ops Agent, add the required elements to collect logs and metrics from your ZooKeeper instances, and restart the agent.
Example configuration
The following command creates the configuration file to collect and ingest logs and metrics for ZooKeeper and restarts the Ops Agent on Linux.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
logging:
receivers:
zookeeper_general:
type: zookeeper_general
service:
pipelines:
zookeeper_general:
receivers:
- zookeeper_general
metrics:
receivers:
zookeeper:
type: zookeeper
service:
pipelines:
zookeeper:
receivers:
- zookeeper
EOF
sudo service google-cloud-ops-agent restart
Configure logs collection
To ingest logs from ZooKeeper, you must create receivers for the logs ZooKeeper
produces and then create a pipeline for the new receivers. To configure a
receiver for your zookeeper_general
logs, specify the following fields:
Field | Default | Description |
---|---|---|
type |
The value must be zookeeper_general . |
|
include_paths |
[/opt/zookeeper/logs/zookeeper-*.out, /var/log/zookeeper/zookeeper.log] |
A list of filesystem paths to read by tailing each file. A wild card (* ) can be used in the paths; for example, /var/log/zookeeper*/*.log . |
exclude_paths |
A list of filesystem path patterns to exclude from the set matched by include_paths . |
|
record_log_file_path |
false |
If set to true , then the path to the specific file from which the log record was obtained appears in the output log entry as the value of the agent.googleapis.com/log_file_path label. When using a wildcard, only the path of the file from which the record was obtained is recorded. |
wildcard_refresh_interval |
60s |
The interval at which wildcard file paths in include_paths are refreshed. Specified as a time interval parsable by time.ParseDuration. Must be a multiple of 1s. |
What is logged
The logName
of the zookeeper_general
logs are derived from the receiver IDs
specified in the configuration. Detailed fields inside the
LogEntry
are as follows.
Field | Type | Description |
---|---|---|
timestamp |
string (Timestamp ) |
Time the request was received. |
jsonPayload.line |
number | Line number from which the log was generated in source. |
jsonPayload.source |
string | Source of where the log originated. |
jsonPayload.thread |
string | Thread from which the log originated. |
jsonPayload.myid |
number | Numeric ID of the Zookeeper instance. |
jsonPayload.message |
string | Log message, including detailed stack trace where provided. |
severity |
string (LogSeverity ) |
Log entry level (translated). |
Configure metrics collection
To collect metrics from ZooKeeper, you must create a receiver for ZooKeeper metrics and then create a pipeline for the new receiver. To configure a receiver for your ZooKeeper metrics, specify the following fields:
Field | Default | Description |
---|---|---|
type |
The value must be zookeeper . |
|
endpoint |
localhost:2181 |
The URL exposed by ZooKeeper. |
collection_interval |
60s |
A time.Duration value, such as 30s or 5m . |
What is monitored
The following table provides the list of metrics that the Ops Agent collects from the ZooKeeper instance.
Metric type | |
---|---|
Kind, Type Monitored resources |
Labels |
workload.googleapis.com/zookeeper.connection.active
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.data_tree.ephemeral_node.count
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.data_tree.size
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.file_descriptor.limit
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.file_descriptor.open
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.fsync.exceeded_threshold.count
|
|
CUMULATIVE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.latency.avg
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.latency.max
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.latency.min
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.packet.count
|
|
CUMULATIVE , INT64 gce_instance |
direction
|
workload.googleapis.com/zookeeper.request.active
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.watch.count
|
|
GAUGE , INT64 gce_instance |
|
workload.googleapis.com/zookeeper.znode.count
|
|
GAUGE , INT64 gce_instance |
Sample dashboard
You can view the metrics from this integration using a sample Cloud Monitoring dashboard. Complete the Installing sample dashboards procedures to import the ZooKeeper GCE Overview dashboard from the Sample library and view charts that display your Apache ZooKeeper metrics.Verify the configuration
You can use the Logs Explorer and Metrics Explorer to verify that you correctly configured the ZooKeeper receiver. It might take one or two minutes for the Ops Agent to begin collecting logs and metrics.
To verify the logs are ingested, go to the Logs Explorer and run the following query to view the ZooKeeper logs:
resource.type="gce_instance"
logName=("projects/PROJECT_ID/logs/zookeeper_general")
To verify the metrics are ingested, go to
Metrics Explorer
and run the following query in the MQL tab.
fetch gce_instance
| metric 'workload.googleapis.com/zookeeper.packet.count'
| align rate(1m)
| every 1m
What's next
For a walkthrough on how to use Ansible to install the Ops Agent, configure a third-party application, and install a sample dashboard, see the Install the Ops Agent to troubleshoot third-party applications video.