--- layout: default description: The ArangoDB web interface shows a nice summary of the current state --- Monitoring ArangoDB using collectd ================================== Problem ------- The ArangoDB web interface shows a nice summary of the current state. I want to see similar numbers in my monitoring system so I can analyze the system usage post mortem or send alarms on failure. Solution -------- [Collectd](http://collectd.org){:target="_blank"} is an excellent tool to gather all kinds of metrics from a system, and deliver it to a central monitoring like [Graphite](http://graphite.wikidot.com/screen-shots){:target="_blank"} and / or [Nagios](http://www.nagios.org/){:target="_blank"}. ### Ingredients For this recipe you need to install the following tools: - [collectd >= 5.4.2](https://collectd.org/){:target="_blank"} The aggregation Daemon - [kcollectd](https://www.forwiss.uni-passau.de/~berberic/Linux/kcollectd.html){:target="_blank"} for inspecting the data ### Configuring collectd For aggregating the values we will use the [cURL-JSON plug-in](https://collectd.org/wiki/index.php/Plugin:cURL-JSON){:target="_blank"}. We will store the values using the [Round-Robin-Database writer](https://collectd.org/wiki/index.php/RRD){:target="_blank"}(RRD) which `kcollectd` can later on present to you. We assume your `collectd` comes from your distribution and reads its config from `/etc/collectd/collectd.conf`. Since this file tends to become pretty unreadable quickly, we use the `include` mechanism: Filter "*.conf" This way we can make each metric group on compact set config files. It consists of three components: * loading the plug-in * adding metrics to the TypesDB * the configuration for the plug-in itself ### rrdtool We will use the [Round-Robin-Database](http://oss.oetiker.ch/rrdtool/){:target="_blank"} as storage backend for now. It creates its own database files of fixed size for each specific time range. Later you may choose more advanced writer-plug-ins, which may do network distribution of your metrics or integrate the above mentioned Graphite or your already established monitoring, etc. For the RRD we will go pretty much with defaults: # Load the plug-in: LoadPlugin rrdtool DataDir "/var/lib/collectd/rrd" # CacheTimeout 120 # CacheFlush 900 # WritesPerSecond 30 # CreateFilesAsync false # RandomTimeout 0 # # The following settings are rather advanced # and should usually not be touched: # StepSize 10 # HeartBeat 20 # RRARows 1200 # RRATimespan 158112000 # XFF 0.1 ### cURL JSON `Collectd` comes with a wide range of metric aggregation plug-ins. Many tools today use [JSON](http://json.org){:target="_blank"} as data formatting grammar; so does ArangoDB. Therefore a plug-in offering to fetch JSON documents via HTTP is the perfect match to query ArangoDBs [administrative Statistics interface](../http/administration-and-monitoring.html#read-the-statistics): # Load the plug-in: LoadPlugin curl_json # we need to use our own types to generate individual names for our gauges: # TypesDB "/etc/collectd/arangodb_types.db" # Adjust the URL so collectd can reach your arangod: # Set your authentication to Aardvark here: User "root" # Password "bar" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "gauge" Type "client_totalTime_count" Type "client_totalTime_sum" Type "client_totalTime_counts0" Type "client_bytesReceived_count" Type "client_bytesReceived_sum" Type "client_bytesReceived_counts0" Type "client_requestTime_count" Type "client_requestTime_sum" Type "client_requestTime_counts0" Type "client_connectionTime_count" Type "client_connectionTime_sum" Type "client_connectionTime_counts0" Type "client_queueTime_count" Type "client_queueTime_sum" Type "client_queueTime_counts0" Type "client_bytesSent_count" Type "client_bytesSent_sum" Type "client_bytesSent_counts0" Type "client_ioTime_count" Type "client_ioTime_sum" Type "client_ioTime_counts0" Type "gauge" To circumvent the shortcoming of the curl_JSON plug-in to only take the last path element as name for the metric, we need to give them a name using our own `types.db` file in `/etc/collectd/arangodb_types.db`: client_totalTime_count value:GAUGE:0:9223372036854775807 client_totalTime_sum value:GAUGE:U:U client_totalTime_counts0 value:GAUGE:U:U client_bytesReceived_count value:GAUGE:0:9223372036854775807 client_bytesReceived_sum value:GAUGE:U:U client_bytesReceived_counts0 value:GAUGE:U:U client_requestTime_count value:GAUGE:0:9223372036854775807 client_requestTime_sum value:GAUGE:U:U client_requestTime_counts0 value:GAUGE:U:U client_connectionTime_count value:GAUGE:0:9223372036854775807 client_connectionTime_sum value:GAUGE:U:U client_connectionTime_counts0 value:GAUGE:U:U client_queueTime_count value:GAUGE:0:9223372036854775807 client_queueTime_sum value:GAUGE:U:U client_queueTime_counts0 value:GAUGE:U:U client_bytesSent_count value:GAUGE:0:9223372036854775807 client_bytesSent_sum value:GAUGE:U:U client_bytesSent_counts0 value:GAUGE:U:U client_ioTime_count value:GAUGE:0:9223372036854775807 client_ioTime_sum value:GAUGE:U:U client_ioTime_counts0 value:GAUGE:U:U Please note that you probably need to uncomment this line from the main collectd.conf: # TypesDB "/usr/share/collectd/types.db" "/etc/collectd/my_types.db" in order to make it still load its main types definition file. ### Rolling your own You may want to monitor your own metrics from ArangoDB. Here is a simple example how to use the `config`: { "testArray":[1,2], "testArrayInbetween":[{"blarg":3},{"blub":4}], "testDirectHit":5, "testSubLevelHit":{"oneMoreLevel":6} } This `config` snippet will parse the JSON above: Type "gauge" # Expect: 1 Type "gauge" # Expect: 2 Type "gauge" # Expect: 3 Type "gauge" # Expect: 4 Type "gauge" # Expect: 5 Type "gauge" # Expect: 6