Skip to content

Create consolidated instance event filters table and model

Hitesh Raghuvanshi requested to merge 436604-event-filters-instance into master

What does this MR do and why?

This MR is introducing audit event type filters for newly introduced instance-level external audit event destinations.

Refer &12339 for the whole proposal and implementation plan.

This is very similar to what was created for group level destinations in !144139 (merged).

Migrations


## up

bundle exec rake db:migrate:up:main VERSION=20240221145450
main: == [advisory_lock_connection] object_id: 119440, pg_backend_pid: 18556
main: == 20240221145450 CreateAuditEventsInstanceStreamingEventTypeFilters: migrating
main: -- create_table(:audit_events_instance_streaming_event_type_filters)
main: -- quote_column_name(:audit_event_type)
main:    -> 0.0000s
main:    -> 0.0090s
main: == 20240221145450 CreateAuditEventsInstanceStreamingEventTypeFilters: migrated (0.0806s)

main: == [advisory_lock_connection] object_id: 119440, pg_backend_pid: 18556

## down

bundle exec rake db:migrate:down:main VERSION=20240221145450
main: == [advisory_lock_connection] object_id: 119480, pg_backend_pid: 18107
main: == 20240221145450 CreateAuditEventsInstanceStreamingEventTypeFilters: reverting
main: -- drop_table(:audit_events_instance_streaming_event_type_filters)
main:    -> 0.0125s
main: == 20240221145450 CreateAuditEventsInstanceStreamingEventTypeFilters: reverted (0.0218s)

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.

How to set up and validate locally

  1. Checkout the branch and run migration.
  2. Open rails console.
  3. You can create an instance level destination by running following command in console a = AuditEvents::Instance::ExternalStreamingDestination.create(name: 'Hello', category: 'http', config: {url: 'https://www.example.com'}, secret_token: 'asdasd')
  4. You can then create the event filter for the destination by running b = a.event_type_filters.create(audit_event_type: 'event_type_filters_created')
  5. Then you can get list of filters for the destination or the destination for the filter
a.event_type_filters

b.external_streaming_destination

Related to #436604 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports