Overview
Data Pipelines provide:- Real-time transformations - Modify events as they’re ingested
- Event filtering - Route specific events to destinations
- Hog functions - Write custom logic in PostHog’s scripting language
- Destinations - Send data to webhooks, Slack, databases, and more
- Error handling - Automatic retries and degradation states
Transformations
Transformations modify events before they’re stored. Use them to:- Enrich events with external data
- Normalize property formats
- Filter out PII
- Add computed properties
Creating a Transformation
1
Write Hog code
Transformations use Hog, PostHog’s event processing language:
2
Set filters
Only process specific events:
3
Deploy
Transformations apply immediately to new events. Existing events aren’t modified.
Transformation Examples
Destinations
Destinations send event data to external systems. PostHog supports:- Webhooks - POST events to any HTTP endpoint
- Message queues - Kafka, RabbitMQ, AWS SQS
- Data warehouses - Snowflake, BigQuery, Redshift
- Tools - Slack, Discord, customer.io, Amplitude
Webhook Destination
Send events to a webhook:Destinations run asynchronously. They don’t block event ingestion, and failures
are automatically retried with exponential backoff.
Slack Notifications
Send alerts to Slack:Database Export
Write to PostgreSQL:Hog Language Reference
Available Context
Hog functions have access to:Built-in Functions
Control Flow
Function Inputs
Define configurable inputs for your functions:Error Handling
Automatic Retries
Failed destinations are automatically retried with exponential backoff:- First retry: 1 minute
- Second retry: 5 minutes
- Third retry: 15 minutes
- Subsequent retries: 30 minutes
Degraded State
Functions enter degraded state after repeated failures:Error Logging
Log errors for debugging:Monitoring
Function Metrics
Track function performance:- Execution count - Total invocations
- Success rate - Percentage of successful runs
- Average latency - Time spent processing
- Error rate - Failed invocations
Health Status
Functions have health states:- Active - Running normally
- Degraded - Experiencing errors but still running
- Disabled - Automatically disabled after sustained failures
- Forcefully disabled - Manually disabled by admin
Best Practices
Keep Transformations Fast
Transformations run synchronously during ingestion. Avoid slow operations like
external API calls. If needed, use destinations for async processing.
Use Filters Wisely
Apply specific event filters to avoid running functions unnecessarily. This
reduces costs and improves performance.
Handle Failures Gracefully
Use try/catch blocks and validate data before processing. Failed transformations
can drop events, while failed destinations only lose the external delivery.
Test Before Deploying
Test Hog functions with sample events before enabling. Use print() statements
for debugging during development.
Limitations
Transformation limits:
- Max execution time: 30 seconds
- Max memory: 128 MB
- No file system access
- Limited external API calls (use destinations for heavy I/O)
Destination limits:
- Max retries: 10 attempts over 24 hours
- Functions disabled after 100 consecutive failures
- Rate limits depend on external service