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 ClusterID: Rails.configuration.ClusterID,
13 request_id: event.payload[:request_id],
14 client_ipaddr: event.payload[:client_ipaddr],
15 client_auth: event.payload[:client_auth],
18 # Lograge adds exceptions not being rescued to event.payload, but we're
19 # catching all errors on ApplicationController so we look for backtraces
21 if !Thread.current[:backtrace].nil?
24 exception: Thread.current[:exception],
25 exception_backtrace: Thread.current[:backtrace],
28 Thread.current[:exception] = nil
29 Thread.current[:backtrace] = nil
32 exceptions = %w(controller action format id)
33 params = event.payload[:params].except(*exceptions)
35 # Omit secret_mounts field if supplied in create/update request
38 ['container', 'secret_mounts'],
39 ['container_request', 'secret_mounts'],
40 ].each do |resource, field|
41 if params[resource].is_a? Hash
42 params[resource] = params[resource].except(field)
46 # Redact new_user_token param in /arvados/v1/users/merge
47 # request. Log the auth UUID instead, if the token exists.
48 if params['new_user_token'].is_a? String
49 params['new_user_token_uuid'] =
50 ApiClientAuthorization.
51 where('api_token = ?', params['new_user_token']).
53 params['new_user_token'] = '[...]'
56 params_s = SafeJSON.dump(params)
57 if params_s.length > Rails.configuration.SystemLogs["MaxRequestLogParamsSize"]
58 payload[:params_truncated] = params_s[0..Rails.configuration.SystemLogs["MaxRequestLogParamsSize"]] + "[...]"
60 payload[:params] = params