Apache Zookeeper

במאמר הזה מוסבר איך להגדיר את הפריסה של Google Kubernetes Engine כדי שתוכלו להשתמש בשירות מנוהל של Google Cloud ל-Prometheus כדי לאסוף מדדים מ-Apache Zookeeper. במאמר הזה מוסבר איך:

  • מגדירים את Zookeeper לדיווח על מדדים.
  • אפשר לגשת למרכז בקרה מוגדר מראש ב-Cloud Monitoring כדי לראות את המדדים.
  • הגדרת כללי התראה למעקב אחר המדדים.

ההוראות האלה רלוונטיות רק אם אתם משתמשים ב אוסף מנוהל עם השירות המנוהל ל-Prometheus. אם אתם משתמשים באיסוף שמוטמע באופן עצמאי, תוכלו לעיין במסמכי Zookeeper כדי לקבל מידע על התקנה.

ההוראות האלה הן דוגמה, והן אמורות לפעול ברוב סביבות Kubernetes. אם נתקלתם בבעיה בהתקנת אפליקציה או כלי לייצוא בגלל מדיניות אבטחה או מדיניות ארגונית מגבילה, מומלץ לעיין במסמכי קוד פתוח לקבלת תמיכה.

מידע על Apache Zookeeper זמין במאמר Zookeeper.

דרישות מוקדמות

כדי לאסוף מדדים מ-Zookeeper exporter באמצעות שירות מנוהל ל-Prometheus ואיסוף מנוהל, הפריסה צריכה לעמוד בדרישות הבאות:

  • האשכול צריך להריץ את Google Kubernetes Engine בגרסה ‎1.28.15-gke.2475000 ואילך.
  • צריך להפעיל את השירות המנוהל ל-Prometheus עם איסוף מנוהל. מידע נוסף זמין במאמר תחילת השימוש באוסף מנוהל.

  • כדי להשתמש בלוחות בקרה שזמינים ב-Cloud Monitoring לשילוב של Zookeeper, צריך להשתמש בגרסה 3.8.0 ואילך של zookeeper.

    מידע נוסף על לוחות הבקרה הזמינים מופיע במאמר הצגת לוחות בקרה.

שינוי ההגדרות של Zookeeper

משנים את ההגדרה של Zookeeper כמו בדוגמה הבאה:

# 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
#
#     https://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.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: zookeeper
spec:
  selector:
    matchLabels:
+     app.kubernetes.io/name: zookeeper
  template:
    metadata:
      labels:
+       app.kubernetes.io/name: zookeeper
    spec:
      containers:
      - name: zookeeper
        image: zookeeper:3.8.0
+       env:
+       - name: ZOO_CFG_EXTRA
+         value: "metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider metricsProvider.httpPort=7000 metricsProvider.exportJvmInfo=true"
+       ports:
+       - containerPort: 7000
+         name: prometheus

צריך להוסיף להגדרה את כל השורות שמופיע לפניהן הסמל +.

כדי להחיל שינויים בתצורה מקובץ מקומי, מריצים את הפקודה הבאה:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

אפשר גם להשתמש ב-Terraform כדי לנהל את ההגדרות.

‫Zookeeper חושף מדדים בפורמט Prometheus באופן אוטומטי כשהוא מוגדר להשתמש במשתנה הסביבה ZOO_CFG_EXTRA. בדוגמה הזו, Zookeeper מוגדר לחשיפת מדדים בפורמט Prometheus ביציאה 7000.

הגדרה של משאב PodMonitoring

כדי לגלות את היעד, שירות מנוהל ל-Prometheus Operator צריך משאב PodMonitoring שתואם ל-Zookeeper exporter באותו מרחב שמות.

אפשר להשתמש בהגדרה הבאה של PodMonitoring:

# 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
#
#     https://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.

apiVersion: monitoring.googleapis.com/v1
kind: PodMonitoring
metadata:
  name: zookeeper
  labels:
    app.kubernetes.io/name: zookeeper
    app.kubernetes.io/part-of: google-cloud-managed-prometheus
spec:
  endpoints:
  - port: prometheus
    scheme: http
    interval: 30s
    path: /metrics
  selector:
    matchLabels:
      app.kubernetes.io/name: zookeeper

כדי להחיל שינויים בתצורה מקובץ מקומי, מריצים את הפקודה הבאה:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

אפשר גם להשתמש ב-Terraform כדי לנהל את ההגדרות.

הגדרת כללים והתראות

אפשר להשתמש בהגדרות הבאות Rules כדי להגדיר התראות על מדדי Zookeeper:

# 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
#
#     https://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.

apiVersion: monitoring.googleapis.com/v1
kind: Rules
metadata:
  name: zookeeper-rules
  labels:
    app.kubernetes.io/component: rules
    app.kubernetes.io/name: zookeeper-rules
    app.kubernetes.io/part-of: google-cloud-managed-prometheus
spec:
  groups:
  - name: zookeeper
    interval: 30s
    rules:
    - alert: ZooKeeperHighAverageLatency
      annotations:
        description: |-
          ZooKeeper high average latency
            VALUE = {{ $value }}
            LABELS: {{ $labels }}
        summary: ZooKeeper high average latency (instance {{ $labels.instance }})
      expr: avg_latency > 100
      for: 5m
      labels:
        severity: warning
    - alert: ZooKeeperHighFsyncDuration
      annotations:
        description: |-
          ZooKeeper high fsync duration
            VALUE = {{ $value }}
            LABELS: {{ $labels }}
        summary: ZooKeeper high fsync duration (instance {{ $labels.instance }})
      expr: fsynctime_sum > 100
      for: 5m
      labels:
        severity: warning
    - alert: ZooKeeperLowFreeFileDescriptors
      annotations:
        description: |-
          ZooKeeper high fsync duration
            VALUE = {{ $value }}
            LABELS: {{ $labels }}
        summary: ZooKeeper high fsync duration (instance {{ $labels.instance }})
      expr: open_file_descriptor_count >= max_file_descriptor_count - 15
      for: 5m
      labels:
        severity: critical

כדי להחיל שינויים בתצורה מקובץ מקומי, מריצים את הפקודה הבאה:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

אפשר גם להשתמש ב-Terraform כדי לנהל את ההגדרות.

מידע נוסף על החלת כללים על האשכול זמין במאמר הערכה והתראות של כללים מנוהלים.

אפשר לשנות את ערכי הסף של ההתראות בהתאם לאפליקציה.

אימות ההגדרה

אתם יכולים להשתמש ב-Metrics Explorer כדי לוודא שהגדרתם את Zookeeper exporter בצורה נכונה. יכול להיות שיחלפו דקה או שתיים עד שמערכת Cloud Monitoring תעבד את המדדים.

כדי לוודא שהמדדים נאספים, מבצעים את הפעולות הבאות:

  1. במסוף Google Cloud , עוברים לדף  Metrics explorer:

    כניסה אל Metrics Explorer

    אם משתמשים בסרגל החיפוש כדי למצוא את הדף הזה, בוחרים בתוצאה שכותרת המשנה שלה היא Monitoring.

  2. בסרגל הכלים של חלונית הכלי ליצירת שאילתות, לוחצים על הלחצן ששמו הוא  MQL או  PromQL.
  3. מוודאים שהאפשרות PromQL נבחרה במתג שפה. המתג לשפה נמצא באותו סרגל כלים שבו אפשר לעצב את השאילתה.
  4. מזינים ומריצים את השאילתה הבאה:
    up{job="zookeeper", cluster="CLUSTER_NAME", namespace="NAMESPACE_NAME"}

הצגת מרכזי בקרה

השילוב עם Cloud Monitoring כולל את לוח הבקרה Zookeeper Prometheus Overview. לוחות הבקרה מותקנים באופן אוטומטי כשמגדירים את השילוב. אפשר גם לראות תצוגות מקדימות סטטיות של מרכזי בקרה בלי להתקין את האינטגרציה.

כדי לראות מרכז בקרה שהותקן:

  1. במסוף Google Cloud , עוברים לדף  Dashboards:

    מעבר אל מרכזי בקרה

    אם משתמשים בסרגל החיפוש כדי למצוא את הדף הזה, בוחרים בתוצאה שכותרת המשנה שלה היא Monitoring.

  2. לוחצים על הכרטיסייה רשימת מרכזי בקרה.
  3. בוחרים בקטגוריה שילובים.
  4. לוחצים על השם של מרכז הבקרה, לדוגמה, Zookeeper Prometheus Overview.

כדי לראות תצוגה מקדימה סטטית של מרכז הבקרה:

  1. נכנסים לדף  Integrations במסוף Google Cloud :

    עוברים אל Integrations

    אם משתמשים בסרגל החיפוש כדי למצוא את הדף הזה, בוחרים בתוצאה שכותרת המשנה שלה היא Monitoring.

  2. לוחצים על המסנן Kubernetes Engine של פלטפורמת הפריסה.
  3. מאתרים את השילוב של Apache Zookeeper ולוחצים על הצגת פרטים.
  4. לוחצים על הכרטיסייה מרכזי בקרה.

פתרון בעיות

מידע על פתרון בעיות בהוספת מדדים זמין במאמר פתרון בעיות שקשורות להוספה, בקטע בעיות באיסוף נתונים ממייצאים.