Apache CouchDB

The Apache CouchDB integration collects traffic-related metrics, such as the number of requests to a node and responses from the node. It also collects database metrics, such as how many are open and the number of operations. The integration collects general CouchDB and access logs and parses them into a JSON payload. The result includes fields for user, host, level, and message.

For more information about Apache CouchDB, see couchdb.apache.org/.

Prerequisites

To collect and ingest CouchDB logs and metrics, you must install Ops Agent version 2.11.0 or higher.

This receiver supports Apache CouchDB versions 2.3.x and 3.1 and higher.

Configure the Ops Agent for CouchDB

Following the guide for Configuring the Ops Agent, add the required elements to collect logs and metrics from your CouchDB instances, and restart the agent.

Example configuration

The following command creates the configuration file to collect and ingest logs and metrics for CouchDB and restarts the Ops Agent on Linux.

sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
logging:
  receivers:
    couchdb:
      type: couchdb
  service:
    pipelines:
      couchdb:
        receivers:
          - couchdb
metrics:
  receivers:
    couchdb:
      type: couchdb
      username: usr
      password: pwd
  service:
    pipelines:
      couchdb:
        receivers:
          - couchdb
EOF
sudo service google-cloud-ops-agent restart

Configure logs collection

To ingest logs from CouchDB, you must create receivers for the logs CouchDB produces and then create a pipeline for the new receivers. To configure a receiver for your couchdb logs, specify the following fields:

Field Default Description
type The value must be couchdb.
include_paths [/var/log/couchdb/couchdb.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/couchdb*/*.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. Given as a time duration, for example 30s or 2m. This property might be useful under high logging throughputs where log files are rotated faster than the default interval. Must be a multiple of 1s.

What is logged

The logName of the couchdb logs are derived from the receiver IDs specified in the configuration. Detailed fields inside the LogEntry are as follows.

Field Type Description
httpRequest.serverIp string Server IP address.
httpRequest.remoteIp string Client IP address.
httpRequest.requestMethod string HTTP method.
httpRequest.responseSize string (int64) Response size
httpRequest.status number HTTP status code.
jsonPayload.remote_user string Authenticated username for the request.
jsonPayload.pid number Process ID.
jsonPayload.message string Log message.
jsonPayload.status_message string status code message.
jsonPayload.node string node instance name.
jsonPayload.host string host instance name.
jsonPayload.path string request path.
jsonPayload.remote_user string user id (optional).
severity string (LogSeverity) Log entry level (translated).
timestamp string (Timestamp) Time the entry was logged.

Log entries don't contain any fields that are blank or missing.

Configure metrics collection

To collect metrics from CouchDB, you must create a receiver for CouchDB metrics and then create a pipeline for the new receiver. To configure a receiver for your CouchDB metrics, specify the following fields:

Field Default Description
type The value must be couchdb.
stub_status_url http://localhost:5984 The URL exposed by CouchDB.
username The username used to connect to the server.
password The password used to connect to the server.
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 CouchDB instance.

Metric type 
Kind, Type
Monitored resources
Labels
workload.googleapis.com/couchdb.average_request_time
GAUGEDOUBLE
gce_instance
 
workload.googleapis.com/couchdb.database.open
GAUGEINT64
gce_instance
 
workload.googleapis.com/couchdb.database.operations
CUMULATIVEINT64
gce_instance
operation
workload.googleapis.com/couchdb.file_descriptor.open
GAUGEINT64
gce_instance
 
workload.googleapis.com/couchdb.httpd.bulk_requests
CUMULATIVEINT64
gce_instance
 
workload.googleapis.com/couchdb.httpd.requests
CUMULATIVEINT64
gce_instance
http_method
workload.googleapis.com/couchdb.httpd.responses
CUMULATIVEINT64
gce_instance
http_status_code
workload.googleapis.com/couchdb.httpd.views
CUMULATIVEINT64
gce_instance
view

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 CouchDB Overview dashboard from the Sample library and view charts that display your CouchDB metrics.

Verify the configuration

You can use the Logs Explorer and Metrics Explorer to verify that you correctly configured the CouchDB 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 CouchDB logs:

resource.type="gce_instance"
logName=("projects/PROJECT_ID/logs/couchdb")


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/couchdb.database.operations'
| 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.