Skip to content
This repository was archived by the owner on Sep 21, 2020. It is now read-only.

GPII-3394: Add couchdb support #2

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.*.sw?
220 changes: 220 additions & 0 deletions configurator/couchdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
#!/bin/bash

# Copyright (C) 2016 wikiwi.io
#
# This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE file for details.

if [ -n "${COUCHDB_STATUS_URL}" ]; then
echo Configuring couchdb...
cat <<EOL > /opt/stackdriver/collectd/etc/collectd.d/couchdb.conf
# This is the monitoring configuration for CouchDB.
#
# Adapted from
# https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/couchdb.conf
# for use in a CouchDB 2.x cluster.
LoadPlugin curl_json
<Plugin "curl_json">
# For example:
# <URL "http://user:[email protected]:5984/_node/_local/_stats">
<URL "${COUCHDB_STATUS_URL}">
Instance "couchdb"

<Key "couchdb/auth_cache_hits/value">
Type "counter"
Instance "auth_cache_hits"
</Key>
<Key "couchdb/auth_cache_misses/value">
Type "counter"
Instance "auth_cache_misses"
</Key>
<Key "couchdb/database_reads/value">
Type "counter"
Instance "database_reads"
</Key>
<Key "couchdb/database_writes/value">
Type "counter"
Instance "database_writes"
</Key>
<Key "couchdb/httpd/bulk_requests/value">
Type "counter"
Instance "httpd/bulk_requests"
</Key>
<Key "couchdb/httpd/clients_requesting_changes/value">
Type "counter"
Instance "httpd/clients_requesting_changes"
</Key>
<Key "couchdb/httpd_request_methods/COPY/value">
Type "counter"
Instance "httpd_request_methods/COPY"
</Key>
<Key "couchdb/httpd_request_methods/DELETE/value">
Type "counter"
Instance "httpd_request_methods/DELETE"
</Key>
<Key "couchdb/httpd_request_methods/GET/value">
Type "counter"
Instance "httpd_request_methods/GET"
</Key>
<Key "couchdb/httpd_request_methods/HEAD/value">
Type "counter"
Instance "httpd_request_methods/HEAD"
</Key>
<Key "couchdb/httpd_request_methods/OPTIONS/value">
Type "counter"
Instance "httpd_request_methods/OPTIONS"
</Key>
<Key "couchdb/httpd_request_methods/POST/value">
Type "counter"
Instance "httpd_request_methods/POST"
</Key>
<Key "couchdb/httpd_request_methods/PUT/value">
Type "counter"
Instance "httpd_request_methods/PUT"
</Key>
<Key "couchdb/httpd/requests/value">
Type "counter"
Instance "httpd/requests"
</Key>
<Key "couchdb/httpd_status_codes/200/value">
Type "counter"
Instance "httpd_status_codes/200"
</Key>
<Key "couchdb/httpd_status_codes/201/value">
Type "counter"
Instance "httpd_status_codes/201"
</Key>
<Key "couchdb/httpd_status_codes/202/value">
Type "counter"
Instance "httpd_status_codes/202"
</Key>
<Key "couchdb/httpd_status_codes/301/value">
Type "counter"
Instance "httpd_status_codes/301"
</Key>
<Key "couchdb/httpd_status_codes/304/value">
Type "counter"
Instance "httpd_status_codes/304"
</Key>
<Key "couchdb/httpd_status_codes/400/value">
Type "counter"
Instance "httpd_status_codes/400"
</Key>
<Key "couchdb/httpd_status_codes/401/value">
Type "counter"
Instance "httpd_status_codes/401"
</Key>
<Key "couchdb/httpd_status_codes/403/value">
Type "counter"
Instance "httpd_status_codes/403"
</Key>
<Key "couchdb/httpd_status_codes/404/value">
Type "counter"
Instance "httpd_status_codes/404"
</Key>
<Key "couchdb/httpd_status_codes/405/value">
Type "counter"
Instance "httpd_status_codes/405"
</Key>
<Key "couchdb/httpd_status_codes/409/value">
Type "counter"
Instance "httpd_status_codes/409"
</Key>
<Key "couchdb/httpd_status_codes/412/value">
Type "counter"
Instance "httpd_status_codes/412"
</Key>
<Key "couchdb/httpd_status_codes/500/value">
Type "counter"
Instance "httpd_status_codes/500"
</Key>
<Key "couchdb/httpd/temporary_view_reads/value">
Type "counter"
Instance "httpd/temporary_view_reads"
</Key>
<Key "couchdb/httpd/view_reads/value">
Type "counter"
Instance "httpd/view_reads"
</Key>
<Key "couchdb/open_databases/value">
Type "gauge"
Instance "open_databases"
</Key>
<Key "couchdb/open_os_files/value">
Type "gauge"
Instance "open_os_files"
</Key>
# couchdb/request_time is a histogram. The values I'd most like
# to export as metrics --
# couchdb/request_time/value/percentile[{50,75,90,95,99,999}] --
# are not available. Hence, we will not export anything from
# couchdb/request_time.

<Key "couch_replicator/checkpoints/failure/value">
Type "counter"
Instance "replicator/checkpoints/failure"
</Key>
<Key "couch_replicator/checkpoints/success/value">
Type "counter"
Instance "replicator/checkpoints/success"
</Key>
<Key "couch_replicator/cluster_is_stable/value">
Type "gauge"
Instance "replicator/cluster_is_stable"
</Key>
<Key "couch_replicator/requests/value">
Type "counter"
Instance "replicator/requests"
</Key>
<Key "couch_replicator/responses/failure/value">
Type "counter"
Instance "replicator/responses/failure"
</Key>
<Key "couch_replicator/responses/success/value">
Type "counter"
Instance "replicator/responses/success"
</Key>
</URL>
</Plugin>

LoadPlugin match_regex
LoadPlugin target_set
LoadPlugin target_replace
<Chain "curl_json_couchdb">
<Rule "rewrite_curl_json_to_couchdb">
<Match regex>
Plugin "^curl_json$"
PluginInstance "^couchdb.*$"
</Match>
<Target "replace">
PluginInstance "^couchdb" ""
</Target>
<Target "set">
Plugin "couchdb"
MetaData "stackdriver_metric_type" "custom.googleapis.com/couchdb/%{type_instance}"
MetaData "label:service_name" "couchdb"
</Target>
</Rule>
<Rule "rewrite_empty_plugininstance">
<Match regex>
PluginInstance "^$"
</Match>
<Target "set">
PluginInstance "localhost"
</Target>
</Rule>
<Rule "go_back">
Target "return"
</Rule>
</Chain>

<Chain "PreCache">
<Rule "jump_to_curl_json_couchdb">
<Target "jump">
Chain "curl_json_couchdb"
</Target>
</Rule>
</Chain>
PreCacheChain "PreCache"
EOL
fi