Collect Okta Advanced Server Access logs
This document explains how to ingest Okta Advanced Server Access logs to Google Security Operations using Google Cloud Storage V2.
Okta Advanced Server Access (formerly ScaleFT) is a privileged access management solution that provides SSH and RDP access to servers with ephemeral certificates and comprehensive audit logging. The platform retains audit events for 90 days and provides an API to retrieve these events for long-term storage and analysis in SIEM platforms.
Before you begin
Ensure that you have the following prerequisites:
- A Google SecOps instance
- A GCP project with Cloud Storage, Cloud Run, Pub/Sub, and Cloud Scheduler APIs enabled
- Permissions to create and manage GCS buckets
- Permissions to manage IAM policies on GCS buckets
- Permissions to create Cloud Run services, Pub/Sub topics, and Cloud Scheduler jobs
- Administrator access to your Okta Advanced Server Access team
- Ability to create service users and API keys in Advanced Server Access
Configure Okta Advanced Server Access API access
To enable Google SecOps to retrieve audit events, you need to create a service user and generate an API key. Service users are special accounts designed for automation and API integrations.
Create a service user
- Sign in to the Advanced Server Access dashboard.
- Go to Users.
- Select the Service Users tab.
- Click Create Service User.
In the Username field, enter a descriptive name for the service user (for example,
chronicle-integration).Click Create Service User.
Generate an API key
- On the service user details page, click Create API Key.
Copy and save the following credentials immediately:
- API Key ID: A UUID that identifies the API key (for example,
6052868b-1b04-4a14-8288-e6496d7f2f4b) - API Key Secret: A base64-encoded secret string used to authenticate API requests
- API Key ID: A UUID that identifies the API key (for example,
Click Done.
Assign the service user to a group with appropriate permissions
Service users must be members of a group with appropriate team-wide roles to access the Audits API.
- In the Advanced Server Access dashboard, go to Groups.
- Select an existing group or create a new group for API access.
- Click the group name to open the group details.
- Select the Users tab.
- Click Add User.
- Search for and select the service user (for example,
chronicle-integration). - Click Add.
- Select the Roles tab.
Ensure the group has one of the following team-wide roles:
- reporting_user: Read-only access to all endpoints (recommended for log ingestion)
- access_admin: Full administrative access (grants all CRUD permissions)
If the required role is not assigned, click Add Role, select reporting_user or access_admin, and click Save.
Verify permissions
To verify the service user has the required permissions:
- In the Advanced Server Access dashboard, go to Groups.
- Click on the group containing the service user (for example,
chronicle-integration). - Select the Roles tab.
- Confirm the reporting_user or access_admin role is listed.
- If you cannot see the Roles tab, contact your administrator to grant appropriate access.
Test API access
Test your credentials before proceeding with the integration:
# Replace with your actual credentials TEAM_NAME="your-team-name" KEY_ID="your-api-key-id" KEY_SECRET="your-api-key-secret" # Obtain bearer token TOKEN=$(curl -s -X POST "https://app.scaleft.com/v1/teams/${TEAM_NAME}/service_token" \ -H "Content-Type: application/json" \ -d "{\"key_id\": \"${KEY_ID}\", \"key_secret\": \"${KEY_SECRET}\"}" \ | python3 -c "import sys,json; print(json.load(sys.stdin)['bearer_token'])") # Test audit events access curl -s -H "Authorization: Bearer ${TOKEN}" \ "https://app.scaleft.com/v1/teams/${TEAM_NAME}/auditsV2?count=5" \ | python3 -m json.tool
A successful response returns a JSON array of recent audit events.
Create Google Cloud Storage bucket
- Go to the Google Cloud Console.
- Select your project or create a new one.
- In the navigation menu, go to Cloud Storage > Buckets.
- Click Create bucket.
Provide the following configuration details:
Setting Value Name your bucket Enter a globally unique name (for example, okta-asa-audit-logs)Location type Choose based on your needs (Region, Dual-region, Multi-region) Location Select the location (for example, us-central1)Storage class Standard (recommended for frequently accessed logs) Access control Uniform (recommended) Protection tools Optional: Enable object versioning or retention policy Click Create.
Create service account for Cloud Run function
- In the GCP Console, go to IAM & Admin > Service Accounts.
- Click Create Service Account.
- Provide the following configuration details:
- Service account name: Enter
okta-asa-collector-sa - Service account description: Enter
Service account for Cloud Run function to collect Okta Advanced Server Access audit logs
- Service account name: Enter
- Click Create and Continue.
- In the Grant this service account access to project section, add the following roles:
- Click Select a role.
- Search for and select Storage Object Admin.
- Click + Add another role.
- Search for and select Cloud Run Invoker.
- Click + Add another role.
- Search for and select Cloud Functions Invoker.
- Click Continue.
- Click Done.
Grant IAM permissions on GCS bucket
- Go to Cloud Storage > Buckets.
- Click on your bucket name (
okta-asa-audit-logs). - Go to the Permissions tab.
- Click Grant access.
- Provide the following configuration details:
- Add principals: Enter the service account email (
okta-asa-collector-sa@PROJECT_ID.iam.gserviceaccount.com) - Assign roles: Select Storage Object Admin
- Add principals: Enter the service account email (
- Click Save.
Create Pub/Sub topic
- In the GCP Console, go to Pub/Sub > Topics.
- Click Create topic.
- Provide the following configuration details:
- Topic ID: Enter
okta-asa-audit-trigger - Leave other settings as default
- Topic ID: Enter
- Click Create.
Create Cloud Run function to collect logs
The Cloud Run function will be triggered by Pub/Sub messages from Cloud Scheduler to fetch logs from the Okta Advanced Server Access Audits API and write them to GCS.
- In the GCP Console, go to Cloud Run.
- Click Create service.
- Select Function (use an inline editor to create a function).
In the Configure section, provide the following configuration details:
Setting Value Service name okta-asa-collectorRegion Select region matching your GCS bucket (for example, us-central1)Runtime Select Python 3.12 or later In the Trigger (optional) section:
- Click + Add trigger.
- Select Cloud Pub/Sub.
- In Select a Cloud Pub/Sub topic, choose
okta-asa-audit-trigger. - Click Save.
In the Authentication section:
- Select Require authentication.
- Check Identity and Access Management (IAM).
Scroll down and expand Containers, Networking, Security.
Go to the Security tab:
- Service account: Select
okta-asa-collector-sa
- Service account: Select
Go to the Containers tab:
- Click Variables & Secrets.
- Click + Add variable for each environment variable:
Variable Name Example Value Description GCS_BUCKETokta-asa-audit-logsGCS bucket name GCS_PREFIXokta-asa-auditPrefix for log files STATE_KEYokta-asa-audit/state.jsonState file path ASA_TEAM_NAMEyour-team-nameAdvanced Server Access team name ASA_KEY_IDyour-api-key-idService user API key ID ASA_KEY_SECRETyour-api-key-secretService user API key secret MAX_RECORDS5000Max records per run PAGE_SIZE1000Records per API page (max 1000) LOOKBACK_HOURS24Initial lookback period In the Variables & Secrets section, scroll down to Requests:
- Request timeout: Enter
600seconds (10 minutes)
- Request timeout: Enter
Go to the Settings tab:
- In the Resources section:
- Memory: Select 512 MiB or higher
- CPU: Select 1
- In the Resources section:
In the Revision scaling section:
- Minimum number of instances: Enter
0 - Maximum number of instances: Enter
100
- Minimum number of instances: Enter
Click Create.
Wait for the service to be created (1-2 minutes).
After the service is created, the inline code editor will open automatically.
Add function code
- Enter main in the Entry point field.
In the inline code editor, create two files:
main.py:
import functions_framework from google.cloud import storage import json import os import urllib3 from datetime import datetime, timezone, timedelta import time http = urllib3.PoolManager( timeout=urllib3.Timeout(connect=10.0, read=60.0), retries=False, ) storage_client = storage.Client() GCS_BUCKET = os.environ.get('GCS_BUCKET') GCS_PREFIX = os.environ.get('GCS_PREFIX', 'okta-asa-audit') STATE_KEY = os.environ.get('STATE_KEY', 'okta-asa-audit/state.json') ASA_TEAM_NAME = os.environ.get('ASA_TEAM_NAME') ASA_KEY_ID = os.environ.get('ASA_KEY_ID') ASA_KEY_SECRET = os.environ.get('ASA_KEY_SECRET') MAX_RECORDS = int(os.environ.get('MAX_RECORDS', '5000')) PAGE_SIZE = int(os.environ.get('PAGE_SIZE', '1000')) LOOKBACK_HOURS = int(os.environ.get('LOOKBACK_HOURS', '24')) ASA_API_BASE = 'https://app.scaleft.com' @functions_framework.cloud_event def main(cloud_event): if not all([GCS_BUCKET, ASA_TEAM_NAME, ASA_KEY_ID, ASA_KEY_SECRET]): print('Error: Missing required environment variables') return try: bucket = storage_client.bucket(GCS_BUCKET) state = load_state(bucket) now = datetime.now(timezone.utc) if isinstance(state, dict) and state.get('last_offset'): last_offset = state['last_offset'] else: last_offset = None print(f"Starting audit log collection (last_offset={last_offset})") token = get_bearer_token() records, newest_offset = fetch_audit_events( token=token, last_offset=last_offset, page_size=PAGE_SIZE, max_records=MAX_RECORDS, ) if not records: print("No new audit records found.") return timestamp = now.strftime('%Y%m%d_%H%M%S') object_key = f"{GCS_PREFIX}/okta_asa_audit_{timestamp}.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}") if newest_offset: save_state(bucket, newest_offset) print(f"Successfully processed {len(records)} records") except Exception as e: print(f'Error processing logs: {str(e)}') raise def get_bearer_token(): url = f"{ASA_API_BASE}/v1/teams/{ASA_TEAM_NAME}/service_token" body = json.dumps({ 'key_id': ASA_KEY_ID, 'key_secret': ASA_KEY_SECRET }).encode('utf-8') response = http.request( 'POST', url, body=body, headers={'Content-Type': 'application/json'} ) if response.status != 200: raise Exception( f"Service token request failed: {response.status} - " f"{response.data.decode('utf-8')}" ) data = json.loads(response.data.decode('utf-8')) token = data.get('bearer_token') if not token: raise Exception("No bearer_token in service token response") print("Successfully obtained ASA bearer token") return token def fetch_audit_events(token, last_offset, page_size, max_records): endpoint = f"{ASA_API_BASE}/v1/teams/{ASA_TEAM_NAME}/auditsV2" headers = { 'Authorization': f'Bearer {token}', 'Accept': 'application/json', } records = [] page_num = 0 backoff = 1.0 current_offset = last_offset while True: page_num += 1 if len(records) >= max_records: print(f"Reached max_records limit ({max_records})") break params = [f"count={page_size}"] if current_offset: params.append(f"offset={current_offset}") url = f"{endpoint}?{'&'.join(params)}" try: response = http.request('GET', url, headers=headers) 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 == 401: print("Token expired (401). Refreshing bearer token...") token = get_bearer_token() headers['Authorization'] = f'Bearer {token}' continue if response.status != 200: print(f"HTTP Error: {response.status}") response_text = response.data.decode('utf-8') print(f"Response body: {response_text}") return records, current_offset data = json.loads(response.data.decode('utf-8')) page_results = data.get('list', []) 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) # Extract next offset from Link header for pagination link_header = response.headers.get('Link', '') next_offset = extract_next_offset(link_header) if next_offset: current_offset = next_offset else: print("No more pages (no next link)") break except Exception as e: print(f"Error fetching audit events: {e}") return records, current_offset print(f"Retrieved {len(records)} total records from {page_num} pages") return records, current_offset def extract_next_offset(link_header): if not link_header: return None parts = link_header.split(',') for part in parts: if 'rel="next"' in part: url_part = part.split(';')[0].strip().strip('<>') if 'offset=' in url_part: for param in url_part.split('?')[-1].split('&'): if param.startswith('offset='): return param.split('=', 1)[1] return None def load_state(bucket): try: blob = bucket.blob(STATE_KEY) if blob.exists(): return json.loads(blob.download_as_text()) except Exception as e: print(f"Warning: Could not load state: {e}") return {} def save_state(bucket, last_offset): try: state = { 'last_offset': last_offset, 'last_run': datetime.now(timezone.utc).isoformat() } blob = bucket.blob(STATE_KEY) blob.upload_from_string( json.dumps(state, indent=2), content_type='application/json' ) print(f"Saved state: last_offset={last_offset}") except Exception as e: print(f"Warning: Could not save state: {e}")requirements.txt:
functions-framework==3.* google-cloud-storage==2.* urllib3>=2.0.0
Click Deploy to save and deploy the function.
Wait for deployment to complete (2-3 minutes).
Create Cloud Scheduler job
- In the GCP Console, go to Cloud Scheduler.
- Click Create Job.
Provide the following configuration details:
Setting Value Name okta-asa-collector-hourlyRegion Select same region as Cloud Run function Frequency 0 * * * *(every hour, on the hour)Timezone Select timezone (UTC recommended) Target type Pub/Sub Topic Select okta-asa-audit-triggerMessage body {}(empty JSON object)Click Create.
Schedule frequency options
Choose frequency based on log volume and latency requirements:
| Frequency | Cron Expression | Use Case |
|---|---|---|
| Every 5 minutes | */5 * * * * |
High-volume, low-latency |
| Every 15 minutes | */15 * * * * |
Medium volume |
| Every hour | 0 * * * * |
Standard (recommended) |
| Every 6 hours | 0 */6 * * * |
Low volume, batch processing |
| Daily | 0 0 * * * |
Historical data collection |
Test the integration
- In the Cloud Scheduler console, find your job (
okta-asa-collector-hourly). - Click Force run to trigger the job manually.
- Wait a few seconds.
- Go to Cloud Run > Services.
- Click on
okta-asa-collector. - Click the Logs tab.
Verify the function executed successfully. Look for:
Starting audit log collection (last_offset=None) Successfully obtained ASA bearer token Page 1: Retrieved X events Wrote X records to gs://okta-asa-audit-logs/okta-asa-audit/okta_asa_audit_YYYYMMDD_HHMMSS.ndjson Successfully processed X recordsGo to Cloud Storage > Buckets.
Click on
okta-asa-audit-logs.Navigate to the
okta-asa-audit/folder.Verify that a new
.ndjsonfile was created with the current timestamp.
If you see errors in the logs:
- HTTP 401: Verify the
ASA_KEY_IDandASA_KEY_SECRETenvironment variables are correct - HTTP 403: Verify the service user has the reporting_user or access_admin role
- HTTP 429: Rate limiting — the function will automatically retry with exponential backoff
- Missing environment variables: Verify all required variables are set in the Cloud Run function configuration
Retrieve the Google SecOps service account
- Go to SIEM Settings > Feeds.
- Click Add New Feed.
- Click Configure a single feed.
- In the Feed name field, enter a name for the feed (for example,
Okta ASA Audit Logs). - Select Google Cloud Storage V2 as the Source type.
- Select Okta Advanced Server Access as the Log type.
- Click Get Service Account.
A unique service account email is displayed. For example:
chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.comCopy this email address for use in the next step.
Click Next.
Specify values for the following input parameters:
Storage bucket URL: Enter the GCS bucket URI with the prefix path:
gs://okta-asa-audit-logs/okta-asa-audit/
Source deletion option: Select the deletion option according to your preference:
- Never: Never deletes any files after transfers (recommended for testing).
- Delete transferred files: Deletes files after successful transfer.
Delete transferred files and empty directories: Deletes files and empty directories after successful transfer.
Maximum File Age: Include files modified in the last number of days (default is 180 days)
Asset namespace: The asset namespace
Ingestion labels: The label to be applied to the events from this feed
Click Next.
Review your new feed configuration in the Finalize screen, and then click Submit.
Grant IAM permissions to the Google SecOps service account
- Go to Cloud Storage > Buckets.
- Click on
okta-asa-audit-logs. - Go to the Permissions tab.
- Click Grant access.
- Provide the following configuration details:
- Add principals: Paste the Google SecOps service account email
- Assign roles: Select Storage Object Viewer
Click Save.
UDM mapping table
| Log Field | UDM Mapping | Logic |
|---|---|---|
| details.actor.details.email | principal.user.email_addresses | Value copied directly |
| details.actor.details.first_name | principal.user.first_name | Value copied directly |
| details.actor.details.full_name | principal.user.user_display_name | Value copied directly |
| details.actor.details.last_name | principal.user.last_name | Value copied directly |
| details.actor.details.user_type | principal.user.attribute.roles | Value copied directly |
| details.actor.id | principal.user.employee_id | Value copied directly |
| details.actor.name | principal.user.userid | Value from details.actor.name if not empty, else details.unix_user_name |
| details.unix_user_name | principal.user.userid | |
| details.actor.status | principal.user.attribute.labels | Merged as label with key "actor_status" |
| details.actor.team_name | principal.user.department | Value copied directly |
| details.actor.user_type | principal.user.attribute.labels | Merged as label with key "actor_user_type" |
| details.client.description | principal.application | Value copied directly |
| details.client.encrypted | principal.asset.attribute.labels | Converted to string, merged as label with key "details_client_encrypted" |
| details.client.hostname | principal.hostname, principal.asset.hostname | Value copied directly |
| details.client.id | principal.user.product_object_id | Value copied directly |
| details.client.os | principal.platform | Set to WINDOWS if matches (?i)Win|win; LINUX if matches (?i)Lin|lin; MAC if matches (?i)Mac|ios|mac; ANDROID if matches (?i)Android|android |
| details.client.os | principal.platform_version | Extracted major.minor.patch from os string using grok |
| details.client.state | principal.resource.attribute.labels | Merged as label with key "client_state" |
| details.client.user_name | target.user.userid | Value copied directly |
| details.client_ip | principal.ip, principal.asset.ip | Extracted IP using grok pattern |
| details.from_address | principal.ip, principal.asset.ip | Extracted IP using grok pattern |
| details.project.create_server_users | target.resource.attribute.labels | Converted to string, merged as label with key "project_create_server_users" |
| details.project.force_shared_ssh_users | target.resource.attribute.labels | Converted to string, merged as label with key "project_force_shared_ssh_users" |
| details.project.forward_traffic | target.resource.attribute.labels | Converted to string, merged as label with key "project_forward_traffic" |
| details.project.id | target.resource.id | Value copied directly |
| details.project.name | target.resource.name | Value copied directly |
| details.project.next_unix_gid | target.resource.attribute.labels | Converted to string, merged as label with key "next_unix_gid" |
| details.project.next_unix_uid | target.resource.attribute.labels | Converted to string, merged as label with key "next_unix_uid" |
| details.project.rdp_session_recording | target.resource.attribute.labels | Converted to string, merged as label with key "project_rdp_session_recording" |
| details.project.require_preauth_for_creds | target.resource.attribute.labels | Converted to string, merged as label with key "project_require_preauth_for_creds" |
| details.project.ssh_certificate_type | target.resource.attribute.labels | Merged as label with key "project_ssh_certificate_type" |
| details.project.ssh_session_recording | target.resource.attribute.labels | Converted to string, merged as label with key "project_ssh_session_recording" |
| details.project.team | target.resource.attribute.labels | Merged as label with key "project_team" |
| details.server.alt_names | target.hostname, target.asset.hostname, target.resource.attribute.labels | First alt_name set to target.hostname and target.asset.hostname, others merged as labels with key "alt_name" |
| details.server.hostname | intermediary_value.hostname | Value copied directly |
| details.server.id | intermediary_value.resource.attribute.labels | Merged as label with key "details_server_id" |
| details.server.os | intermediary_value.platform_version | Value copied directly |
| details.server.os | intermediary_value.resource.attribute.labels | Merged as label with key "details_server_os" |
| details.server.os_type | intermediary_value.platform | Set to LINUX if matches (?i)linux; WINDOWS if matches (?i)windows; MAC if matches (?i)mac |
| details.server.services | intermediary_value.resource.attribute.labels | Merged as labels with key "server_services {index}" |
| details.server.source | intermediary_value.resource.attribute.labels | Merged as label with key "server_source" |
| details.server.source_details.cloud_account | intermediary_value.resource.attribute.labels | Merged as label with key "server_source_details_cloud_account" |
| details.server.source_details.cloud_provider | intermediary_value.resource.attribute.labels | Merged as label with key "server_source_details_cloud_provider" |
| details.server.source_details.instance_id | intermediary_value.resource.attribute.labels | Merged as label with key "server_source_details_instance_id" |
| details.server.state | target.asset.attribute.labels | Converted to string, merged as label with key "server_state" |
| details.server.team_name | intermediary_value.user.department | Value copied directly |
| details.server_hostnames | target.hostname, target.resource.attribute.labels | First hostname set to target.hostname, others merged as labels with key "server_hostname {index}" |
| details.server_id | target.resource.attribute.labels | Merged as label with key "details_server_id" |
| details.server_os | target.platform_version | Value copied directly |
| details.server_os_type | target.platform | Set to LINUX if matches (?i)linux; WINDOWS if matches (?i)windows; MAC if matches (?i)mac |
| details.server_state | target.resource.attribute.labels | Merged as label with key "details_server_state" |
| details.session_type | extensions.auth.auth_details | Value copied directly |
| details.session_type | security_result.detection_fields | Merged as label with key "session_type" |
| details.servers | intermediary | Processed and merged as intermediary object |
| details.ssh_algorithm | network.tls.cipher | Value copied directly |
| details.ssh_key_fingerprint | target.asset.attribute.labels | Merged as label with key "ssh_key_fingerprint" |
| details.ssh_public_key | security_result.detection_fields | Merged as label with key "ssh_public_key" |
| details.target_server | target.application | Value copied directly |
| details.team_id | principal.resource.id | Value copied directly |
| details.team_id | target.resource.id | Value copied directly |
| details.team_name | additional.fields | Merged as label with key "team_name" |
| details.trace_id | network.session_id | Value copied directly |
| details.type | metadata.product_event_type | Value copied directly |
| details.username | target.user.user_display_name | Value copied directly |
| details.via | network.session_id | Value copied directly |
| details_server | intermediary_value | Processed and merged as intermediary_value object |
| id | additional.fields | Merged as label with key "id" |
| timestamp | metadata.event_timestamp | Converted using ISO8601 format |
| extensions.auth.type | extensions.auth.type | Set to "SSO" if metadata.event_type is USER_LOGIN |
| intermediary_value | intermediary | Merged from intermediary_value if not empty |
| has_principal_user | metadata.event_type | Set to USER_LOGIN if has_principal_user and has_target_user or has_principal_user and has_target and details_type matches login; else USER_UNCATEGORIZED if has_principal_user; else STATUS_UPDATE if has_principal |
| has_target_user | metadata.event_type | |
| metadata.product_name | metadata.product_name | Set to "OKTA_SCALEFT" |
| metadata.vendor_name | metadata.vendor_name | Set to "OKTA_SCALEFT" |
Need more help? Get answers from Community members and Google SecOps professionals.