EDXCompress
2 minute read
Minimum Agent Version: v1.31.0
EDXCompress fills a gap in standard OTTL which lacks native compression capabilities. This Edge Delta extension enables you to compress strings or byte arrays using various algorithms (gzip, zlib, deflate, snappy, zstd), which is essential for reducing data size before storage or transmission in telemetry pipelines.
Syntax
EDXCompress(data, algorithm, asBytes...)
data: The string or byte array to compress (can be a field reference or literal).algorithm: The compression algorithm to use. Supported values:"gzip","zlib","deflate","snappy","zstd","lz4".asBytes(optional): Boolean flag to control output format. Whentrue(default), returns a byte array. Whenfalse, returns a base64-encoded string. This parameter is variadic and can be omitted.
Input
{
"_type": "log",
"timestamp": 1735789200000,
"body": "This is a very long log message that contains repeated information. This is a very long log message that contains repeated information. This is a very long log message that contains repeated information.",
"resource": {...},
"attributes": {
"original_size": 198
},
"cache": {
"body": "This is a very long log message that contains repeated information. This is a very long log message that contains repeated information. This is a very long log message that contains repeated information."
}
}
Example
set(body, EDXCompress(cache["body"], "gzip"))
set(attributes["compression"], "gzip")
set(attributes["compressed_size"], Len(body))
Output
{
"_type": "log",
"timestamp": 1735789230000,
"body": "[compressed byte array]",
"resource": {...},
"attributes": {
"original_size": 198,
"compression": "gzip",
"compressed_size": 52
},
"cache": {
"body": "This is a very long log message that contains repeated information. This is a very long log message that contains repeated information. This is a very long log message that contains repeated information."
}
}
The body field now contains the compressed version of the original text as a byte array, significantly reducing the data size from 198 bytes to approximately 52 bytes when using gzip compression.