Skip to content

Commit

Permalink
Merge pull request #637 from alphagov/configure-lograge
Browse files Browse the repository at this point in the history
Configure lograge to ignore spammy actions
  • Loading branch information
pixeltrix authored Dec 1, 2017
2 parents f5224dd + a2dfb3b commit bf0d14c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/controllers/admin/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class Admin::AdminController < ApplicationController
def index
end

def admin_request?
true
end

private

def set_appsignal_namespace
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/archived/locks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def destroy
end
end

private

def last_request_update_allowed?
false
end

private

def fetch_petition
@petition = ::Archived::Petition.find(params[:petition_id])
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/locks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def destroy
end
end

private

def last_request_update_allowed?
false
end

private

def fetch_petition
@petition = Petition.find(params[:petition_id])
end
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class ApplicationController < ActionController::Base
before_action :set_seen_cookie_message, if: :show_cookie_message?
helper_method :show_cookie_message?, :public_petition_facets

hide_action :admin_request?

def admin_request?
false
end

protected

def authenticate
Expand Down
16 changes: 16 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@

# Turn on lograge, to give us more parseable logs
config.lograge.enabled = true
config.lograge.ignore_actions = %w[
PingController#ping
Admin::UserSessionsController#status
Admin::LocksController#show
Admin::LocksController#create
Admin::LocksController#update
Admin::LocksController#destroy
Admin::Archived::LocksController#show
Admin::Archived::LocksController#create
Admin::Archived::LocksController#update
Admin::Archived::LocksController#destroy
]

config.lograge.custom_payload do |controller|
controller.admin_request? ? { user_id: controller.current_user.try(:id) } : {}
end

# Log in logstash format, so that we can easily parse the output
config.logger = LogStashLogger.new(
Expand Down

0 comments on commit bf0d14c

Please sign in to comment.