Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
LogentriesAlertsController
class LogentriesAlertsController < ApplicationController
skip_before_action :verify_authenticity_token
def create
return head(:unprocessable_entity) unless
LogentriesAuth.new(request).authorized?
if what =~ /R1[45]/ &&
who =~ /web\.\d+/
Redis.current.set(
"puma::stop::#{who}",
"*** HEROKU ERROR #{what} ***",
ex: 60.seconds
)
end
head :ok
end
private
def logentries_payload
params.require(:payload)
end
def message
@message ||= JSON
.parse(logentries_payload)
.dig('event', 'm')
end
def who
@who ||= message
.match(/heroku ([^\s]+)/)
.to_a
.dig(1)
end
def what
@what ||= message
.match(/- - Error (\w\d+) /)
.to_a
.dig(1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment