Logstash Error: Elasticsearch rejected documents - Common Causes & Fixes

Pulse - Elasticsearch Operations Done Right

On this page

Brief Explanation Impact Common Causes Troubleshooting and Resolution Steps Additional Information and Best Practices Frequently Asked Questions

Brief Explanation

The "Elasticsearch rejected documents" error occurs when Elasticsearch refuses to index some or all of the documents sent by Logstash. This typically happens when there are issues with the document structure, mapping conflicts, or resource constraints on the Elasticsearch cluster.

Impact

This error can lead to data loss or incomplete data in Elasticsearch, affecting the accuracy and completeness of your logs or analytics. It may also cause performance issues in your Logstash pipeline and potentially overload your Elasticsearch cluster.

Common Causes

  1. Mapping conflicts between the document structure and existing index mappings
  2. Field limit exceeded in the Elasticsearch index
  3. Elasticsearch cluster running out of disk space
  4. Bulk request size exceeding Elasticsearch limits
  5. Invalid or malformed documents

Troubleshooting and Resolution Steps

  1. Check Elasticsearch logs for detailed error messages.
  2. Verify the document structure and ensure it matches the expected mapping in Elasticsearch.
  3. Review your Elasticsearch index settings, particularly the field limit.
  4. Monitor Elasticsearch cluster health and ensure adequate disk space.
  5. Adjust Logstash batch size and retry options in the Elasticsearch output plugin.
  6. Use Logstash's dead letter queue to capture and analyze rejected documents.
  7. Implement proper error handling in your Logstash pipeline to manage rejected documents.

Additional Information and Best Practices

  • Regularly monitor your Elasticsearch cluster health and performance.
  • Implement proper index lifecycle management to prevent indices from growing too large.
  • Use dynamic mapping cautiously and consider using explicit mappings for critical fields.
  • Implement a robust error handling strategy in your Logstash pipeline to manage and recover from document rejections.
  • Consider using Logstash's dead letter queue feature to capture and analyze rejected documents.

Frequently Asked Questions

Q: How can I identify which documents are being rejected?
A: Enable debug logging in your Logstash configuration and check the Elasticsearch output plugin logs. You can also use Logstash's dead letter queue feature to capture rejected documents for further analysis.

Q: Can rejected documents be automatically reprocessed?
A: Yes, you can use Logstash's retry mechanism in the Elasticsearch output plugin. Set appropriate retry options and consider implementing a separate pipeline for reprocessing rejected documents from the dead letter queue.

Q: How do I prevent mapping conflicts that lead to document rejection?
A: Use explicit mappings for your Elasticsearch indices instead of relying on dynamic mapping. Regularly review and update your mappings as your data structure evolves.

Q: What should I do if Elasticsearch is rejecting documents due to disk space issues?
A: Implement proper index lifecycle management, add more storage to your Elasticsearch cluster, or consider removing old or unnecessary data. You may also need to optimize your index settings for better storage utilization.

Q: How can I handle rejected documents without losing data?
A: Implement a robust error handling strategy in your Logstash pipeline. Use the dead letter queue feature to capture rejected documents, analyze the cause of rejection, and set up a separate pipeline to reprocess these documents after addressing the underlying issues.

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.