Elasticsearch
Elasticsearch is a distributed, RESTful search and analytics engine designed for horizontal scalability, reliability, and real-time search capabilities. It's built on Apache Lucene and excels at full-text search, log analytics, metrics analysis, and complex queries across large datasets. Elasticsearch is widely used for application search, log and event data analysis, infrastructure monitoring, and business analytics.
Authentication Types
Elasticsearch supports API Key authentication:
- API Key - Use Elasticsearch API keys for secure, token-based authentication
- Pros: Secure, can be scoped to specific privileges, easy to rotate
- Cons: Requires API key creation in Elasticsearch
- Best for: Production use with fine-grained access control
General Settings
Before using the connector, you need to configure:
- Elasticsearch URL - The base URL of your Elasticsearch instance
- Examples:
- Local:
http://localhost:9200 - Hosted:
https://your-cluster.es.us-east-1.aws.elastic.cloud:9243 - Self-managed:
https://elasticsearch.yourcompany.com
- Local:
- Important: Include the protocol (http/https) and port
- Examples:
For Elastic Cloud deployments, you can find your Elasticsearch endpoint in the Cloud console under "Deployments" → Your deployment → "Elasticsearch" → "Endpoint".
Setting up API Key Authentication
API Key authentication is the recommended method for production use.
Creating an API Key in Elasticsearch
-
Via Kibana UI:
- Go to Stack Management → Security → API Keys
- Click Create API key
- Configure the API key:
- Name: Give it a descriptive name (e.g., "Webrix Integration")
- Expiration: Set an expiration date or leave it to never expire
- Role descriptors (optional): Define specific privileges
- Click Create API key
- Important: Copy the API key immediately - it won't be shown again
- The key format will be:
VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==
Configuring in Webrix
- In Webrix connector settings, select API Key authentication
- Paste the encoded API key in the Token field
- Click Save Changes
Recommended Permissions
For full functionality, the API key or user should have:
Cluster privileges:
monitor- View cluster health and statsmanage_index_templates- Create and manage index templatesmanage_ilm- Manage Index Lifecycle Management (optional)
Index privileges (for relevant indices):
read- Search and retrieve documentswrite- Index and update documentscreate_index- Create new indicesdelete_index- Delete indicesview_index_metadata- View index settings and mappingsmanage- Modify index settings and mappings
You can scope these privileges to specific index patterns (e.g., logs-*, metrics-*) for tighter security.
Common Use Cases
1. Log and Event Analysis
Use Elasticsearch tools to search logs, count error events, analyze trends with aggregations, and correlate events across time.
2. Application Search
Implement full-text search for your application data, with relevance tuning, filtering, faceting, and highlighting.
3. Metrics and Monitoring
Store and analyze time-series metrics, create dashboards with aggregations, and monitor system health using cluster APIs.
4. Data Management
Manage index lifecycle with templates, aliases, and automated operations. Implement blue-green deployments with aliases.
5. Bulk Operations
Efficiently index large datasets using bulk operations, and perform mass updates or deletions with query-based operations.
Troubleshooting
Connection Issues
Symptom: "Connection refused" or timeout errors
Cause: Incorrect Elasticsearch URL, network issues, or Elasticsearch not running
Solution:
- Verify Elasticsearch is running:
curl http://localhost:9200 - Check the URL in connector settings matches your Elasticsearch endpoint
- For Elastic Cloud, ensure you're using the correct endpoint from the Cloud console
- Check firewall rules and network connectivity
Authentication Errors
Symptom: "401 Unauthorized" or "403 Forbidden" errors
Cause: Invalid API key, expired credentials, or insufficient permissions
Solution:
-
For API Key authentication:
- Verify the API key is correctly copied (encoded format)
- Check if the API key has expired in Elasticsearch
- Create a new API key if needed
-
For permission errors (403):
- Review the API key privileges
- Ensure required permissions are granted (see "Recommended Permissions")
- Check Elasticsearch logs for detailed permission errors
SSL/TLS Certificate Issues
Symptom: "SSL certificate problem" or "certificate verify failed"
Cause: Self-signed certificates or certificate chain issues
Solution:
-
For self-signed certificates in development:
- Add certificate to system trust store, or
- Configure Elasticsearch to use a valid certificate
-
For Elastic Cloud:
- Should work automatically as Elastic Cloud uses valid certificates
- If issues persist, verify network proxy settings
Query Timeout
Symptom: "Request timeout" or slow responses
Cause: Complex queries, large datasets, or under-resourced cluster
Solution:
-
Optimize queries:
- Use filters instead of queries when scoring isn't needed
- Reduce result size or use pagination
- Use specific index patterns instead of searching all indices
-
Check cluster health:
- Run "Get Cluster Health" tool
- Review shard allocation and node resources
- Consider scaling the cluster if under-resourced
-
Increase timeout (if appropriate):
- Add
timeoutparameter to search queries - Example:
{"query": {...}, "timeout": "30s"}
- Add
Index Not Found
Symptom: "index_not_found_exception"
Cause: Trying to access a non-existent index
Solution:
- Use "List Indices" tool to see available indices
- Check for typos in index names
- Verify index patterns with wildcards are correct
- Create the index if it should exist using "Create Index" tool
Mapping Conflicts
Symptom: "mapper_parsing_exception" or "illegal_argument_exception"
Cause: Trying to index a field with a different type than the mapping
Solution:
- Use "Get Mapping" tool to view current field types
- Fix the document to match existing mappings, or
- If changing field type is necessary:
- Create a new index with the correct mapping
- Use reindex API to copy data
- Update aliases to point to new index
- Delete old index
Best Practices
Security
- Use API Key authentication for production
- Scope API keys to minimum required privileges
- Rotate API keys regularly
- Enable SSL/TLS for all connections
- Never expose Elasticsearch directly to the internet
Performance
- Use bulk operations for indexing multiple documents
- Implement index templates for consistent settings
- Use aliases for zero-downtime index management
- Set appropriate refresh intervals (default 1s can be increased for write-heavy workloads)
- Use filters for boolean logic (cached) vs queries (scored)
Data Management
- Use Index Lifecycle Management (ILM) for time-series data
- Implement appropriate shard sizing (target 10-50GB per shard)
- Set replica count based on availability requirements
- Use index templates to standardize settings across indices
- Regular monitoring of cluster health and resources
Search Optimization
- Use specific index patterns instead of wildcard searches
- Implement pagination with
fromandsizeor search_after - Use
_sourcefiltering to return only needed fields - Leverage aggregations for analytics instead of post-processing results
- Use the explain API to understand and optimize relevance scoring