Prerequisites
Before setting up the integration, collect these connection details:| Variable | Description |
|---|---|
ELASTICSEARCH_USER | Username to access the Elasticsearch service |
ELASTICSEARCH_PASSWORD | Password to access the Elasticsearch service |
ELASTICSEARCH_HOST | HTTPS service host of your external Elasticsearch service |
ELASTICSEARCH_PORT | Port to use for the connection |
CA_CERTIFICATE | CA certificate in PEM format (optional, if necessary) |
CONNECTION_NAME | Name of this external connection to be used with Aiven services |
Create external Elasticsearch integration
Start by setting up an external service integration for Elasticsearch.Access integration endpoints
Log in to the Aiven Console and navigate to your project.
Select External Elasticsearch
Click Integration endpoints and select External Elasticsearch from the list.
Configure connection URL
In the connection URL field, set the connection string:Replace the placeholders with your actual values.Example:
Set index prefix
Configure the desired index prefix. This should not overlap with any existing indexes in your Elasticsearch service.
Logs are split per day with index names consisting of your prefix and a date in
year-month-day format (e.g., logs-2022-08-30).Add CA certificate (optional)
If your Elasticsearch service uses a custom CA certificate, add the certificate body in PEM format.This is typically needed if:
- Your Elasticsearch server uses a self-signed certificate
- Your server’s certificate is issued by an internal CA
Send service logs to Elasticsearch
After creating the integration endpoint, enable it for your Aiven services.Navigate to service
Click Services and open the service whose logs you want to send to Elasticsearch.
Index naming convention
Logs are automatically organized into daily indices:- Format:
{prefix}-{year}-{month}-{day} - Example: If your prefix is
aiven-logs, indices will be named:aiven-logs-2024-03-01aiven-logs-2024-03-02aiven-logs-2024-03-03
- Facilitates easier log retention management
- Improves search performance for time-based queries
- Simplifies index lifecycle management
Using Aiven CLI
You can also set up the integration using the Aiven CLI:CLI commands reference
- avn service integration-endpoint-create - Create integration endpoint
- avn service integration-endpoint-list - List integration endpoints
- avn service integration-create - Enable integration on service
Log structure
Logs sent to Elasticsearch include:- Timestamp - When the log event occurred
- Hostname - Service host that generated the log
- Service name - Aiven service name
- Log level - Severity level (INFO, WARNING, ERROR, etc.)
- Message - Log message content
- Additional fields - Service-specific metadata
Troubleshooting
Logs not appearing
- Verify the connection URL format is correct with proper URL encoding
- Check that Elasticsearch credentials have write permissions
- Confirm the Elasticsearch service is accessible from Aiven infrastructure
- Verify the index prefix doesn’t conflict with existing indices
- Check Elasticsearch cluster health and available disk space
Authentication failures
- Verify username and password are correct
- Check that the user has appropriate permissions in Elasticsearch
- Confirm the Elasticsearch service allows connections from Aiven
- Review any IP allowlists or firewall rules
Certificate errors
- Ensure the CA certificate is in proper PEM format
- Verify the certificate matches your Elasticsearch server
- Check that the certificate hasn’t expired
- Confirm the certificate chain is complete
Index creation failures
- Check that the index prefix doesn’t conflict with existing indices
- Verify Elasticsearch has sufficient resources to create new indices
- Review Elasticsearch logs for any error messages
- Confirm index templates or ILM policies aren’t blocking creation
Connection timeout
- Verify the Elasticsearch host and port are correct
- Check that the Elasticsearch service is running
- Confirm network connectivity between Aiven and Elasticsearch
- Review firewall rules and security groups
Index management
Retention policies
To manage log retention:- Use Elasticsearch Index Lifecycle Management (ILM) policies
- Set up automated deletion of old indices
- Configure index rollover based on size or age
- Archive indices to cold storage before deletion
Search optimization
For better search performance:- Use index patterns for time-based queries
- Configure appropriate shard and replica counts
- Set up index templates for consistent field mappings
- Consider using data tiers for older logs
Storage considerations
- Monitor Elasticsearch disk usage regularly
- Set up alerts for high disk usage
- Plan capacity based on log volume and retention period
- Use compression for older indices