Elasticsearch
Search and visualize compact events in Elasticsearch and OpenSearch with no loss of log content: compact is a reversible in-place shrink, and L1ES expands events back to their original text at query time. This open-source plugin transparently expands compact events at query time, keeping Kibana search, dashboards and alerts working on the queries it rewrites while reducing ingestion and storage.
How It Works
L1ES is an Elasticsearch plugin that intercepts search requests and expands compact events before returning results. Kibana searches, dashboards and alerts built on match, match_phrase, multi_match and the KQL that compiles to them run on the original log text; term, terms, wildcard, regexp, fuzzy, range, aggregations and highlight on a compact field run on the compact form.
Two mechanisms make this transparent:
- Query rewriting, standard
match,match_phrase, andmulti_matchqueries are automatically converted to L1ES equivalents that search across expanded content _sourceexpansion, encoded fields in_sourceare expanded in search responses, so Kibana Discover, document views, and dashboards display the original log text
Ingestion Flow
Events are compact at the edge and ingested into Elasticsearch with reduced payload size:
graph LR
A["<div style='font-size: 14px;'>🗜️ Compact</div><div style='font-size: 10px;'>Compact Events</div>"] --> B["<div style='font-size: 14px;'>📡 Ingest</div><div style='font-size: 10px;'>Bulk API</div>"]
B --> C["<div style='font-size: 14px;'>📋 Templates</div><div style='font-size: 10px;'>l1es_dml Index</div>"]
B --> D["<div style='font-size: 14px;'>💾 Index</div><div style='font-size: 10px;'>Encoded Events</div>"]
classDef edge fill:#7c3aed88,stroke:#6d28d9,color:#ffffff,stroke-width:2px,rx:8,ry:8
classDef ingest fill:#9333ea88,stroke:#7c3aed,color:#ffffff,stroke-width:2px,rx:8,ry:8
classDef store fill:#2563eb88,stroke:#1d4ed8,color:#ffffff,stroke-width:2px,rx:8,ry:8
class A edge
class B ingest
class C,D store
🗜️ Compact: Receiver (Compact mode) compacts events, extracting repetitive patterns into templates
📡 Ingest: Encoded events forwarded to Elasticsearch via the Bulk API with reduced payload size
📋 Templates: Templates stored in the l1es_dml internal index for lookup at query time
💾 Index: Compact events stored with template hash references
Search Flow
Standard Elasticsearch queries are transparently rewritten to expand compact events:
graph LR
E["<div style='font-size: 14px;'>👤 User</div><div style='font-size: 10px;'>KQL / Query DSL</div>"] --> F["<div style='font-size: 14px;'>🔄 Rewrite</div><div style='font-size: 10px;'>Intercept Query</div>"]
F --> G["<div style='font-size: 14px;'>🔍 Match</div><div style='font-size: 10px;'>Templates + Values</div>"]
G --> H["<div style='font-size: 14px;'>📖 Expand</div><div style='font-size: 10px;'>Decode _source</div>"]
H --> I["<div style='font-size: 14px;'>📊 Results</div><div style='font-size: 10px;'>Full Data</div>"]
classDef user fill:#059669,stroke:#047857,color:#ffffff,stroke-width:2px,rx:8,ry:8
classDef hook fill:#f59e0b,stroke:#d97706,color:#ffffff,stroke-width:2px,rx:8,ry:8
classDef result fill:#ea580c88,stroke:#c2410c,color:#ffffff,stroke-width:2px,rx:8,ry:8
class E user
class F,G hook
class H,I result
👤 User: Submits search query through Kibana, API, or any Elasticsearch client
🔄 Rewrite: ActionFilter intercepts the search request and converts standard queries to L1ES equivalents
🔍 Match: L1ES queries match search terms against template patterns and encoded values
📖 Expand: Fetch sub-phase decodes encoded fields in _source and fields
📊 Results: Full events returned with original field names and values
Compact Documents in Elasticsearch
A compact event replaces the log message with a template reference and variable values. Here is the same event before and after optimization:
Original event _source:
{
"message": "2026-02-25T14:03:22Z INFO [http-handler] POST /api/v2/orders completed in 42ms status=200 bytes=1583 user=acct_7291",
"@timestamp": "2026-02-25T14:03:22.000Z",
"kubernetes.pod_name": "order-svc-6f8b4d-xk2lp"
}
Compact event _source (as stored in Elasticsearch):
{
"message": "~a3f29c01,2026-02-25T14:03:22Z,/api/v2/orders,42,200,1583,acct_7291",
"@timestamp": "2026-02-25T14:03:22.000Z",
"kubernetes.pod_name": "order-svc-6f8b4d-xk2lp"
}
Expanded event (returned by L1ES at query time):
Identical to the original. L1ES looks up template a3f29c01 in the l1es_dml index, reconstructs the full message from the template pattern and variable values, and returns it in _source. Search hits and document views show the original text; the queries and aggregations under Not Rewritten read the compact form.
What changes and what stays the same:
| Field | Compact? | Notes |
|---|---|---|
message (or configured source field) |
Yes | Replaced with ~hash,val1,val2,... |
@timestamp |
No | Passed through unchanged |
| All other fields | No | Metadata, labels, Kubernetes fields unchanged |
| Index mappings | No | Same field types, same index patterns |
Only the field registered via _l1es/add-dml-index is compacted. Everything else is stored and indexed exactly as before.
Compact mode encodes the log message into the registered source field while leaving Kubernetes labels, pod names, and other metadata as normal JSON. The plugin's expansion path expects the compact line at the field root, and Kibana aggregations on metadata fields keep working against the original values. The elasticsearch-plugin README covers the Receiver setting and an optional knob that drops repeating low-value metadata for additional storage savings.
Query Behavior
L1ES intercepts standard Elasticsearch queries and rewrites them to search across compact content. The following query types are transparently rewritten:
Supported Query Types
| Query Type | Behavior |
|---|---|
match |
Rewritten to l1es_match, searches template patterns and variable values |
match_phrase |
Rewritten to l1es_match_phrase, phrase matching across expanded content |
multi_match |
Rewritten to l1es_multi_match, multi-field search across expanded content |
| KQL (Kibana) | KQL compiles to match/match_phrase, works transparently |
A search built from these types runs on the original text with no change to the query; the types under Not Rewritten run on the compact form.
Not Rewritten
| Query Type | Behavior |
|---|---|
term / terms |
Searches the raw indexed value, matches compact form, not expanded text |
wildcard / regexp / fuzzy |
Operates on raw indexed tokens |
range |
Works on non-compacted fields (e.g., @timestamp), not applicable to compact text fields |
Aggregations (terms, significant_terms) |
Aggregate on raw indexed values, compact field values appear as ~hash,... in buckets |
highlight |
Highlights raw indexed tokens, not expanded text |
Practical impact: Most Kibana usage (Discover search bar, dashboard panels, alerting rules) relies on match and match_phrase queries, which are fully supported. Direct term queries and aggregations on the compacted field will see the raw compact form.
Workaround for aggregations: Use aggregations on non-compacted fields (e.g., kubernetes.pod_name, level, @timestamp) which are stored unchanged. For aggregations that must operate on expanded message content, use Retriever to expand events into a separate index.
_source and fields
Both _source and fields responses expand the compacted field automatically when source_decoding_enabled and decoding_enabled are true (both default to true). API consumers, Kibana document views, and CSV exports receive the original text.
Quickstart
To get searchable compact events in Elasticsearch in under 15 minutes:
Step 1: Install the Plugin
Install the L1ES plugin on each Elasticsearch data node:
Restart Elasticsearch after installing.
Restart OpenSearch after installing.
Prerequisites:
| Requirement | Description |
|---|---|
| Elasticsearch 8.17.0 or OpenSearch 2.19.0 | Self-hosted with plugin install access, or Elastic Cloud Hosted with the plugin uploaded as an extension built for the deployment's exact version; there is no 9.x build |
| Java 17+ | Required by Elasticsearch 8.x and OpenSearch 2.x |
| Admin access | Needed to install plugins and restart nodes |
Step 2: Initialize and Register
Initialize the plugin's internal indices:
Register which index and field contain encoded data:
curl -X POST 'http://localhost:9200/_l1es/add-dml-index' \
-H 'Content-Type: application/json' \
-d '{
"index_name": "my-logs",
"source": "message",
"dest": "decoded_message"
}'
| Parameter | Description |
|---|---|
index_name |
Your data index containing encoded events |
source |
The field containing encoded events (e.g., message) |
dest |
Field name for expanded output (defaults to source if omitted) |
Repeat add-dml-index for each index that contains encoded data.
Step 3: Configure Forwarder
Configure your log forwarder to send encoded events and templates to Elasticsearch.
Start from the 10x sidecar configuration:
Use the Fluent Bit overlay in Deploy, or the tenx-sidecar.conf recipe outside Kubernetes, and add receiverOptimize true to the Receiver's arguments. In the overlay, set Merge_Log Off in the kubernetes filter (and remove Keep_Log Off), so a JSON log line stays in log, where the Receiver compacts it. Each record returns from the Receiver with tenx. in front of its tag, templates included, so both outputs below match tenx. tags.
Configure Elasticsearch outputs in place of the [OUTPUT] that writes tenx.* to stdout:
# ========================= TEMPLATES OUTPUT =========================
# Routes templates to l1es_dml index for plugin template lookup
[OUTPUT]
Name es
Match tenx.tenx-template
Host your-elasticsearch-host.com
Port 9200
Index l1es_dml
Type _doc
Suppress_Type_Name On
TLS On
TLS.Verify Off
# ========================= ENCODED EVENTS OUTPUT ====================
# Routes encoded log events to your target index. The Receiver's
# connection notice (tag tenx-stdout) matches no output and is dropped.
[OUTPUT]
Name es
Match_Regex ^tenx\.(?!tenx-template|tenx-stdout).*
Host your-elasticsearch-host.com
Port 9200
Index my-logs
Type _doc
Suppress_Type_Name On
TLS On
TLS.Verify Off
Start from the 10x sidecar configuration:
Use the Fluentd overlay in Deploy, or the tenx-sidecar.conf recipe outside Kubernetes, and add receiverOptimize true to the Receiver's arguments. Records return from the Receiver into the @OUTPUT label. Templates return tagged tenx-template, and every other record keeps its tag.
Configure Elasticsearch outputs in place of the @OUTPUT label's stdout match:
<label @OUTPUT>
# ========================= TEMPLATES OUTPUT =========================
<match tenx-template>
@type elasticsearch
host your-elasticsearch-host.com
port 9200
index_name l1es_dml
type_name _doc
suppress_type_name true
</match>
# The Receiver's connection notice: discard it.
<match tenx-stdout>
@type null
</match>
# ========================= ENCODED EVENTS OUTPUT ====================
<match **>
@type elasticsearch
host your-elasticsearch-host.com
port 9200
index_name my-logs
type_name _doc
suppress_type_name true
</match>
</label>
Step 4: Verify End-to-End
Run these queries to confirm everything is working:
1. Check templates are loaded:
Expected:count > 0
2. Check encoded events are indexed:
Expected:count > 0
3. Search with a standard query (transparent rewriting):
curl -X POST 'http://localhost:9200/my-logs/_search' \
-H 'Content-Type: application/json' \
-d '{"query":{"match":{"message":"error"}},"size":3}'
_source, original log text, not ~hash,val1,val2...
4. Open Kibana Discover:
Navigate to Kibana, select your index pattern, and search using KQL (e.g., message: "error"). Results should display the full original log events.
Verification Checklist
Use this checklist to diagnose issues at each stage of the pipeline.
Plugin Loaded?
Test:
| Result | Meaning | Action |
|---|---|---|
| JSON with version | Plugin loaded | Proceed to setup check |
| 400/404 error | Plugin not installed | Reinstall plugin, restart Elasticsearch |
Internal Indices Created?
Test:
| Result | Meaning | Action |
|---|---|---|
l1es_dml and l1es_dml_indices listed |
Setup complete | Proceed to template check |
| No indices | Setup not run | Run POST _l1es/setup |
Templates Loaded?
Test:
| Result | Meaning | Action |
|---|---|---|
| Count > 0 | Templates present | Proceed to search check |
| Count = 0 | No templates loaded | Check forwarder config, verify templates are being sent to l1es_dml index |
Queries Returning Expanded Results?
Test:
curl -X POST 'http://localhost:9200/my-logs/_search' \
-H 'Content-Type: application/json' \
-d '{"query":{"match":{"message":"your-search-term"}},"size":1}'
| Result | Meaning | Action |
|---|---|---|
Expanded _source with original text |
Working correctly | Done |
~hash,val1,val2... in _source |
Source expansion not active | Check source_decoding_enabled: true in l1es.yml, verify field is registered via add-dml-index |
| 0 hits | Query rewriting not matching | Check query_rewrite_enabled: true in l1es.yml, verify template hash exists in l1es_dml |
Troubleshooting
Standard Queries Return 0 Hits on Encoded Data
Symptom: A match or match_phrase query on an encoded field returns no results, even though the data is indexed.
Common Causes:
| Cause | Solution |
|---|---|
query_rewrite_enabled is false |
Set to true in config/l1es.yml and restart |
| Field not registered | Run POST _l1es/add-dml-index for the index and field |
| Templates not loaded | Check l1es_dml index has matching template hashes |
| Wrong index name in registration | Verify index_name matches your data index exactly |
Kibana Shows Encoded Text Instead of Expanded
Symptom: Kibana Discover displays ~hash,val1,val2... instead of the original log line.
Common Causes:
| Cause | Solution |
|---|---|
source_decoding_enabled is false |
Set to true in config/l1es.yml and restart |
| Field not registered | Run POST _l1es/add-dml-index with the correct source field |
| Template hash not found | Verify template exists: GET l1es_dml/_doc/<hash-from-event> |
Plugin Not Loading After Install
Symptom: GET _l1es returns 400 or the endpoint is not found.
Diagnostic Steps:
-
Check Elasticsearch logs for plugin loading errors:
-
Verify the plugin is listed:
| Error | Cause | Solution |
|---|---|---|
java.lang.UnsupportedClassVersionError |
Wrong Java version | L1ES requires Java 17+ |
Plugin version mismatch |
ES/OS version mismatch | Use the plugin build matching your ES/OS version |
| Plugin not in list | Install failed | Reinstall with --batch flag |
Configuration
The plugin reads config/l1es.yml from its plugin directory. Key settings:
flags:
enabled: true # Master switch
query_rewrite_enabled: true # Transparent rewriting of standard queries
source_decoding_enabled: true # Decode encoded fields in _source responses
decoding_enabled: true # Decode encoded fields in 'fields' responses
match_query_enabled: true # Enable l1es_match query type
match_pharse_query_enabled: true # Enable l1es_match_phrase query type
multi_match_query_enabled: true # Enable l1es_multi_match query type
| Flag | Default | Description |
|---|---|---|
query_rewrite_enabled |
true |
Converts standard match/match_phrase/multi_match to L1ES equivalents |
source_decoding_enabled |
true |
Expands encoded fields in _source for registered indices |
decoding_enabled |
true |
Expands encoded fields when requested via the fields parameter |
Components
| Component | Description |
|---|---|
| Query Rewriter | Recursive query tree walker that converts standard queries to L1ES equivalents |
| Action Filter | ES ActionFilter intercepting search requests for transparent rewriting |
| Fetch Sub-Phase | Expands _source and fields for encoded events in search responses |
| Template Index | Internal l1es_dml index storing template patterns for lookup at query time |
| REST Handlers | _l1es/setup, _l1es/add-dml-index, and other management endpoints |
Platform Support
L1ES supports Elasticsearch 8.17.0 and OpenSearch 2.19.0, with one plugin build for each. Both builds are functionally identical.
| Platform | Version | Plugin Build |
|---|---|---|
| Elasticsearch | 8.17.0 | l1es-plugin-1.0.1.es.8.17.0.zip |
| OpenSearch | 2.19.0 | l1es-plugin-1.0.1.os.2.19.0.zip |
The plugin must be installed on every data node in your cluster. Coordinating-only nodes and Kibana instances do not need the plugin.
On Elasticsearch 9.x, Elastic Cloud Hosted included, the Receiver's lever is tier down, and Retriever returns offloaded events from S3 on demand. Elasticsearch 9.3 and later store templates natively in the pattern_text field type, and Cloud Hosted loads an uploaded plugin only when it is built for the deployment's exact version.
Version compatibility: Each plugin build is compiled against a specific Elasticsearch/OpenSearch version. The plugin version must match your cluster version exactly. An ES 8.17.0 plugin will not load on ES 8.16.x or 8.18.x. The latest release carries l1es-plugin-1.0.1.es.8.17.0.zip and l1es-plugin-1.0.1.os.2.19.0.zip. To build from the repository with a Java 17 JDK: ./gradlew build writes build/distributions/l1es-plugin-1.0.1.es.8.17.0.zip for Elasticsearch 8.17.0, and ./gradlew :opensearch:build -x test writes opensearch/build/distributions/l1es-plugin-1.0.1.os.2.19.0.zip for OpenSearch 2.19.0.
Version History
| L1ES | Elasticsearch | OpenSearch | Java | Lucene |
|---|---|---|---|---|
| 1.0.1 | 8.17.0 | 2.19.0 | 17+ | 9.12.0 |
OpenSearch Config
After installing L1ES on OpenSearch, verify that config/l1es-plugin/l1es.yml exists. If missing, copy it from plugins/l1es-plugin/config/l1es.yml.
Production Operations
Rolling Upgrades
L1ES supports rolling upgrades without downtime. Upgrade one data node at a time:
-
Disable shard allocation, prevent rebalancing during the restart:
-
Stop Elasticsearch on the target node
-
Install the new plugin version (remove old, install new):
-
Start Elasticsearch on the node
-
Re-enable shard allocation:
-
Wait for green status before proceeding to the next node:
Repeat for each data node. During the upgrade, nodes running the old plugin version continue to expand queries. Mixed-version operation is safe as long as the l1es_dml index schema has not changed between versions (check the release notes).
Upgrading Elasticsearch with L1ES Installed
When upgrading Elasticsearch itself (e.g., 8.16 → 8.17), you need a matching L1ES build for the target ES version. The plugin zip is compiled against a specific ES version and will not load on a different one.
-
Before the upgrade: Take the L1ES zip for the target version from the release, or build it from the repository, as under Platform Support. For a version that section does not list, contact Log10x support.
-
Per node (rolling, one at a time):
- Disable shard allocation (same as rolling upgrade above)
- Stop Elasticsearch
- Upgrade Elasticsearch to the target version
- Remove the old L1ES plugin:
bin/elasticsearch-plugin remove l1es - Install the new L1ES build:
bin/elasticsearch-plugin install file:///path/to/l1es-plugin-<version>.es.<target-es-version>.zip - Start Elasticsearch
- Re-enable shard allocation
- Wait for green status
-
After the upgrade: Verify L1ES is loaded on all nodes:
GET _l1esshould return the new version. Run a test query to confirm expansion works.
The l1es_dml and l1es_dml_indices internal indices persist across the upgrade, no need to re-run _l1es/setup or re-register indices.
Operator Checklist
Pre-production readiness checklist for L1ES deployments:
| Category | Check | How to Verify |
|---|---|---|
| Install | Plugin installed on every data node | GET _l1es returns version on each node |
| Install | Plugin version matches ES/OS version exactly | Compare plugin build version to GET / output |
| Setup | Internal indices created | GET _cat/indices/l1es_*?v lists l1es_dml and l1es_dml_indices |
| Setup | Target indices registered | GET _l1es/dml-indices lists your data indices |
| Forwarder | Templates routed to l1es_dml |
GET l1es_dml/_count returns > 0 |
| Forwarder | Compact events routed to data index | GET my-logs/_count returns > 0 |
| Search | Query rewriting active | match query returns expanded results |
| Search | _source expansion active |
Document view in Kibana shows original text |
| Config | l1es.yml flags reviewed |
All three flags default true, adjust if needed |
| Ops | Cluster health green after install | GET _cluster/health |
| Ops | Plugin appears in node info | GET _nodes/plugins lists l1es on each data node |
Performance
Two operations add work to a search on compact fields:
- Query rewriting, translating
match/match_phraseto L1ES equivalents (per-query, microseconds) _sourceexpansion, template lookup and string substitution for each hit (per-document, sub-millisecond)
The overhead scales with result set size, not data volume. A query returning 500 hits expands 500 documents regardless of whether the index holds 1M or 1B events.
Net effect on cluster performance: A compact storage reduction means fewer data nodes, less SSD, and less memory required for the same retention period. The reduced shard sizes also improve baseline query performance (smaller segments to scan).
REST API
| Endpoint | Method | Description |
|---|---|---|
_l1es |
GET | Plugin info (version, description) |
_l1es/setup |
POST | Create internal indices (l1es_dml, l1es_dml_indices) |
_l1es/cleanup |
POST | Remove internal indices |
_l1es/add-dml-index |
POST | Register an encoded field mapping for an index |
_l1es/remove-dml-index |
POST | Unregister an encoded field mapping |
This plugin is open source. View on GitHub.