Atlassian 조직 감사 로그 수집
파서 버전: 1.0
이 문서에서는 Google Cloud Storage V2를 사용하여 Atlassian 조직 감사 로그를 Google Security Operations에 수집하는 방법을 설명합니다.
Atlassian 조직 감사 로그는 admin.atlassian.com에서 Atlassian 조직 전반의 관리 활동을 중앙에서 기록합니다. 사용자 프로비저닝, 그룹 멤버십 변경, 인증 정책 업데이트, API 키 관리와 같은 이벤트를 캡처하여 보안팀이 조직 관리자가 변경한 사항을 모니터링하고 조사할 수 있도록 지원합니다.
시작하기 전에
다음 기본 요건이 충족되었는지 확인합니다.
- Google SecOps 인스턴스
- Cloud Storage API가 사용 설정된 GCP 프로젝트
- GCS 버킷을 만들고 관리할 수 있는 권한
- GCS 버킷의 IAM 정책을 관리할 수 있는 권한
- Cloud Run 서비스, Pub/Sub 주제, Cloud Scheduler 작업을 만들 수 있는 권한
- admin.atlassian.com에서 Atlassian 조직 관리에 대한 권한 액세스
- Atlassian Guard 구독 (Standard 또는 Premium) 또는 하나 이상의 Enterprise 요금제 (조직 감사 로그에 필요)가 있는 Atlassian 조직
Google Cloud Storage 버킷 만들기
- Google Cloud 콘솔로 이동합니다.
- 프로젝트를 선택하거나 새 프로젝트를 만듭니다.
- 탐색 메뉴에서 Cloud Storage> 버킷으로 이동합니다.
- 버킷 만들기를 클릭합니다.
다음 구성 세부정보를 제공합니다.
설정 값 버킷 이름 지정 전역적으로 고유한 이름 (예: atlassian-audit-logs)을 입력합니다.위치 유형 필요에 따라 선택 (리전, 이중 리전, 멀티 리전) 위치 위치를 선택합니다 (예: us-central1).스토리지 클래스 Standard (자주 액세스하는 로그에 권장) 액세스 제어 균일 (권장) 보호 조치 선택사항: 객체 버전 관리 또는 보관 정책 사용 설정 만들기를 클릭합니다.
Atlassian API 사용자 인증 정보 수집
API 키 만들기
- admin.atlassian.com에 로그인합니다.
- 조직이 두 개 이상인 경우 조직을 선택합니다.
- 설정> API 키로 이동합니다.
- API 키 만들기를 클릭합니다.
- 키를 설명하는 이름을 입력합니다 (예:
SecOps-Audit-Collector). 만료일을 설정합니다.
만들기를 클릭합니다.
API 키 값을 안전하게 복사하여 저장합니다. 이 대화상자를 닫은 후에는 API 키 값을 복구할 수 없습니다.
브라우저 주소 표시줄의 URL에서 조직 ID (
https://admin.atlassian.com/o/{orgId}/...의 UUID)를 확인합니다.완료를 클릭합니다.
권한 확인
API를 통해 조직 감사 로그에 액세스하려면 조직 관리자여야 합니다.
- admin.atlassian.com에 로그인합니다.
- 설정> API 키로 이동합니다.
- API 키 페이지가 표시되고 키를 만들 수 있다면 필요한 조직 관리자 권한이 있는 것입니다.
- 이 옵션이 표시되지 않으면 Atlassian 조직 관리자에게 문의하여 조직 관리자 액세스 권한을 부여받으세요.
API 액세스 테스트
통합을 진행하기 전에 사용자 인증 정보를 테스트합니다.
# Replace with your actual credentials API_KEY="<your-atlassian-api-key>" ORG_ID="<your-organization-id>" # Test API access using the events-stream endpoint curl -v \ --header "Authorization: Bearer ${API_KEY}" \ --header "Accept: application/json" \ "https://api.atlassian.com/admin/v1/orgs/${ORG_ID}/events-stream?limit=1"
성공적인 응답은 이벤트 객체의 data 배열이 포함된 JSON 본문과 함께 HTTP 200을 반환합니다.
Cloud Run 함수의 서비스 계정 만들기
Cloud Run 함수에는 GCS 버킷에 쓸 수 있고 Pub/Sub에 의해 호출될 수 있는 권한이 있는 서비스 계정이 필요합니다.
서비스 계정 만들기
- GCP 콘솔에서 IAM 및 관리자 > 서비스 계정으로 이동합니다.
- 서비스 계정 만들기를 클릭합니다.
- 다음 구성 세부정보를 제공합니다.
- 서비스 계정 이름:
atlassian-audit-collector-sa을 입력합니다. - 서비스 계정 설명:
Service account for Cloud Run function to collect Atlassian Organization Audit logs를 입력합니다.
- 서비스 계정 이름:
- 만들고 계속하기를 클릭합니다.
- 이 서비스 계정에 프로젝트에 대한 액세스 권한 부여 섹션에서 다음 역할을 추가합니다.
- 역할 선택을 클릭합니다.
- 스토리지 객체 관리자를 검색하여 선택합니다.
- + 다른 역할 추가를 클릭합니다.
- Cloud Run 호출자를 검색하여 선택합니다.
- + 다른 역할 추가를 클릭합니다.
- Cloud Functions 호출자를 검색하여 선택합니다.
- 계속을 클릭합니다.
- 완료를 클릭합니다.
이러한 역할은 다음 작업에 필요합니다.
- 스토리지 객체 관리자: GCS 버킷에 로그를 쓰고 상태 파일을 관리합니다.
- Cloud Run 호출자: Pub/Sub에서 함수를 호출하도록 허용
- Cloud Functions 호출자: 함수 호출 허용
GCS 버킷에 대한 IAM 권한 부여
GCS 버킷에 대한 쓰기 권한을 서비스 계정에 부여합니다.
- Cloud Storage> 버킷으로 이동합니다.
- 버킷 이름 (예:
atlassian-audit-logs)을 클릭합니다. - 권한 탭으로 이동합니다.
- 액세스 권한 부여를 클릭합니다.
- 다음 구성 세부정보를 제공합니다.
- 주 구성원 추가: 서비스 계정 이메일 (예:
atlassian-audit-collector-sa@PROJECT_ID.iam.gserviceaccount.com)을 입력합니다. - 역할 할당: 스토리지 객체 관리자 선택
- 주 구성원 추가: 서비스 계정 이메일 (예:
- 저장을 클릭합니다.
Pub/Sub 주제 만들기
Cloud Scheduler가 게시하고 Cloud Run 함수가 구독할 Pub/Sub 주제를 만듭니다.
- GCP 콘솔에서 Pub/Sub> 주제로 이동합니다.
- 주제 만들기를 클릭합니다.
- 다음 구성 세부정보를 제공합니다.
- 주제 ID:
atlassian-audit-logs-trigger를 입력합니다. - 다른 설정은 기본값으로 둡니다.
- 주제 ID:
- 만들기를 클릭합니다.
로그를 수집하는 Cloud Run 함수 만들기
Cloud Run 함수는 Cloud Scheduler의 Pub/Sub 메시지에 의해 트리거되어 Atlassian Organizations REST API에서 감사 로그 이벤트를 폴링하고 GCS에 작성합니다.
- GCP 콘솔에서 Cloud Run으로 이동합니다.
- 서비스 만들기를 클릭합니다.
- 함수를 선택합니다 (인라인 편집기를 사용하여 함수 만들기).
구성 섹션에서 다음 구성 세부정보를 입력합니다.
설정 값 서비스 이름 atlassian-audit-collector리전 GCS 버킷과 일치하는 리전을 선택합니다 (예: us-central1).런타임 Python 3.12 이상 선택 트리거 (선택사항) 섹션에서 다음을 수행합니다.
- + 트리거 추가를 클릭합니다.
- Cloud Pub/Sub을 선택합니다.
- Cloud Pub/Sub 주제 선택에서 Pub/Sub 주제 (
atlassian-audit-logs-trigger)를 선택합니다. - 저장을 클릭합니다.
인증 섹션에서 다음을 구성합니다.
- 인증 필요를 선택합니다.
- ID 및 액세스 관리 (IAM)를 확인합니다.
아래로 스크롤하고 컨테이너, 네트워킹, 보안을 펼칩니다.
보안 탭으로 이동합니다.
- 서비스 계정: 서비스 계정 (
atlassian-audit-collector-sa)을 선택합니다.
- 서비스 계정: 서비스 계정 (
컨테이너 탭으로 이동합니다.
- 변수 및 보안 비밀을 클릭합니다.
- 각 환경 변수에 대해 + 변수 추가를 클릭합니다.
변수 이름 예시 값 설명 GCS_BUCKETatlassian-audit-logsGCS 버킷 이름 GCS_PREFIXatlassian-audit로그 파일의 접두사 STATE_KEYatlassian-audit/state.json상태 파일 경로 ATL_TOKENyour-atlassian-api-keyAtlassian API 키 ATL_ORG_IDyour-organization-idAtlassian 조직 ID MAX_RECORDS1000실행당 최대 레코드 수 PAGE_SIZE200페이지당 레코드 수 (최대 500) LOOKBACK_HOURS24초기 전환 확인 기간 변수 및 보안 비밀 섹션에서 요청까지 아래로 스크롤합니다.
- 요청 제한 시간:
600초 (10분)를 입력합니다.
- 요청 제한 시간:
설정 탭으로 이동합니다.
- 리소스 섹션에서 다음을 수행합니다.
- 메모리: 512MiB 이상 선택
- CPU: 1을 선택합니다.
- 리소스 섹션에서 다음을 수행합니다.
버전 확장 섹션에서 다음을 수행합니다.
- 최소 인스턴스 수:
0를 입력합니다. - 최대 인스턴스 수:
100을 입력합니다 (또는 예상 부하에 따라 조정).
- 최소 인스턴스 수:
만들기를 클릭합니다.
서비스가 생성될 때까지 기다립니다 (1~2분).
서비스가 생성되면 인라인 코드 편집기가 자동으로 열립니다.
함수 코드 추가
- 진입점 필드에 main을 입력합니다.
인라인 코드 편집기에서 다음 두 파일을 만듭니다.
- main.py:
import functions_framework from google.cloud import storage import json import os import urllib3 from datetime import datetime, timezone, timedelta from urllib.parse import urlparse, parse_qs import time # Initialize HTTP client with timeouts http = urllib3.PoolManager( timeout=urllib3.Timeout(connect=5.0, read=30.0), retries=False, ) # Initialize Storage client storage_client = storage.Client() # Environment variables GCS_BUCKET = os.environ.get('GCS_BUCKET') GCS_PREFIX = os.environ.get('GCS_PREFIX', 'atlassian-audit') STATE_KEY = os.environ.get('STATE_KEY', 'atlassian-audit/state.json') ATL_TOKEN = os.environ.get('ATL_TOKEN') ATL_ORG_ID = os.environ.get('ATL_ORG_ID') MAX_RECORDS = int(os.environ.get('MAX_RECORDS', '1000')) PAGE_SIZE = int(os.environ.get('PAGE_SIZE', '200')) LOOKBACK_HOURS = int(os.environ.get('LOOKBACK_HOURS', '24')) def parse_datetime(value): """Parse ISO datetime string to datetime object.""" if value.endswith("Z"): value = value[:-1] + "+00:00" return datetime.fromisoformat(value) @functions_framework.cloud_event def main(cloud_event): """ Cloud Run function triggered by Pub/Sub to fetch Atlassian Organization Audit logs via the events-stream endpoint and write to GCS. Args: cloud_event: CloudEvent object containing Pub/Sub message """ if not all([GCS_BUCKET, ATL_TOKEN, ATL_ORG_ID]): print('Error: Missing required environment variables') return try: # Get GCS bucket bucket = storage_client.bucket(GCS_BUCKET) # Load state state = load_state(bucket, STATE_KEY) # Determine time window now = datetime.now(timezone.utc) last_time = None if isinstance(state, dict) and state.get("last_event_time"): try: last_time = parse_datetime(state["last_event_time"]) # Overlap by 2 minutes to catch any delayed events last_time = last_time - timedelta(minutes=2) except Exception as e: print(f"Warning: Could not parse last_event_time: {e}") if last_time is None: last_time = now - timedelta(hours=LOOKBACK_HOURS) print(f"Fetching logs from {last_time.isoformat()} to {now.isoformat()}") # Fetch logs using the events-stream polling endpoint records, newest_event_time = fetch_logs( start_time=last_time, end_time=now, page_size=PAGE_SIZE, max_records=MAX_RECORDS, ) if not records: print("No new log records found.") save_state(bucket, STATE_KEY, now.isoformat()) return # Write to GCS as NDJSON timestamp_str = now.strftime('%Y%m%d_%H%M%S') object_key = f"{GCS_PREFIX}/logs_{timestamp_str}.ndjson" blob = bucket.blob(object_key) ndjson = '\n'.join([json.dumps(record, ensure_ascii=False) for record in records]) + '\n' blob.upload_from_string(ndjson, content_type='application/x-ndjson') print(f"Wrote {len(records)} records to gs://{GCS_BUCKET}/{object_key}") # Update state with newest event time if newest_event_time: save_state(bucket, STATE_KEY, newest_event_time) else: save_state(bucket, STATE_KEY, now.isoformat()) print(f"Successfully processed {len(records)} records") except Exception as e: print(f'Error processing logs: {str(e)}') raise def load_state(bucket, key): """Load state from GCS.""" try: blob = bucket.blob(key) if blob.exists(): state_data = blob.download_as_text() return json.loads(state_data) except Exception as e: print(f"Warning: Could not load state: {e}") return {} def save_state(bucket, key, last_event_time_iso): """Save the last event timestamp to GCS state file.""" try: state = {'last_event_time': last_event_time_iso} blob = bucket.blob(key) blob.upload_from_string( json.dumps(state, indent=2), content_type='application/json' ) print(f"Saved state: last_event_time={last_event_time_iso}") except Exception as e: print(f"Warning: Could not save state: {e}") def fetch_logs(start_time, end_time, page_size, max_records): """ Fetch audit logs from Atlassian Organization events-stream API with cursor-based pagination. The events-stream endpoint is designed for polling use cases and supports higher throughput than the /events query endpoint. API reference: https://developer.atlassian.com/cloud/admin/organization/rest/api-group-events/ Args: start_time: Start time for log query end_time: End time for log query page_size: Number of records per page (max 500) max_records: Maximum total records to fetch Returns: Tuple of (records list, newest_event_time ISO string) """ endpoint = f"https://api.atlassian.com/admin/v1/orgs/{ATL_ORG_ID}/events-stream" headers = { 'Authorization': f'Bearer {ATL_TOKEN}', 'Accept': 'application/json', 'User-Agent': 'GoogleSecOps-AtlassianAuditCollector/1.0' } records = [] newest_time = None page_num = 0 backoff = 1.0 cursor = None while True: page_num += 1 if len(records) >= max_records: print(f"Reached max_records limit ({max_records})") break # Build request URL with query parameters params = [ f"from={start_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')}", f"to={end_time.strftime('%Y-%m-%dT%H:%M:%S.000Z')}", f"limit={min(page_size, max_records - len(records))}", ] if cursor: params.append(f"cursor={cursor}") url = f"{endpoint}?{'&'.join(params)}" try: response = http.request('GET', url, headers=headers) # Handle rate limiting with exponential backoff if response.status == 429: retry_after = int(response.headers.get('Retry-After', str(int(backoff)))) print(f"Rate limited (429). Retrying after {retry_after}s...") time.sleep(retry_after) backoff = min(backoff * 2, 30.0) continue backoff = 1.0 if response.status != 200: print(f"HTTP Error: {response.status}") response_text = response.data.decode('utf-8') print(f"Response body: {response_text}") return [], None data = json.loads(response.data.decode('utf-8')) page_results = data.get('data', []) if not page_results: print(f"No more results (empty page)") break print(f"Page {page_num}: Retrieved {len(page_results)} events") records.extend(page_results) # Track newest event time from attributes for event in page_results: try: attrs = event.get('attributes', {}) event_time = attrs.get('time') if event_time: if newest_time is None or parse_datetime(event_time) > parse_datetime(newest_time): newest_time = event_time except Exception as e: print(f"Warning: Could not parse event time: {e}") # Check for next page using links.next or meta.next cursor next_link = data.get('links', {}).get('next') if not next_link: next_cursor = data.get('meta', {}).get('next') if not next_cursor: print("No more pages (no next cursor)") break cursor = next_cursor else: # Extract cursor from next link URL parsed = urlparse(next_link) query_params = parse_qs(parsed.query) cursor = query_params.get('cursor', [None])[0] if not cursor: break except Exception as e: print(f"Error fetching logs: {e}") return [], None print(f"Retrieved {len(records)} total records from {page_num} pages") return records, newest_time- requirements.txt:
functions-framework==3.* google-cloud-storage==2.* urllib3>=2.0.0배포를 클릭하여 함수를 저장하고 배포합니다.
배포가 완료될 때까지 기다립니다 (2~3분).
Cloud Scheduler 작업 만들기
Cloud Scheduler는 일정 간격으로 Pub/Sub 주제에 메시지를 게시하여 Cloud Run 함수를 트리거합니다.
- GCP Console에서 Cloud Scheduler로 이동합니다.
- 작업 만들기를 클릭합니다.
다음 구성 세부정보를 제공합니다.
설정 값 이름 atlassian-audit-collector-hourly리전 Cloud Run 함수와 동일한 리전 선택 주파수 0 * * * *(매시간 정각)시간대 시간대 선택 (UTC 권장) 타겟 유형 Pub/Sub 주제 Pub/Sub 주제 ( atlassian-audit-logs-trigger)를 선택합니다.메일 본문 {}(빈 JSON 객체)만들기를 클릭합니다.
일정 빈도 옵션
로그 볼륨 및 지연 시간 요구사항에 따라 빈도를 선택합니다.
| 빈도 | 크론 표현식 | 사용 사례 |
|---|---|---|
| 5분마다 | */5 * * * * |
대용량, 저지연 |
| 15분마다 | */15 * * * * |
검색량 보통 |
| 1시간마다 | 0 * * * * |
표준 (권장) |
| 6시간마다 | 0 */6 * * * |
적은 볼륨, 일괄 처리 |
| 매일 | 0 0 * * * |
이전 데이터 수집 |
통합 테스트
- Cloud Scheduler 콘솔에서 작업을 찾습니다.
- 강제 실행을 클릭하여 작업을 수동으로 트리거합니다.
- 몇 초 동안 기다립니다.
- Cloud Run > 서비스로 이동합니다.
- 함수 이름 (
atlassian-audit-collector)을 클릭합니다. - 로그 탭을 클릭합니다.
함수가 성공적으로 실행되었는지 확인합니다. 다음 항목을 찾습니다.
Fetching logs from YYYY-MM-DDTHH:MM:SS+00:00 to YYYY-MM-DDTHH:MM:SS+00:00 Page 1: Retrieved X events Wrote X records to gs://atlassian-audit-logs/atlassian-audit/logs_YYYYMMDD_HHMMSS.ndjson Successfully processed X recordsCloud Storage> 버킷으로 이동합니다.
버킷 이름 (
atlassian-audit-logs)을 클릭합니다.접두사 폴더 (
atlassian-audit/)로 이동합니다.현재 타임스탬프로 새
.ndjson파일이 생성되었는지 확인합니다.
로그에 오류가 표시되는 경우:
- HTTP 401: 환경 변수에서 API 키 확인
- HTTP 403: 조직 관리자 권한 및 Atlassian Guard 구독 확인
- HTTP 429: 비율 제한 - 함수가 백오프로 자동 재시도됨
- 환경 변수 누락: 필요한 모든 변수가 설정되어 있는지 확인합니다.
Google SecOps 서비스 계정 가져오기
Google SecOps는 고유한 서비스 계정을 사용하여 GCS 버킷에서 데이터를 읽습니다. 이 서비스 계정에 버킷 액세스 권한을 부여해야 합니다.
서비스 계정 이메일 가져오기
- SIEM 설정 > 피드로 이동합니다.
- 새 피드 추가를 클릭합니다.
- 단일 피드 구성을 클릭합니다.
- 피드 이름 필드에 피드 이름을 입력합니다(예:
Atlassian Audit Logs). - 소스 유형으로 Google Cloud Storage V2를 선택합니다.
- 로그 유형으로 ATLASSIAN_AUDIT를 선택합니다.
- 서비스 계정 가져오기를 클릭합니다.
고유한 서비스 계정 이메일이 표시됩니다. 예를 들면 다음과 같습니다.
chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com다음 단계에서 사용할 수 있도록 이 이메일 주소를 복사합니다.
다음을 클릭합니다.
다음 입력 매개변수의 값을 지정합니다.
스토리지 버킷 URL: 다음 접두사 경로를 사용하여 GCS 버킷 URI를 입력합니다.
gs://atlassian-audit-logs/atlassian-audit/
소스 삭제 옵션: 환경설정에 따라 삭제 옵션을 선택합니다.
- 삭제 안함: 전송 후 파일을 삭제하지 않습니다 (테스트에 권장).
- 전송된 파일 삭제: 전송이 완료되면 파일을 삭제합니다.
전송된 파일 및 빈 디렉터리 삭제: 전송이 완료되면 파일과 빈 디렉터리를 삭제합니다.
최대 파일 기간: 지난 일수 동안 수정된 파일을 포함합니다 (기본값은 180일).
애셋 네임스페이스: 애셋 네임스페이스
수집 라벨: 이 피드의 이벤트에 적용할 라벨
다음을 클릭합니다.
확정 화면에서 새 피드 구성을 검토한 다음 제출을 클릭합니다.
Google SecOps 서비스 계정에 IAM 권한 부여
Google SecOps 서비스 계정에는 GCS 버킷에 대한 스토리지 객체 뷰어 역할이 필요합니다.
- Cloud Storage> 버킷으로 이동합니다.
- 버킷 이름 (
atlassian-audit-logs)을 클릭합니다. - 권한 탭으로 이동합니다.
- 액세스 권한 부여를 클릭합니다.
- 다음 구성 세부정보를 제공합니다.
- 주 구성원 추가: Google SecOps 서비스 계정 이메일을 붙여넣습니다.
- 역할 할당: 스토리지 객체 뷰어를 선택합니다.
저장을 클릭합니다.
UDM 매핑 테이블
| 로그 필드 | UDM 매핑 | 로직 |
|---|---|---|
attributes.time |
metadata.event_timestamp |
원시 로그의 attributes.time 필드에서 파싱됩니다. |
attributes.action |
metadata.product_event_type |
값은 attributes.action 필드에서 가져옵니다. |
attributes.actor.id |
principal.user.product_object_id |
값은 attributes.actor.id 필드에서 가져옵니다. |
attributes.actor.name |
principal.user.user_display_name |
값은 attributes.actor.name 필드에서 가져옵니다. |
attributes.actor.email |
principal.user.email_addresses |
값은 attributes.actor.email 필드에서 가져옵니다. |
attributes.location.ip |
principal.ip |
값은 attributes.location.ip 필드에서 가져옵니다. |
attributes.location.geo |
principal.location.country_or_region |
값은 attributes.location.geo 필드에서 가져옵니다. |
attributes.location.countryName |
principal.location.name |
값은 attributes.location.countryName 필드에서 가져옵니다. |
attributes.context[].id |
target.resource.product_object_id |
값은 컨텍스트 id 필드에서 가져옵니다. |
attributes.context[].type |
target.resource.resource_subtype |
값은 컨텍스트 type 필드에서 가져옵니다. |
attributes.container[].id |
target.resource.attribute.labels |
컨테이너 id가 라벨로 추가됩니다. |
attributes.container[].type |
target.resource.attribute.labels |
컨테이너 type가 라벨로 추가됩니다. |
message.content |
security_result.summary |
값은 message.content 필드에서 가져옵니다. |
metadata.event_type |
사용 가능한 필드를 기반으로 매핑됩니다. 리소스 수정의 경우 USER_RESOURCE_UPDATE_CONTENT, 그 외의 경우 GENERIC_EVENT입니다. |
|
metadata.product_name |
Atlassian Admin로 설정합니다. |
|
metadata.vendor_name |
Atlassian로 설정합니다. |
변경 로그
도움이 더 필요하신가요? 커뮤니티 회원 및 Google SecOps 전문가에게 문의하여 답변을 받으세요.