In my day job we use the excellent Librato Metrics service to push all our metrics data to for monitoring and visualisation. We've been primarily using StatsD to collect metrics from our various applications, and the AWS integration for data on those services. Something we've been missing though is some server level information that isn't provided with Cloudwatch (specifically disk space and memory). I've been meaning to try using collectd to collect this and then push it off to Librato somehow. Then luckily the Librato team announced native integration...
Just what we needed!
Luckily Collectd was available through the package manager on our current distribution, so I set right to creating an Ansible role for it...
# roles/collectd/tasks/main.yml
---
- name: Package Installed
yum: pkg=collectd state=present
tags:
- collectd
- name: Configured
template: src=collectd.conf.j2 dest=/etc/collectd.conf
owner=root group=root mode=644
tags:
- collectd
notify:
- restart collectd
- name: Service Running
service: name=collectd state=started enabled=true
tags:
- collectd
With the associated handler...
# roles/collectd/handlers/main.yml
---
- name: restart collectd
service: name=collectd state=restarted
And basic configuration file for testing the setup on my VM...
# roles/collectd/templates/collectd.conf.j2
Hostname "{{ inventory_hostname_short }}"
FQDNLookup false
LoadPlugin load
LoadPlugin memory
LoadPlugin df
LoadPlugin write_http
<Plugin write_http>
<URL "https://collectd.librato.com/v1/measurements">
User "{{ librato_email }}"
Password "{{ librato_token }}"
Format "JSON"
</URL>
</Plugin>
Include "/etc/collectd.d"
Helpfully the configuration is provided when you enable the service integration in Librato as well:
After adding the role I quickly reprovisioned my development VM and switched to Librato to watch the data roll in... and it did! Some quick testing, deployment to our test environment for final checking and then it was straight out to production - thanks Librato!
The collectd plugins are easily configured now through my Ansible scripts, time to dive in to the data! :)