doc/api/graphql/audit_event_streaming_instances.md
{{< details >}}
{{< /details >}}
{{< history >}}
ff_external_audit_events. Disabled by default.ff_external_audit_events. Disabled by default.ff_external_audit_events enabled by default in GitLab 16.2.ff_external_audit_events removed.{{< /history >}}
Manage audit event streaming destinations for instances by using a GraphQL API.
Manage HTTP streaming destinations for an entire instance.
Add a new HTTP streaming destination to an instance.
Prerequisites:
To enable streaming and add a destination, use the
instanceExternalAuditEventDestinationCreate mutation in the GraphQL API.
mutation {
instanceExternalAuditEventDestinationCreate(input: { destinationUrl: "https://mydomain.io/endpoint/ingest"}) {
errors
instanceExternalAuditEventDestination {
destinationUrl
id
name
verificationToken
}
}
}
Event streaming is enabled if:
errors object is empty.200 OK.You can optionally specify your own destination name (instead of the default GitLab-generated one) using the GraphQL
instanceExternalAuditEventDestinationCreate
mutation. Name length must not exceed 72 characters and trailing whitespace are not trimmed. This value should be unique. For example:
mutation {
instanceExternalAuditEventDestinationCreate(input: { destinationUrl: "https://mydomain.io/endpoint/ingest", name: "destination-name-here"}) {
errors
instanceExternalAuditEventDestination {
destinationUrl
id
name
verificationToken
}
}
}
Instance administrators can add an HTTP header using the GraphQL auditEventsStreamingInstanceHeadersCreate mutation. You can retrieve the destination ID
by listing all the streaming destinations for the instance or from the previous mutation.
mutation {
auditEventsStreamingInstanceHeadersCreate(input:
{
destinationId: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/42",
key: "foo",
value: "bar",
active: true
}) {
errors
header {
id
key
value
active
}
}
}
The header is created if the returned errors object is empty.
List all HTTP streaming destinations for an instance.
Prerequisites:
To view a list of streaming destinations for an instance, use the
instanceExternalAuditEventDestinations query type.
query {
instanceExternalAuditEventDestinations {
nodes {
id
name
destinationUrl
verificationToken
headers {
nodes {
id
key
value
active
}
}
eventTypeFilters
}
}
}
If the resulting list is empty, then audit streaming is not enabled for the instance.
You need the ID values returned by this query for the update and delete mutations.
Update an HTTP streaming destination for an instance.
Prerequisites:
To update streaming destinations for an instance, use the
instanceExternalAuditEventDestinationUpdate mutation type. You can retrieve the destination ID
by listing all the external destinations for the instance.
mutation {
instanceExternalAuditEventDestinationUpdate(input: {
id: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/1",
destinationUrl: "https://www.new-domain.com/webhook",
name: "destination-name"}) {
errors
instanceExternalAuditEventDestination {
destinationUrl
id
name
verificationToken
}
}
}
Streaming destination is updated if:
errors object is empty.200 OK.Instance administrators can update streaming destinations custom HTTP headers using the
auditEventsStreamingInstanceHeadersUpdate mutation type. You can retrieve the custom HTTP headers ID
by listing all the custom HTTP headers for the instance.
mutation {
auditEventsStreamingInstanceHeadersUpdate(input: { headerId: "gid://gitlab/AuditEvents::Streaming::InstanceHeader/2", key: "new-key", value: "new-value", active: false }) {
errors
header {
id
key
value
active
}
}
}
The header is updated if the returned errors object is empty.
Delete streaming destinations for an entire instance.
When the last destination is successfully deleted, streaming is disabled for the instance.
Prerequisites:
To delete streaming destinations, use the
instanceExternalAuditEventDestinationDestroy mutation type. You can retrieve the destinations ID
by listing all the streaming destinations for the instance.
mutation {
instanceExternalAuditEventDestinationDestroy(input: { id: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/1" }) {
errors
}
}
Streaming destination is deleted if:
errors object is empty.200 OK.To remove an HTTP header, use the GraphQL auditEventsStreamingInstanceHeadersDestroy mutation.
To retrieve the header ID,
list all the custom HTTP headers for the instance.
mutation {
auditEventsStreamingInstanceHeadersDestroy(input: { headerId: "gid://gitlab/AuditEvents::Streaming::InstanceHeader/<id>" }) {
errors
}
}
The header is deleted if the returned errors object is empty.
{{< history >}}
{{< /history >}}
When this feature is enabled for an instance, you can use an API to permit users to filter streamed audit events per destination. If the feature is enabled with no filters, the destination receives all audit events.
A streaming destination that has an event type filter set has a filtered ({{< icon name="filter" >}}) label.
Prerequisites:
You can add a list of event type filters using the auditEventsStreamingDestinationInstanceEventsAdd mutation:
mutation {
auditEventsStreamingDestinationInstanceEventsAdd(input: {
destinationId: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/1",
eventTypeFilters: ["list of event type filters"]}){
errors
eventTypeFilters
}
}
Event type filters are added if:
errors object is empty.200 OK.Prerequisites:
You can remove a list of event type filters using the auditEventsStreamingDestinationInstanceEventsRemove mutation:
mutation {
auditEventsStreamingDestinationInstanceEventsRemove(input: {
destinationId: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/1",
eventTypeFilters: ["list of event type filters"]
}){
errors
}
}
Event type filters are removed if:
errors object is empty.200 OK.{{< history >}}
{{< /history >}}
Manage Google Cloud Logging destinations for an entire instance.
Before setting up Google Cloud Logging streaming audit events, you must satisfy the prerequisites.
Add a new Google Cloud Logging configuration destination to an instance.
Prerequisites:
To enable streaming and add a configuration, use the
instanceGoogleCloudLoggingConfigurationCreate mutation in the GraphQL API.
mutation {
instanceGoogleCloudLoggingConfigurationCreate(input: { googleProjectIdName: "my-google-project", clientEmail: "[email protected]", privateKey: "YOUR_PRIVATE_KEY", logIdName: "audit-events", name: "destination-name" } ) {
errors
googleCloudLoggingConfiguration {
id
googleProjectIdName
logIdName
clientEmail
name
}
errors
}
}
Event streaming is enabled if:
errors object is empty.200 OK.List all Google Cloud Logging configuration destinations for an instance.
Prerequisites:
You can view a list of streaming configurations for an instance using the instanceGoogleCloudLoggingConfigurations query
type.
query {
instanceGoogleCloudLoggingConfigurations {
nodes {
id
logIdName
googleProjectIdName
clientEmail
name
}
}
}
If the resulting list is empty, audit streaming is not enabled for the instance.
You need the ID values returned by this query for the update and delete mutations.
Update the Google Cloud Logging configuration destinations for an instance.
Prerequisites:
To update streaming configuration for an instance, use the
instanceGoogleCloudLoggingConfigurationUpdate mutation type. You can retrieve the configuration ID
by listing all the external destinations.
mutation {
instanceGoogleCloudLoggingConfigurationUpdate(
input: {id: "gid://gitlab/AuditEvents::Instance::GoogleCloudLoggingConfiguration/1", googleProjectIdName: "updated-google-id", clientEmail: "[email protected]", privateKey: "YOUR_PRIVATE_KEY", logIdName: "audit-events", name: "updated name"}
) {
errors
instanceGoogleCloudLoggingConfiguration {
id
logIdName
googleProjectIdName
clientEmail
name
}
}
}
Streaming configuration is updated if:
errors object is empty.200 OK.Delete streaming destinations for an instance.
When the last destination is successfully deleted, streaming is disabled for the instance.
Prerequisites:
To delete streaming configurations, use the
instanceGoogleCloudLoggingConfigurationDestroy mutation type. You can retrieve the configurations ID
by listing all the streaming destinations for the instance.
mutation {
instanceGoogleCloudLoggingConfigurationDestroy(input: { id: "gid://gitlab/AuditEvents::Instance::GoogleCloudLoggingConfiguration/1" }) {
errors
}
}
Streaming configuration is deleted if:
errors object is empty.200 OK.