Insert Wit Here

Posts Tagged ‘logging

Structured log output from puppet

A post on puppet-users got me thinking about improved output. A simple method is to just JSON encode the log and parse the message objects on the other side. So here’s an easy way to do that.

This works pretty well with puppet master & puppet apply:

tmp donavanm$ puppet apply /tmp/test.pp --logdest json
{"level":"notice","time":"Sat Feb 19 17:01:12 -0800 2011","tags":["notice"],"source":"Puppet","message":"this is a message"}
{"line":1,"level":"notice","time":"Sat Feb 19 17:01:12 -0800 2011","tags":["notice","notify","class"],"file":"/tmp/test.pp","source":"/Stage[main]//Notify[this is a message]/message","message":"defined 'message' as 'this is a message'"}
{"level":"notice","time":"Sat Feb 19 17:01:12 -0800 2011","tags":["notice"],"source":"Puppet","message":"Finished catalog run in 0.06 seconds"}

It works less well with puppet agent, unfortunately. If --verbose or --debug is specified the :console destination is added, so you’ll get duplicate messages. Lame.

Currently there’s no way to load this as a plugin, see #6522. Appending this method to puppet/util/log/destinations.rb works. Meh.

Ideally I think we’d have different options for transaction reports. Currently the agent application always forces reports to the rest terminus. Being able to set up multiple destinations, like nagios or a local cache, would be great.

Update I’d previously mentioned #4248, which is similar but not what I really want. Updated with the correct issue. Also opened #6523 to clean up logdest handling in applications like agent.

Written by donavan

2011/02/19 at 17:28

Posted in Software

Tagged with ,