최상위 그룹의 감사 이벤트 스트리밍 GraphQL API
GitLab v19.5Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
요약
GraphQL API로 최상위 그룹의 감사 이벤트 스트리밍 대상을 관리합니다. 최상위 그룹의 HTTP 스트리밍 대상을 관리합니다. 최상위 그룹에 새 스트리밍 대상을 추가합니다. 스트리밍 대상은 모든 감사 이벤트 데이터를 수신하며 여기에는 민감한 정보가 포함될 수 있습니다.
GraphQL API로 최상위 그룹의 감사 이벤트 스트리밍 대상을 관리합니다.
HTTP 대상#
최상위 그룹의 HTTP 스트리밍 대상을 관리합니다.
새 스트리밍 대상 추가#
최상위 그룹에 새 스트리밍 대상을 추가합니다.
스트리밍 대상은 모든 감사 이벤트 데이터를 수신하며 여기에는 민감한 정보가 포함될 수 있습니다. 신뢰할 수 있는 스트리밍 대상인지 확인합니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
스트리밍을 활성화하고 최상위 그룹에 대상을 추가하려면 externalAuditEventDestinationCreate 뮤테이션을 사용합니다.
mutation {
externalAuditEventDestinationCreate(input: { destinationUrl: "https://mydomain.io/endpoint/ingest", groupPath: "my-group" } ) {
errors
externalAuditEventDestination {
id
name
destinationUrl
verificationToken
group {
name
}
}
}
}
GitLab 이 생성하는 기본 검증 토큰 대신 직접 정한 검증 토큰을 GraphQL
externalAuditEventDestinationCreate
뮤테이션으로 지정할 수 있습니다. 검증 토큰 길이는 16~24 자여야 하며 뒤쪽 공백은 제거되지 않습니다.
암호학적으로 무작위이며 고유한 값을 설정합니다. 예를 들면 다음과 같습니다.
mutation {
externalAuditEventDestinationCreate(input: { destinationUrl: "https://mydomain.io/endpoint/ingest", groupPath: "my-group", verificationToken: "unique-random-verification-token-here" } ) {
errors
externalAuditEventDestination {
id
name
destinationUrl
verificationToken
group {
name
}
}
}
}
GitLab 이 생성하는 기본 대상 이름 대신 직접 정한 대상 이름을 GraphQL
externalAuditEventDestinationCreate
뮤테이션으로 지정할 수 있습니다. 이름 길이는 72 자를 넘을 수 없고 뒤쪽 공백은 제거되지 않습니다. 이 값은 그룹 범위에서 고유해야 합니다. 예를 들면 다음과 같습니다.
mutation {
externalAuditEventDestinationCreate(input: { destinationUrl: "https://mydomain.io/endpoint/ingest", name: "destination-name-here", groupPath: "my-group" }) {
errors
externalAuditEventDestination {
id
name
destinationUrl
verificationToken
group {
name
}
}
}
}
다음 조건을 충족하면 이벤트 스트리밍이 활성화됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
GraphQL auditEventsStreamingHeadersCreate 뮤테이션으로 HTTP 헤더를 추가할 수 있습니다. 대상 ID는
그룹의 스트리밍 대상 전체 나열로 확인하거나 위 뮤테이션의
응답에서 확인합니다.
mutation {
auditEventsStreamingHeadersCreate(input: {
destinationId: "gid://gitlab/AuditEvents::ExternalAuditEventDestination/1",
key: "foo",
value: "bar",
active: false
}) {
errors
header {
id
key
value
active
}
}
}
반환된 errors 객체가 비어 있으면 헤더가 생성됩니다.
스트리밍 대상 나열#
최상위 그룹의 스트리밍 대상을 나열합니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
externalAuditEventDestinations 쿼리 타입으로 최상위 그룹의 스트리밍 대상 목록을
조회할 수 있습니다.
query {
group(fullPath: "my-group") {
id
externalAuditEventDestinations {
nodes {
destinationUrl
verificationToken
id
name
headers {
nodes {
key
value
id
active
}
}
eventTypeFilters
namespaceFilter {
id
namespace {
id
name
fullName
}
}
}
}
}
}
결과 목록이 비어 있으면 해당 그룹에서 감사 스트리밍이 활성화되지 않은 상태입니다.
스트리밍 대상 업데이트#
최상위 그룹의 스트리밍 대상을 업데이트합니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
그룹의 스트리밍 대상을 업데이트하려면 externalAuditEventDestinationUpdate 뮤테이션 타입을 사용합니다. 대상 ID는
그룹의 스트리밍 대상 전체 나열로 확인합니다.
mutation {
externalAuditEventDestinationUpdate(input: {
id:"gid://gitlab/AuditEvents::ExternalAuditEventDestination/1",
destinationUrl: "https://www.new-domain.com/webhook",
name: "destination-name"} ) {
errors
externalAuditEventDestination {
id
name
destinationUrl
verificationToken
group {
name
}
}
}
}
다음 조건을 충족하면 스트리밍 대상이 업데이트됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
그룹의 Owner 권한이 있는 사용자는 auditEventsStreamingHeadersUpdate 뮤테이션 타입으로
스트리밍 대상의 사용자 지정 HTTP 헤더를 업데이트할 수 있습니다. 사용자 지정 HTTP 헤더 ID는
그룹의 사용자 지정 HTTP 헤더 전체 나열로 확인합니다.
mutation {
auditEventsStreamingHeadersUpdate(input: { headerId: "gid://gitlab/AuditEvents::Streaming::Header/2", key: "new-key", value: "new-value", active: false }) {
errors
header {
id
key
value
active
}
}
}
그룹 Owner는 GraphQL auditEventsStreamingHeadersDestroy 뮤테이션으로 HTTP 헤더를 제거할 수 있습니다. 헤더 ID는
그룹의 사용자 지정 HTTP 헤더 전체 나열로 확인합니다.
mutation {
auditEventsStreamingHeadersDestroy(input: { headerId: "gid://gitlab/AuditEvents::Streaming::Header/1" }) {
errors
}
}
반환된 errors 객체가 비어 있으면 헤더가 삭제됩니다.
스트리밍 대상 삭제#
최상위 그룹의 스트리밍 대상을 삭제합니다.
마지막 대상이 정상적으로 삭제되면 해당 그룹의 스트리밍이 비활성화됩니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
그룹의 Owner 권한이 있는 사용자는 externalAuditEventDestinationDestroy 뮤테이션 타입으로
스트리밍 대상을 삭제할 수 있습니다. 대상 ID는
그룹의 스트리밍 대상 전체 나열로 확인합니다.
mutation {
externalAuditEventDestinationDestroy(input: { id: destination }) {
errors
}
}
다음 조건을 충족하면 스트리밍 대상이 삭제됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
그룹 Owner는 GraphQL auditEventsStreamingHeadersDestroy 뮤테이션으로 HTTP 헤더를 제거할 수 있습니다. 헤더 ID는
그룹의 사용자 지정 HTTP 헤더 전체 나열로 확인합니다.
mutation {
auditEventsStreamingHeadersDestroy(input: { headerId: "gid://gitlab/AuditEvents::Streaming::Header/1" }) {
errors
}
}
반환된 errors 객체가 비어 있으면 헤더가 삭제됩니다.
이벤트 유형 필터#
그룹에서 이 기능을 활성화하면 API로 사용자가 대상별 스트리밍 감사 이벤트를 필터링하도록 허용할 수 있습니다. 기능을 활성화했지만 필터가 없으면 대상은 모든 감사 이벤트를 수신합니다.
이벤트 유형 필터가 설정된 스트리밍 대상에는 filtered ([filter]) 레이블이 표시됩니다.
API로 이벤트 유형 필터 추가#
필수 조건:
- 그룹의 Owner 권한이 있어야 합니다.
auditEventsStreamingDestinationEventsAdd 쿼리 타입으로 이벤트 유형 필터 목록을 추가할 수 있습니다.
mutation {
auditEventsStreamingDestinationEventsAdd(input: {
destinationId: "gid://gitlab/AuditEvents::ExternalAuditEventDestination/1",
eventTypeFilters: ["list of event type filters"]}){
errors
eventTypeFilters
}
}
다음 조건을 충족하면 이벤트 유형 필터가 추가됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
API로 이벤트 유형 필터 제거#
필수 조건:
- 그룹의 Owner 권한이 있어야 합니다.
auditEventsStreamingDestinationEventsRemove 뮤테이션 타입으로 이벤트 유형 필터 목록을 제거할 수 있습니다.
mutation {
auditEventsStreamingDestinationEventsRemove(input: {
destinationId: "gid://gitlab/AuditEvents::ExternalAuditEventDestination/1",
eventTypeFilters: ["list of event type filters"]
}){
errors
}
}
다음 조건을 충족하면 이벤트 유형 필터가 제거됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
네임스페이스 필터#
그룹에 네임스페이스 필터를 적용하면 사용자는 그룹의 특정 하위 그룹이나 프로젝트를 기준으로 대상별 스트리밍 감사 이벤트를 필터링할 수 있습니다. 필터를 적용하지 않으면 대상은 모든 감사 이벤트를 수신합니다.
네임스페이스 필터가 설정된 스트리밍 대상에는 filtered ([filter]) 레이블이 표시됩니다.
API로 네임스페이스 필터 추가#
필수 조건:
- 그룹의 Owner 권한이 있어야 합니다.
하위 그룹과 프로젝트 모두 auditEventsStreamingHttpNamespaceFiltersAdd 뮤테이션 타입으로 네임스페이스 필터를 추가할 수 있습니다.
다음 조건을 충족하면 네임스페이스 필터가 추가됩니다.
- API가 비어 있는
errors객체를 반환합니다. - API가
200 OK로 응답합니다.
하위 그룹용 뮤테이션#
mutation auditEventsStreamingHttpNamespaceFiltersAdd {
auditEventsStreamingHttpNamespaceFiltersAdd(input: {
destinationId: "gid://gitlab/AuditEvents::ExternalAuditEventDestination/1",
groupPath: "path/to/subgroup"
}) {
errors
namespaceFilter {
id
namespace {
id
name
fullName
}
}
}
}
프로젝트용 뮤테이션#
mutation auditEventsStreamingHttpNamespaceFiltersAdd {
auditEventsStreamingHttpNamespaceFiltersAdd(input: {
destinationId: "gid://gitlab/AuditEvents::ExternalAuditEventDestination/1",
projectPath: "path/to/project"
}) {
errors
namespaceFilter {
id
namespace {
id
name
fullName
}
}
}
}
API로 네임스페이스 필터 제거#
필수 조건:
- 그룹의 Owner 권한이 있어야 합니다.
auditEventsStreamingHttpNamespaceFiltersDelete 뮤테이션 타입으로 네임스페이스 필터를 제거할 수 있습니다.
mutation auditEventsStreamingHttpNamespaceFiltersDelete {
auditEventsStreamingHttpNamespaceFiltersDelete(input: {
namespaceFilterId: "gid://gitlab/AuditEvents::Streaming::HTTP::NamespaceFilter/5"
}) {
errors
}
}
다음 조건을 충족하면 네임스페이스 필터가 제거됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
Google Cloud Logging 대상#
최상위 그룹의 Google Cloud Logging 대상을 관리합니다.
Google Cloud Logging 감사 이벤트 스트리밍을 설정하기 전에 필수 조건을 충족해야 합니다.
새 Google Cloud Logging 대상 추가#
최상위 그룹에 새 Google Cloud Logging 구성 대상을 추가합니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
- 서비스 계정을 생성하고 Google Cloud Logging을 활성화할 수 있는 권한을 갖춘 Google Cloud 프로젝트.
스트리밍을 활성화하고 구성을 추가하려면 GraphQL API의
googleCloudLoggingConfigurationCreate 뮤테이션을 사용합니다.
mutation {
googleCloudLoggingConfigurationCreate(input: { groupPath: "my-group", googleProjectIdName: "my-google-project", clientEmail: "my-email@my-google-project.iam.gservice.account.com", privateKey: "YOUR_PRIVATE_KEY", logIdName: "audit-events", name: "destination-name" } ) {
errors
googleCloudLoggingConfiguration {
id
googleProjectIdName
logIdName
clientEmail
name
}
errors
}
}
다음 조건을 충족하면 이벤트 스트리밍이 활성화됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
Google Cloud Logging 구성 나열#
최상위 그룹의 모든 Google Cloud Logging 구성 대상을 나열합니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
googleCloudLoggingConfigurations 쿼리 타입으로 최상위 그룹의 스트리밍 구성 목록을
조회할 수 있습니다.
query {
group(fullPath: "my-group") {
id
googleCloudLoggingConfigurations {
nodes {
id
logIdName
googleProjectIdName
clientEmail
name
}
}
}
}
결과 목록이 비어 있으면 해당 그룹에서 감사 스트리밍이 활성화되지 않은 상태입니다.
업데이트 뮤테이션과 삭제 뮤테이션에는 이 쿼리가 반환한 ID 값이 필요합니다.
Google Cloud Logging 구성 업데이트#
최상위 그룹의 Google Cloud Logging 구성 대상을 업데이트합니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
최상위 그룹의 스트리밍 구성을 업데이트하려면
googleCloudLoggingConfigurationUpdate 뮤테이션 타입을 사용합니다. 구성 ID는
외부 대상 전체 나열로 확인합니다.
mutation {
googleCloudLoggingConfigurationUpdate(
input: {id: "gid://gitlab/AuditEvents::GoogleCloudLoggingConfiguration/1", googleProjectIdName: "my-google-project", clientEmail: "my-email@my-google-project.iam.gservice.account.com", privateKey: "YOUR_PRIVATE_KEY", logIdName: "audit-events", name: "updated-destination-name" }
) {
errors
googleCloudLoggingConfiguration {
id
logIdName
googleProjectIdName
clientEmail
name
}
}
}
다음 조건을 충족하면 스트리밍 구성이 업데이트됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.
Google Cloud Logging 구성 삭제#
최상위 그룹의 스트리밍 대상을 삭제합니다.
마지막 대상이 정상적으로 삭제되면 해당 그룹의 스트리밍이 비활성화됩니다.
필수 조건:
- 최상위 그룹의 Owner 권한.
그룹의 Owner 권한이 있는 사용자는 googleCloudLoggingConfigurationDestroy 뮤테이션 타입으로
스트리밍 구성을 삭제할 수 있습니다. 구성 ID는
그룹의 스트리밍 대상 전체 나열로 확인합니다.
mutation {
googleCloudLoggingConfigurationDestroy(input: { id: "gid://gitlab/AuditEvents::GoogleCloudLoggingConfiguration/1" }) {
errors
}
}
다음 조건을 충족하면 스트리밍 구성이 삭제됩니다.
- 반환된
errors객체가 비어 있습니다. - API가
200 OK로 응답합니다.