Add filtering to unique count metrics
What does this MR do and why?
Adds support for filtered unique count metrics.
For example, a metric definition could look like this:
time_frame: 7d
events:
- name: pull_package
unique: user.id
filter:
label: rubygems
And would define a metric that "counts the number of unique users that pulled a rubygems package during the last week"
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Get some metric definitions with filters:
curl https://gitlab.com/gitlab-org/gitlab/-/commit/8024c609b1b68d0892dfe8fe41bcfe4dad1867d4.diff | git apply -
- Start the monitor:
rails runner scripts/internal_events/monitor.rb perform_epics_action
- Trigger events from the rails console:
Gitlab::InternalEvents.track_event('perform_epics_action', user: User.first, additional_properties: {label: 'abc'})
Gitlab::InternalEvents.track_event('perform_epics_action', user: User.first, additional_properties: {label: 'xyz'})
Gitlab::InternalEvents.track_event('perform_epics_action', user: User.second, additional_properties: {label: 'xyz'})
Gitlab::InternalEvents.track_event('perform_epics_action', user: User.first)
Gitlab::InternalEvents.track_event('perform_epics_action', user: User.first, additional_properties: {label: 'foo'})
- Check that the values in the monitor is updating as expected.
Edited by Jonas Larsen