Prompt
How do I collect logs from third-party APIs and SaaS services?
Latest observation
To collect logs from third-party APIs and SaaS services, you typically use a mix of vendor-native export methods, log forwarding integrations, and API polling/webhooks. The exact approach depends on whether the service supports pushing logs out, or only exposes them via an API.
Common ways to collect them
1) Native log export / audit log streaming
Many SaaS products offer one or more of:
- Audit log export
- Event streaming
- SIEM integration
- Webhook notifications
- Cloud storage export (S3, GCS, Azure Blob)
Examples:
- Okta, Microsoft 365, Google Workspace, Salesforce, GitHub, AWS, etc.
- Often these are the best option because they’re near real-time and designed for compliance/security use cases.
2) API polling
If the service exposes logs through an API:
- Run a scheduled job to fetch new records periodically
- Use cursor-based, timestamp-based, or pagination-based queries
- Store the last seen cursor/timestamp so you only ingest deltas
This is common when:
- There is no webhook/streaming support
- You need historical data
- The API is the only access path
Important considerations:
- Rate limits
- Pagination
- Time zone consistency
- Event ordering and late-arriving events
- Idempotency/deduplication
3) Webhooks / event subscriptions
If supported, subscribe to events and receive them as they happen.
- Best for low latency
- Good for operational alerts
- Usually not enough by itself for complete auditing, so many teams pair it with periodic backfill from APIs
4) Log forwarding agents / connectors
Use a log pipeline or observability tool that already has connectors:
- Splunk
- Datadog
- Elastic
- Sumo Logic
- Microsoft Sentinel
- CrowdStrike/Falco-style tooling in some cases
These tools may:
- Pull from APIs
- Receive webhooks
- Ingest via vendor-specific streaming endpoints
5) Export via cloud storage, then ingest
Some vendors can dump logs to object storage:
- S3 / GCS / Azure Blob
- Then a collector ingests from there into your SIEM/data lake
This is useful for:
- Large volumes
- Batch processing
- Long-term retention
Typical architecture
A practical setup looks like this:
- Source system (SaaS/API)
- Collector
- webhook receiver, scheduled poller, or vendor integration
- Normalization layer
- parse JSON/CSV
- map fields to a common schema
- Storage
- SIEM, log store, data lake, or database
- Alerting / analysis
- dashboards, detections, compliance reports
Key design tips
Use a common schema
Normalize events into a consistent structure, such as:
timestampsourceevent_typeactortargetstatusraw_payload
This makes correlation across vendors much easier.
Handle authentication securely
Most third-party APIs use:
- OAuth 2.0
- API keys
- Service accounts
- Signed webhooks
Store secrets in a secrets manager and rotate them regularly.
Deduplicate events
Third-party sources often re-send events or return overlapping data.
- Use event IDs if available
- Otherwise hash stable fields
- Maintain an ingestion checkpoint
Plan for retries and gaps
Your collector should:
- Retry transient failures
- Detect missed intervals
- Support backfill/replay
- Alert when ingestion stops
Watch rate limits and quotas
Implement:
- exponential backoff
- pagination
- incremental sync
- concurrency limits
Preserve raw logs
Keep original payloads if possible, even if you also normalize them. Raw logs help with:
- forensic investigations
- schema changes
- reprocessing
Example implementation patterns
If the vendor supports webhooks
- Register a webhook endpoint
- Verify signatures
- Queue incoming events
- Persist raw payloads
- Process asynchronously
If the vendor only has an API
- Poll every N minutes
- Query for events newer than the last checkpoint
- Paginate until exhausted
- Update checkpoint only after successful ingestion
If the vendor supports SIEM export
- Configure native export to your SIEM or storage bucket
- Validate field mappings
- Confirm retention and completeness
What to ask vendors before integrating
- Do you support audit logs, event streams, or webhooks?
- What is the retention period for logs?
- Is there an API to backfill historical logs?
- Are log timestamps in UTC?
- How do you handle pagination and rate limits?
- Can you export to S3/GCS/Azure Blob?
- Do events have unique IDs for deduplication?
- Are logs available in near real time?
Recommended approach
If you want a robust setup:
- Use webhooks/streaming where available
- Use API polling for backfill and completeness
- Normalize all vendor logs into a common schema
- Store raw events
- Build checkpointing, deduplication, and alerting into the pipeline
If you want, I can also give you:
- a reference architecture for collecting SaaS logs,
- a Python example for polling an API and storing logs, or
- a vendor-by-vendor strategy for common services like Google Workspace, GitHub, Okta, and Microsoft 365.