From 525b2653d85635b41c3ba5f4fc7e33851c3e83cf Mon Sep 17 00:00:00 2001 From: Tyler Roscoe Date: Mon, 3 Dec 2018 22:04:17 -0700 Subject: [PATCH 1/5] Add configurator/couchdb.sh. This is an unmodified copy of https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/couchdb.conf. I'm adding it here to aid interdiffing and to show the version from which I started. --- configurator/couchdb.sh | 137 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 configurator/couchdb.sh diff --git a/configurator/couchdb.sh b/configurator/couchdb.sh new file mode 100644 index 0000000..6acf850 --- /dev/null +++ b/configurator/couchdb.sh @@ -0,0 +1,137 @@ +# This is the monitoring configuration for CouchDB. +# Look for COUCHDB_HOST and COUCHDB_PORT to adjust your configuration file. +LoadPlugin curl_json + + # When using non-standard CouchDB configurations, replace the below with + # + + Instance "couchdb" + + + Type "counter" + + + Type "counter" + + + Type "gauge" + + + Type "gauge" + + + Type "gauge" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + Type "counter" + + + + +LoadPlugin match_regex +LoadPlugin target_set +LoadPlugin target_replace + + + + Plugin "^curl_json$" + PluginInstance "^couchdb.*$" + + + PluginInstance "^couchdb" "" + + + Plugin "couchdb" + + + + + PluginInstance "^$" + + + PluginInstance "localhost" + + + + Target "return" + + + + + + + Chain "curl_json_couchdb" + + + +PreCacheChain "PreCache" + From 6026c2676974efb87160e293fea444fd7bcc5fc0 Mon Sep 17 00:00:00 2001 From: Tyler Roscoe Date: Mon, 3 Dec 2018 22:17:01 -0700 Subject: [PATCH 2/5] Adapt couchdb.sh. * Add shell stackdriver-agent shell wrapper. * Change to CouchDB 2.x metrics names. * Export metrics in custom namespace since they no longer match predefined metrics names. --- .gitignore | 1 + configurator/couchdb.sh | 118 ++++++++++++++++++++++++++++------------ 2 files changed, 83 insertions(+), 36 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3268211 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.*.sw? diff --git a/configurator/couchdb.sh b/configurator/couchdb.sh index 6acf850..09d3cef 100644 --- a/configurator/couchdb.sh +++ b/configurator/couchdb.sh @@ -1,98 +1,141 @@ +#!/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 < /opt/stackdriver/collectd/etc/collectd.d/couchdb.conf # This is the monitoring configuration for CouchDB. -# Look for COUCHDB_HOST and COUCHDB_PORT to adjust your configuration file. +# +# 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 - # When using non-standard CouchDB configurations, replace the below with - # - + # For example: + # + Instance "couchdb" - + Type "counter" + Instance "database_writes" - + Type "counter" + Instance "database_reads" - + Type "gauge" + Instance "open_databases" - + Type "gauge" + Instance "open_os_files" - - Type "gauge" - - + # 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. + Type "counter" + Instance "httpd/bulk_requests" - + Type "counter" + Instance "httpd/requests" - + Type "counter" + Instance "httpd/temporary_view_reads" - + Type "counter" + Instance "httpd/view_reads" - + Type "counter" + Instance "httpd_request_methods/COPY" - + Type "counter" + Instance "httpd_request_methods/DELETE" - + Type "counter" + Instance "httpd_request_methods/GET" - + Type "counter" + Instance "httpd_request_methods/HEAD" - + Type "counter" + Instance "httpd_request_methods/OPTIONS" - + Type "counter" + Instance "httpd_request_methods/POST" - + Type "counter" + Instance "httpd_request_methods/PUT" - + Type "counter" + Instance "httpd_status_codes/200" - + Type "counter" + Instance "httpd_status_codes/201" - + Type "counter" + Instance "httpd_status_codes/202" - + Type "counter" + Instance "httpd_status_codes/301" - + Type "counter" + Instance "httpd_status_codes/304" - + Type "counter" + Instance "httpd_status_codes/400" - + Type "counter" + Instance "httpd_status_codes/401" - + Type "counter" + Instance "httpd_status_codes/403" - + Type "counter" + Instance "httpd_status_codes/404" - + Type "counter" + Instance "httpd_status_codes/405" - + Type "counter" + Instance "httpd_status_codes/409" - + Type "counter" + Instance "httpd_status_codes/412" - + Type "counter" + Instance "httpd_status_codes/500" @@ -111,6 +154,8 @@ LoadPlugin target_replace Plugin "couchdb" + MetaData "stackdriver_metric_type" "custom.googleapis.com/couchdb/%{type_instance}" + MetaData "label:service_name" "couchdb" @@ -134,4 +179,5 @@ LoadPlugin target_replace PreCacheChain "PreCache" - +EOL +fi From e6862805514ec8a9b4d385fcb8a450ae37b8d12b Mon Sep 17 00:00:00 2001 From: Tyler Roscoe Date: Tue, 4 Dec 2018 21:10:17 -0700 Subject: [PATCH 3/5] Sort entries. --- configurator/couchdb.sh | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/configurator/couchdb.sh b/configurator/couchdb.sh index 09d3cef..47a7251 100644 --- a/configurator/couchdb.sh +++ b/configurator/couchdb.sh @@ -20,43 +20,18 @@ LoadPlugin curl_json Instance "couchdb" - - Type "counter" - Instance "database_writes" - Type "counter" Instance "database_reads" - - Type "gauge" - Instance "open_databases" - - - Type "gauge" - Instance "open_os_files" + + Type "counter" + Instance "database_writes" - # 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. Type "counter" Instance "httpd/bulk_requests" - - Type "counter" - Instance "httpd/requests" - - - Type "counter" - Instance "httpd/temporary_view_reads" - - - Type "counter" - Instance "httpd/view_reads" - Type "counter" Instance "httpd_request_methods/COPY" @@ -85,6 +60,10 @@ LoadPlugin curl_json Type "counter" Instance "httpd_request_methods/PUT" + + Type "counter" + Instance "httpd/requests" + Type "counter" Instance "httpd_status_codes/200" @@ -137,6 +116,27 @@ LoadPlugin curl_json Type "counter" Instance "httpd_status_codes/500" + + Type "counter" + Instance "httpd/temporary_view_reads" + + + Type "counter" + Instance "httpd/view_reads" + + + Type "gauge" + Instance "open_databases" + + + Type "gauge" + Instance "open_os_files" + + # 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. From ef1377ba24a192fb66f21ba044058b6ae569422a Mon Sep 17 00:00:00 2001 From: Tyler Roscoe Date: Tue, 4 Dec 2018 21:47:12 -0700 Subject: [PATCH 4/5] Add a few more metrics based on ideas from: * http://gws.github.io/munin-plugin-couchdb/guide-to-couchdb-monitoring.html * https://www.site24x7.com/plugins/couchdb-monitoring.html * https://www.monitis.com/blog/a-guide-to-couchdb-installation-configuration-and-monitoring/ --- configurator/couchdb.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configurator/couchdb.sh b/configurator/couchdb.sh index 47a7251..d8eb68c 100644 --- a/configurator/couchdb.sh +++ b/configurator/couchdb.sh @@ -20,6 +20,18 @@ LoadPlugin curl_json Instance "couchdb" + + Type "counter" + Instance "auth_cache_hits" + + + Type "counter" + Instance "auth_cache_misses" + + + Type "counter" + Instance "clients_requesting_changes" + Type "counter" Instance "database_reads" From 08727c4f70f1f37be7add9c71d36e14b2706a4d6 Mon Sep 17 00:00:00 2001 From: Tyler Roscoe Date: Tue, 4 Dec 2018 21:55:17 -0700 Subject: [PATCH 5/5] Add some metrics from couch_replicator. --- configurator/couchdb.sh | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/configurator/couchdb.sh b/configurator/couchdb.sh index d8eb68c..b8200b9 100644 --- a/configurator/couchdb.sh +++ b/configurator/couchdb.sh @@ -28,10 +28,6 @@ LoadPlugin curl_json Type "counter" Instance "auth_cache_misses" - - Type "counter" - Instance "clients_requesting_changes" - Type "counter" Instance "database_reads" @@ -44,6 +40,10 @@ LoadPlugin curl_json Type "counter" Instance "httpd/bulk_requests" + + Type "counter" + Instance "httpd/clients_requesting_changes" + Type "counter" Instance "httpd_request_methods/COPY" @@ -149,6 +149,31 @@ LoadPlugin curl_json # couchdb/request_time/value/percentile[{50,75,90,95,99,999}] -- # are not available. Hence, we will not export anything from # couchdb/request_time. + + + Type "counter" + Instance "replicator/checkpoints/failure" + + + Type "counter" + Instance "replicator/checkpoints/success" + + + Type "gauge" + Instance "replicator/cluster_is_stable" + + + Type "counter" + Instance "replicator/requests" + + + Type "counter" + Instance "replicator/responses/failure" + + + Type "counter" + Instance "replicator/responses/success" +