Skip to content

Redis counter for streaming audit event types

What does this MR do and why?

We want to track number of audit events stream for each audit event type and for this we are going to use service ping. This MR makes Redis counter and also sets count for every streamed audit event type.

How to set up and validate locally

  1. Add a streaming destination https://docs.gitlab.com/ee/administration/audit_event_streaming.html#add-a-new-streaming-destination
  2. Stream any audit event for example download project zip from project page
  3. This should increase counter and we can check so by Gitlab::UsageDataCounters::StreamingAuditEventTypeCounter.totals
  4. Also run below script to check all the metric definitions are correctly incrementing counter.
event_names = ["allow_committer_approval_updated", "allow_overrides_to_approver_list_per_merge_request_updated", "retain_approvals_on_push_updated", "delete_work_item", "delete_merge_request", "allow_author_approval_updated", "delete_issue", "project_fork_relationship_removed", "set_runner_associated_projects", "delete_epic", "require_password_to_approve_updated"]

## manually incr count 

event_names.each do |event|
  Gitlab::UsageDataCounters::StreamingAuditEventTypeCounter.count(event)
end


## get payload data

payload = ServicePing::BuildPayload.new.execute

counts = {}

event_names.each do |name|
  counts[name] = payload['counts'][name]
end

puts counts

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #361794 (closed)

Edited by Harsimar Sandhu

Merge request reports