We implemented a custom company_transaction_id
attribute to be added to each log of our application (we use Lograge and its custom_payload
method for that). It is included in the log_summary attribute column in the Logs UI, and in a message.company_transaction_id
attribute column. We would like to have it at the root of the log data in a company_transaction_id
attribute column.
It seems that the log summary line issued at the end of Rails requests is considered as the message payload by the New Relic Agent though.
We have seen that custom parsing rules can be added, but it seems that it is only applicable to the message column. We couldn’t parse the data of the log_summary column.
Did we miss something? Do you have ideas on how we could fix this?
Many thanks for the help
# Example of log summary line
{"method":"GET","path":"/en/tours","format":"html","controller":"ToursController","action":"index","status":200,"duration":5266.62,"view":5129.3,"db":66.67,"params":{"locale":"en"},"host":"localhost","user_id":565,"locale":"en","company_transaction_id":"9143c008-73c2-4230-a02d-db66ed16f218"}
# Our config
config.log_formatter = NewRelic::Agent::Logging::DecoratingFormatter.new
config.lograge.enabled = true
config.lograge.formatter = Lograge::Formatters::Json.new
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']
config.lograge.keep_original_rails_log = false
config.lograge.custom_payload do |controller|
{
host: controller.request.host,
user_id: controller.try(:current_user).try(:id),
locale: I18n.locale,
company_transaction_id: controller.try(:company_transaction_id)
}
end