This guide helps you migrate from the legacy malachite ingestion API to the new Chronicle REST API.
Logstory now supports both the legacy malachite ingestion API and the new Chronicle REST API. The system automatically detects which API to use based on your credentials, or you can explicitly specify the API type.
- Endpoint:
malachiteingestion-pa.googleapis.com - Scope:
https://www.googleapis.com/auth/malachite-ingestion - Simple authentication with service account
- Batch endpoints:
/v2/unstructuredlogentries:batchCreate,/v2/udmevents:batchCreate
- Endpoint:
chronicle.googleapis.com - Scope:
https://www.googleapis.com/auth/cloud-platform - Requires Google Cloud project ID
- Supports forwarder management
- Supports service account impersonation
- Enhanced regional support
The REST API requires service account credentials with the cloud-platform scope instead of the malachite-ingestion scope.
To create new credentials:
- Go to the Google Cloud Console
- Navigate to IAM & Admin > Service Accounts
- Create a new service account or update an existing one
- Grant the necessary Chronicle API permissions
- Download the JSON key file
For Legacy API (.env.legacy):
LOGSTORY_CUSTOMER_ID=01234567-0123-4321-abcd-01234567890a
LOGSTORY_CREDENTIALS_PATH=/path/to/malachite-credentials.json
LOGSTORY_REGION=US
LOGSTORY_API_TYPE=legacy # RequiredFor REST API (.env.rest):
LOGSTORY_CUSTOMER_ID=01234567-0123-4321-abcd-01234567890a
LOGSTORY_PROJECT_ID=my-project-123
LOGSTORY_CREDENTIALS_PATH=/path/to/rest-credentials.json
LOGSTORY_REGION=US
LOGSTORY_API_TYPE=rest # RequiredLegacy API:
logstory replay usecase RULES_SEARCH_WORKSHOP \
--customer-id=01234567-0123-4321-abcd-01234567890a \
--credentials-path=/path/to/malachite-credentials.json \
--api-type=legacyREST API:
logstory replay usecase RULES_SEARCH_WORKSHOP \
--customer-id=01234567-0123-4321-abcd-01234567890a \
--project-id=my-project-123 \
--credentials-path=/path/to/rest-credentials.json \
--api-type=rest-
Start with a small test:
# Test with a single usecase logstory replay usecase RULES_SEARCH_WORKSHOP --env-file .env.rest -
Verify ingestion:
- Check your Chronicle dashboard for the ingested logs
- Verify timestamps and labels are correct
- Ensure no data loss or errors
-
Gradual rollout:
- Test with different usecases
- Monitor for any issues
- Switch production workloads after validation
Important: LOGSTORY_API_TYPE is now required and must be explicitly set to either rest or legacy.
- No auto-detection is performed
- No fallback behavior - the system will fail with clear error messages if misconfigured
- This ensures predictable behavior and prevents silent failures
To specify the API type:
- Set
LOGSTORY_API_TYPE=restfor the new Chronicle REST API - Set
LOGSTORY_API_TYPE=legacyfor the legacy malachite API
export LOGSTORY_FORWARDER_NAME=MyCustomForwarderexport LOGSTORY_IMPERSONATE_SERVICE_ACCOUNT=service-account@project.iam.gserviceaccount.com# REST API supports more regions
export LOGSTORY_REGION=EUROPE # or UK, ASIA, SYDNEY, etc.Breaking Change: LOGSTORY_API_TYPE is now required for all configurations.
- All .env files must include
LOGSTORY_API_TYPE=legacyorLOGSTORY_API_TYPE=rest - All command-line scripts must include
--api-type=legacyor--api-type=rest - Cloud Functions must set the
LOGSTORY_API_TYPEenvironment variable - CI/CD pipelines must set the
LOGSTORY_API_TYPEenvironment variable
- Update existing configurations to explicitly set
LOGSTORY_API_TYPE=legacy - Test that existing workflows still work with the explicit API type
- For new REST API usage: Set
LOGSTORY_API_TYPE=restand add requiredLOGSTORY_PROJECT_ID - No silent fallbacks - any misconfiguration will fail with clear error messages
1. Missing API Type Error
LOGSTORY_API_TYPE environment variable must be set to 'rest' or 'legacy'
- Solution: Add
LOGSTORY_API_TYPE=restorLOGSTORY_API_TYPE=legacyto your environment
2. Missing Project ID for REST API
Error: REST API is specified but missing required parameters!
LOGSTORY_API_TYPE=rest requires:
* LOGSTORY_PROJECT_ID (Google Cloud project ID)
- Solution: Pass via
--project-id your-project-idor setLOGSTORY_PROJECT_ID=your-project-idin your.envfile or environment
3. Authentication Error with REST API
- Ensure credentials have
cloud-platformscope - Verify project ID is correct
- Check service account permissions in Google Cloud Console
4. Forwarder Creation Fails
- Check project permissions for creating forwarders
- Verify region is correctly specified
- Try with a different forwarder name
Enable verbose logging to troubleshoot:
PYTHONLOGLEVEL=DEBUG logstory replay usecase RULES_SEARCH_WORKSHOP --env-file .env.rest- Better Performance: Optimized for modern cloud infrastructure
- Enhanced Security: Support for service account impersonation
- Forwarder Management: Automatic forwarder creation and caching
- Regional Flexibility: Support for more geographic regions
- Future-Proof: Aligned with Google Cloud's API standards
| Environment Variable | CLI Parameter | Description |
|---|---|---|
LOGSTORY_CUSTOMER_ID |
--customer-id |
Chronicle customer ID |
LOGSTORY_PROJECT_ID |
--project-id |
Google Cloud project ID (REST API only) |
LOGSTORY_CREDENTIALS_PATH |
--credentials-path |
Path to service account credentials JSON file |
LOGSTORY_REGION |
--region |
Geographic region (US, EUROPE, UK, ASIA, SYDNEY) |
LOGSTORY_API_TYPE |
--api-type |
Required: API type to use (rest or legacy) |
LOGSTORY_FORWARDER_NAME |
--forwarder-name |
Custom forwarder name (REST API only) |
LOGSTORY_IMPERSONATE_SERVICE_ACCOUNT |
--impersonate-service-account |
Service account to impersonate (REST API only) |
For issues or questions:
- Check the main README for general usage
- Review example .env files:
.env.legacy.example,.env.rest.example - Enable debug logging for detailed error messages
- Report issues on the GitHub repository
Breaking Change: LOGSTORY_API_TYPE is now required for all configurations. This ensures predictable behavior and eliminates silent fallbacks that could cause debugging issues.
- Update configurations to explicitly set
LOGSTORY_API_TYPE=legacyto continue using the legacy API - No automatic detection - you must specify which API to use
- Clear error messages when configuration is missing or incorrect
- Set
LOGSTORY_API_TYPE=restandLOGSTORY_PROJECT_ID - Follow the enhanced error messages for any missing configuration
- Benefit from improved performance and features