Skip to content

Commit

Permalink
Add monitoring for Event::ServiceFail
Browse files Browse the repository at this point in the history
We need to see in monitoring / be alerted about excessive ServiceFail events
to fix issues before too many users are affected.

We map service success+fail onto the same key in the monitoring
so that we can consider them together.
  • Loading branch information
bmwiedemann committed Feb 8, 2023
1 parent 96eb354 commit 6b9c6fa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/api/app/models/event/service_fail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ def set_payload(attribs, keys)
attribs['error'] = attribs['error'][0..800]
super(attribs, keys)
end

def metric_measurement
'service'
end

def metric_tags
error = case payload['error']
when start_with?('bad link:')
'bad_link'
when /^ 400 remote error:.*.service No such file or directory/
'service_missing'
when /^ 400 remote error:.*service parameter.*is not defined/
'unknown_service_parameter'
else
'unknown'
end

{
status: 'fail',
error: error
}
end

def metric_fields
{ value: 1 }
end
end
end

Expand Down
14 changes: 14 additions & 0 deletions src/api/app/models/event/service_success.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ def custom_headers
h['X-OBS-Package'] = "#{payload['project']}/#{payload['package']}"
h
end

def metric_measurement
'service'
end

def metric_tags
{
status: 'success'
}
end

def metric_fields
{ value: 1 }
end
end
end

Expand Down

0 comments on commit 6b9c6fa

Please sign in to comment.