Thursday, December 19, 2013

Viewing New Relic Audit Logs When Not Using Ruby

Although New Relic is great for viewing the status of running web applications, at our startup (which deals with patient data) we wanted to be sure that we weren't sending any private data to New Relic. For all of the Ruby developers out there, this is a simple task by following their instructions on their website. For the rest of us, however, there aren't any clear instructions. Fortunately, that doesn't mean that it is hard to do!

All you have to do is modify your newrelic.ini file as follows:
  1. Uncomment the line: log_file = /tmp/newrelic-python-agent.log
  2. Then set the log_level setting to debug
  3. Underneath the log_level line, add the following:
    debug.log_data_collector_payloads = True
    debug.log_agent_initialization = True
    debug.log_data_collector_calls = True
    debug.log_transaction_trace_payload = True
    debug.log_thread_profile_payload = True
    debug.log_raw_metric_data = True
  4. Restart your application that loads the New Relic agent.
You now can enjoy staring at all of the data that is being sent to New Relic by watching the log file
tail -f /tmp/newrelic-python-agent.log
As you might have guessed, this will create a large log file, so make sure to turn off these settings when you are done with them (or ensure that you are properly rotating your logs).

According to New Relic support, the debug.log_data_collector_payloads setting is what will log every data message sent to the New Relic collector. As this data is encoded and compressed, the other settings above are what decode the data and print them out in human readable form.

If you are not seeing any logging output in your log file, make sure that you are not running into any issues due to logger conflicts. For example, if you disable existing loggers in your app, you won't see any output. For further details take a look at this article put together by the folks at NewRelic.