# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

public_url: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/third-party/zookeeper"
app_url: "https://zookeeper.apache.org/"
short_name: ZooKeeper
long_name: Apache ZooKeeper
logo_path: /stackdriver/images/zookeeper.png # supplied by google technical writer
description: |-
  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.
minimum_supported_agent_version:
  metrics: 2.10.0
  logging: 2.11.0
supported_operating_systems: linux
supported_app_version: ["3.5", "3.6", "3.7"]
expected_metrics:
  - type: workload.googleapis.com/zookeeper.connection.active
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.data_tree.ephemeral_node.count
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.data_tree.size
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.file_descriptor.limit
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
    representative: true
  - type: workload.googleapis.com/zookeeper.file_descriptor.open
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.fsync.exceeded_threshold.count
    optional: true
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.latency.avg
    optional: true
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.latency.max
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.latency.min
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.packet.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: direction
        value_regex: .*
  - type: workload.googleapis.com/zookeeper.request.active
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.watch.count
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/zookeeper.znode.count
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
expected_logs:
  - log_name: zookeeper_general
    fields:
      - name: jsonPayload.message
        value_regex: (?s)binding to port 0.0.0.0/0.0.0.0:2181.* # The (?s) part will make the . match with newline as well. See https://github.com/google/re2/blob/main/doc/syntax.txt#L65,L68
        type: string
        description: Log message, including detailed stacktrace where provided
      - name: jsonPayload.thread
        value_regex: main
        type: string
        description: Thread from which the log originated
      - name: jsonPayload.source
        value_regex: NIOServerCnxnFactory
        type: string
        description: Source of where the log originated
      - name: jsonPayload.line
        type: number
        description: Line number from which the log was generated in source
      - name: jsonPayload.myid
        type: number
        description: Numeric ID of the Zookeeper instance
        optional: true
      - name: jsonPayload.level
        type: string
        description: Log entry level
        optional: true
      - name: severity
        type: string
        description: ''
configuration_options:
  logs:
    - type: zookeeper_general
      fields:
        - name: type
          default: null
          description: The value must be `zookeeper_general`.
        - name: include_paths
          default: '[/opt/zookeeper/logs/zookeeper-*.out, /var/log/zookeeper/zookeeper.log]'
          description: 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`.
        - name: exclude_paths
          default: null
          description: A list of filesystem path patterns to exclude from the set matched by `include_paths`.
        - name: record_log_file_path
          default: false
          description: 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.
        - name: wildcard_refresh_interval
          default: 60s
          description: The interval at which wildcard file paths in `include_paths` are refreshed. Given as a [time duration](https://pkg.go.dev/time#ParseDuration), for example `30s` or `2m`. This property might be useful under high logging throughputs where log files are rotated faster than the default interval.
  metrics:
    - type: zookeeper
      fields:
        - name: type
          default: null
          description: This value must be `zookeeper`.
        - name: endpoint
          default: localhost:2181
          description: The URL exposed by ZooKeeper.
        - name: collection_interval
          default: 60s
          description: A [time duration](https://pkg.go.dev/time#ParseDuration) value, such as `30s` or `5m`.
