Adding API for listing event filters for instance level
What does this MR do and why?
This MR adds ability to list down event filters associated with an instance level external audit event destination. Event filters are used for filtering of audit events while streaming to external audit event destinations. API for creating audit event filters was added in !124605 (merged).
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- You need to have Ultimate license for your instance.
- Enable feature flag by running
::Feature.enable(:ff_external_audit_events)
in rails console. - Login with instance administrator account at http://gitlab.localdev:3000/(or whatever your local gitlab setup url is).
- Then visit http://gitlab.localdev:3000/-/graphql-explorer for running graphql queries and mutations.
- Run following mutation for creating a new instance level external audit event destination
mutation {
instanceExternalAuditEventDestinationCreate(input: { destinationUrl: "https://www.example.com"}) {
errors
instanceExternalAuditEventDestination {
destinationUrl
id
}
}
}
- Note the destination id in response and create an event type filter for this destination by running following mutation, you should not receive any errors and this will return all the event filters for the destination.
mutation {
auditEventsStreamingDestinationInstanceEventsAdd(
input: {
destinationId: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/<id>",
eventTypeFilters:["filter1", "filter2"]
}
){
errors
eventTypeFilters
}
}
- List down the destinations with their respective event filters by running following query:
query {
instanceExternalAuditEventDestinations {
nodes {
id
destinationUrl
verificationToken
eventTypeFilters
}
}
}
- Output of query in step 7 should be something like:
{
"data": {
"instanceExternalAuditEventDestinations": {
"nodes": [
{
"id": "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/39",
"destinationUrl": "https://www.example.com",
"verificationToken": "XSY4FpJCZfW5PnkKpJxiHJAy",
"eventTypeFilters": [
"filter5",
"filter7"
]
}
]
}
}
}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #415769 (closed)
Edited by Hitesh Raghuvanshi