1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 Server::Application.configure do
8 config.lograge.enabled = true
9 config.lograge.formatter = Lograge::Formatters::Logstash.new
10 config.lograge.custom_options = lambda do |event|
12 request_id: event.payload[:request_id],
13 client_ipaddr: event.payload[:client_ipaddr],
14 client_auth: event.payload[:client_auth],
17 # Lograge adds exceptions not being rescued to event.payload, but we're
18 # catching all errors on ApplicationController so we look for backtraces
20 if !Thread.current[:backtrace].nil?
23 exception: Thread.current[:exception],
24 exception_backtrace: Thread.current[:backtrace],
27 Thread.current[:exception] = nil
28 Thread.current[:backtrace] = nil
31 exceptions = %w(controller action format id)
32 params = event.payload[:params].except(*exceptions)
34 # Omit secret_mounts field if supplied in create/update request
37 ['container', 'secret_mounts'],
38 ['container_request', 'secret_mounts'],
39 ].each do |resource, field|
40 if params[resource].is_a? Hash
41 params[resource] = params[resource].except(field)
45 # Redact new_user_token param in /arvados/v1/users/merge
46 # request. Log the auth UUID instead, if the token exists.
47 if params['new_user_token'].is_a? String
48 params['new_user_token_uuid'] =
49 ApiClientAuthorization.
50 where('api_token = ?', params['new_user_token']).
52 params['new_user_token'] = '[...]'
55 params_s = SafeJSON.dump(params)
56 if params_s.length > Rails.configuration.SystemLogs["MaxRequestLogParamsSize"]
57 payload[:params_truncated] = params_s[0..Rails.configuration.SystemLogs["MaxRequestLogParamsSize"]] + "[...]"
59 payload[:params] = params