Apache CouchDB

Dokumen ini menjelaskan cara mengonfigurasi deployment Google Kubernetes Engine sehingga Anda dapat menggunakan Google Cloud Managed Service for Prometheus untuk mengumpulkan metrik dari Apache CouchDB. Dokumen ini menunjukkan cara melakukan hal berikut:

  • Menyiapkan pengekspor untuk CouchDB guna melaporkan metrik.
  • Mengakses dasbor bawaan di Cloud Monitoring untuk melihat metrik.
  • Mengonfigurasi aturan pemberitahuan untuk memantau metrik.

Petunjuk ini hanya berlaku jika Anda menggunakan koleksi terkelola dengan Managed Service for Prometheus. Jika Anda menggunakan koleksi yang di-deploy sendiri, lihat repositori sumber untuk pengekspor CouchDB guna mengetahui informasi penginstalan.

Petunjuk ini diberikan sebagai contoh dan diharapkan berfungsi di sebagian besar lingkungan Kubernetes. Jika Anda mengalami masalah saat menginstal aplikasi atau pengekspor karena kebijakan organisasi atau keamanan yang ketat, sebaiknya lihat dokumentasi open source untuk mendapatkan dukungan.

Untuk mengetahui informasi tentang Apache CouchDB, lihat CouchDB.

Prasyarat

Untuk mengumpulkan metrik dari CouchDB menggunakan Managed Service for Prometheus dan koleksi terkelola, deployment Anda harus memenuhi persyaratan berikut:

  • Cluster Anda harus menjalankan Google Kubernetes Engine versi 1.28.15-gke.2475000 atau yang lebih baru.
  • Anda harus menjalankan Managed Service for Prometheus dengan koleksi terkelola yang diaktifkan. Untuk mengetahui informasi selengkapnya, lihat Mulai menggunakan koleksi terkelola.

  • Untuk menggunakan dasbor yang tersedia di Cloud Monitoring untuk integrasi CouchDB, Anda harus menggunakan couchdb-prometheus-exporter versi v30.4.3 atau yang lebih baru.

    Untuk mengetahui informasi selengkapnya tentang dasbor yang tersedia, lihat Melihat dasbor.

Menginstal pengekspor CouchDB

Sebaiknya instal pengekspor CouchDB, couchdb-prometheus-exporter, sebagai sidecar ke workload CouchDB Anda. Untuk mengetahui informasi tentang penggunaan sidecar, lihat Aplikasi yang diperluas di Kubernetes dengan pod multi-container pod.

Untuk menginstal couchdb-prometheus-exporter sebagai sidecar ke CouchDB, ubah konfigurasi CouchDB Anda seperti yang ditunjukkan dalam contoh berikut:

# 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: StatefulSet
metadata:
  name: couchdb
spec:
  serviceName: couchdb
  selector:
    matchLabels:
+     app.kubernetes.io/name: couchdb
  template:
    metadata:
      labels:
+       app.kubernetes.io/name: couchdb
    spec:
      containers:
      - name: couchdb
        image: couchdb:3.2.2
        env:
          - name: COUCHDB_USER
            value: "otelu"
          - name: COUCHDB_PASSWORD
            value: "otelp"
          - name: NODENAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: ERL_FLAGS
            value: "-setcookie otel"
        ports:
        - containerPort: 5984
+     - name: couchdb-exporter
+       image: gesellix/couchdb-prometheus-exporter:v30.4.3
+       args:
+       - --couchdb.uri=http://localhost:5984
+       - --logtostderr
+       env:
+         - name: COUCHDB_USERNAME
+           value: "otelu"
+         - name: COUCHDB_PASSWORD
+           value: "otelp"
+       ports:
+       - containerPort: 9984
+         name: prometheus

Anda harus menambahkan baris yang diawali dengan simbol + ke konfigurasi Anda.

Perbarui variabel lingkungan COUCHDB_USERNAME dan COUCHDB_PASSWORD pengekspor ke variabel pengguna pemantauan Anda.

Untuk menerapkan perubahan konfigurasi dari file lokal, jalankan perintah berikut:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

Anda juga dapat menggunakan Terraform untuk mengelola konfigurasi.

Menentukan resource PodMonitoring

Untuk penemuan target, Managed Service for Prometheus Operator memerlukan resource PodMonitoring yang sesuai dengan pengekspor CouchDB di namespace yang sama.

Anda dapat menggunakan konfigurasi PodMonitoring berikut:

# 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: couchdb
  labels:
    app.kubernetes.io/name: couchdb
    app.kubernetes.io/part-of: google-cloud-managed-prometheus
spec:
  endpoints:
  - port: prometheus
    scheme: http
    interval: 30s
    path: /metrics
    params:
      format:
      - prometheus
  selector:
    matchLabels:
      app.kubernetes.io/name: couchdb

Pastikan pemilih label dan port cocok dengan pemilih dan port yang digunakan di Menginstal pengekspor CouchDB.

Untuk menerapkan perubahan konfigurasi dari file lokal, jalankan perintah berikut:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

Anda juga dapat menggunakan Terraform untuk mengelola konfigurasi.

Menentukan aturan dan pemberitahuan

Anda dapat menggunakan konfigurasi Rules berikut untuk menentukan pemberitahuan pada metrik CouchDB:

# Copyright 2023 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: couchdb-rules
  labels:
    app.kubernetes.io/component: rules
    app.kubernetes.io/name: couchdb-rules
    app.kubernetes.io/part-of: google-cloud-managed-prometheus
spec:
  groups:
  - name: couchdb
    interval: 30s
    rules:
    - alert: CouchDBHighRequestRate
      annotations:
        description: |-
          CouchDB high request rate
            VALUE = {{ $value }}
            LABELS: {{ $labels }}
        summary: CouchDB high request rate (instance {{ $labels.instance }})
      expr: rate(couchdb_httpd_requests[5m]) > 100
      for: 5m
      labels:
        severity: warning
    - alert: CouchDBHighServerErrorRate
      annotations:
        description: |-
          CouchDB high server error rate
            VALUE = {{ $value }}
            LABELS: {{ $labels }}
        summary: CouchDB high server error rate (instance {{ $labels.instance }})
      expr: rate(couchdb_httpd_status_codes{code="500"}[5m]) > 0
      for: 5m
      labels:
        severity: warning
    - alert: CouchDBLowRequestRate
      annotations:
        description: |-
          CouchDB low request rate
            VALUE = {{ $value }}
            LABELS: {{ $labels }}
        summary: CouchDB low request rate (instance {{ $labels.instance }})
      expr: rate(couchdb_httpd_requests[5m]) < 10
      for: 5m
      labels:
        severity: warning

Untuk menerapkan perubahan konfigurasi dari file lokal, jalankan perintah berikut:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

Anda juga dapat menggunakan Terraform untuk mengelola konfigurasi.

Untuk mengetahui informasi selengkapnya tentang cara menerapkan aturan ke cluster, lihat Evaluasi dan pemberitahuan aturan terkelola.

Anda dapat menyesuaikan nilai minimum pemberitahuan agar sesuai dengan aplikasi Anda.

Memverifikasi konfigurasi

Anda dapat menggunakan Metrics Explorer untuk memverifikasi bahwa Anda telah mengonfigurasi pengekspor CouchDB dengan benar. Cloud Monitoring mungkin memerlukan waktu satu atau dua menit untuk menyerap metrik Anda.

Untuk memverifikasi bahwa metrik telah diserap, lakukan hal berikut:

  1. Di Google Cloud konsol, buka halaman  Metrics explorer:

    Buka Metrics explorer

    Jika Anda menggunakan kotak penelusuran untuk menemukan halaman ini, pilih hasil yang subjudulnya adalah Monitoring.

  2. Di toolbar panel pembuat kueri, pilih tombol yang namanya  PromQL.
  3. Masukkan dan jalankan kueri berikut:
    up{job="couchdb", cluster="CLUSTER_NAME", namespace="NAMESPACE_NAME"}

Melihat dasbor

Integrasi Cloud Monitoring mencakup dasbor CouchDB Prometheus Overview. Dasbor akan otomatis diinstal saat Anda mengonfigurasi integrasi. Anda juga dapat melihat pratinjau statis dasbor tanpa menginstal integrasi.

Untuk melihat dasbor yang terinstal, lakukan hal berikut:

  1. Di Google Cloud konsol, buka halaman  Dashboards:

    Buka Dashboards

    Jika Anda menggunakan kotak penelusuran untuk menemukan halaman ini, pilih hasil yang subjudulnya adalah Monitoring.

  2. Pilih tab Dashboard List.
  3. Pilih kategori Integrations.
  4. Klik nama dasbor, misalnya, CouchDB Prometheus Overview.

Untuk melihat pratinjau statis dasbor, lakukan hal berikut:

  1. Di Google Cloud konsol, buka halaman  Integrations:

    Buka Integrations

    Jika Anda menggunakan kotak penelusuran untuk menemukan halaman ini, pilih hasil yang subjudulnya adalah Monitoring.

  2. Klik filter platform deployment Kubernetes Engine.
  3. Temukan integrasi Apache CouchDB, lalu klik View Details.
  4. Pilih tab Dashboards.

Pemecahan masalah

Untuk mengetahui informasi tentang cara memecahkan masalah penyerapan metrik, lihat Masalah dengan pengumpulan dari pengekspor di Memecahkan masalah sisi penyerapan.