Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Commit

Permalink
Update/document loggly recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
till committed Jul 4, 2012
1 parent 2254d93 commit e1eaaeb
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 25 deletions.
67 changes: 67 additions & 0 deletions loggly/README.md
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,67 @@
# loggly

## Requirements

* Ubuntu
* Ruby (in `/usr/local/bin`)
* rsyslog
* [loggly](http://loggly.com) (syslog (TCP) input)

## Usage

Add this to your runlist: `loggly::setup`

## How does it work?

We hope it's pretty simple and straight forward:

* we write a configuration for rsyslog to send all data to loggly
* each instance gets a `loggly` init-script, which is customized with necessary variables: user, password, ...)
* we install a script called `deviceid` (called from the init script)
* init-script is ran during boot process and shutdown

## Customization (aka attribute files)

Edit the `attributes/default.rb` or read on.

If you happen to use Scalarium, edit your _cloud json_ via the cloud overview, then actions and edit cloud.

### loggly

Set the following in your `node.json`:

{
"loggly": {
"domain": "example",
"input": 1,
"user": "account",
"pass": "password"
}
}

Domain is your _subdomain_, e.g. http://example.loggly.com.

### rsyslog

So, yeah - this recipe uses the syslog (TCP) transport only.

For rsyslog's configuration, we have a few options as well:

{
"syslog": {
"logfiles": {
"/var/log/nginx/error.log": "error",
"/var/log/php/slow.log" => "notice"
"/var/log/php/fpm.log" => "error"
},
"host": "logs.loggly.com",
"haproxy": {
"log_dir": "/mnt/logs/haproxy",
"poll": 10
}
}
}

`logfiles` should be interesting since this allows us to configure rsyslog to pick up logfiles as well.

The haproxy-related bits are Scalarium specific. We should probably spin this off some time (PRs welcome!).
20 changes: 20 additions & 0 deletions loggly/recipes/scalarium.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,20 @@
# this is specific to our setup and is only triggered on scalarium
if node[:scalarium]
if node[:scalarium][:instance][:roles].include?('loadbalancer')

template "/etc/rsyslog.d/10-haproxy.conf" do
source "10-haproxy.conf.erb"
mode "0644"
end

directory "#{node[:syslog][:haproxy][:log_dir]}" do
recursive true
mode "0755"
end

service "rsyslog" do
supports :status => true, :restart => true, :reload => true
action [ :restart ]
end
end
end
5 changes: 5 additions & 0 deletions loggly/recipes/service.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,5 @@
service "loggly" do
supports :start => true, :stop => true
running false
action [ :enable, :start ]
end
28 changes: 3 additions & 25 deletions loggly/recipes/setup.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
gem_package "json" gem_package "json"


if node[:loggly] && (node[:loggly][:domain] != 'example') if node[:loggly] && (node[:loggly][:domain] != 'example')

template "/etc/rsyslog.d/10-loggly.conf" do template "/etc/rsyslog.d/10-loggly.conf" do
source "10-loggly.conf.erb" source "10-loggly.conf.erb"
mode "0644" mode "0644"
Expand All @@ -22,28 +23,5 @@
end end
end end


if node[:scalarium] include_recipe "loggly::scalarium"
if node[:scalarium][:instance][:roles].include?('loadbalancer') include_recipe "loggly::service"

template "/etc/rsyslog.d/10-haproxy.conf" do
source "10-haproxy.conf.erb"
mode "0644"
end

directory "#{node[:syslog][:haproxy][:log_dir]}" do
recursive true
mode "0755"
end

service "rsyslog" do
supports :status => true, :restart => true, :reload => true
action [ :restart ]
end
end
end

service "loggly" do
supports :start => true, :stop => true
running false
action [ :enable, :start ]
end

0 comments on commit e1eaaeb

Please sign in to comment.