Edge Delta's EDXCode Extension
EDXCode enables inline JavaScript execution for advanced data transformations in Edge Delta Telemetry Pipelines.
3 minute read
Overview
edx_code is a Beta feature introduced in Edge Delta Agent v2.6.0 that executes inline JavaScript expressions within OTTL transform statements. This function enables sophisticated data transformations that would be difficult or impossible using native OTTL alone, including conditional logic, array manipulation, nested object operations, and multi-step computations—all within a secure sandbox environment.
Using the Code Processor (GUI)
Edge Delta provides a visual Code processor in the pipeline builder interface that simplifies working with edx_code. This processor offers:
- JavaScript editor with syntax highlighting for writing transformation code
- AI-assisted code generation via “Generate with AI” button
- Automatic OTTL wrapping - your JavaScript is automatically converted to a properly formatted
edx_code()OTTL statement - Preview of generated OTTL - see the final statement before saving
- Integrated validation - syntax errors are caught before deployment

When you use the Code processor, you write plain JavaScript (e.g., item.attributes["new_field"] = "Hello"), and Edge Delta automatically generates the complete OTTL statement (e.g., edx_code("item.attributes[\"new_field\"] = \"Hello\";")). This eliminates the need to manually escape quotes and format the edx_code() function call.
Code Processor vs. Custom Processor:
- Code Processor: Visual editor with AI assistance, automatic OTTL generation, type:
codein YAML - Custom Processor: Write
edx_code()statements manually in OTTL, type:ottl_transformin YAML
Both approaches produce the same runtime behavior—use the Code processor for convenience or write edx_code() manually in custom processors when you prefer direct control over the OTTL statements.
Prerequisites
To use edx_code in your pipelines, you need:
- Edge Delta Agent v2.6.0 or later
- A pipeline with OTTL transform processors
- JSON parsing enabled (typically
log_parsing_mode: full) for field access - Understanding of JavaScript ES6+ syntax
How It Works
edx_code executes JavaScript code in a restricted sandbox that has access to the telemetry event through the item object. The JavaScript runtime supports ES6+ features including arrow functions, template literals, const/let declarations, and all standard built-in objects (Math, Date, JSON, RegExp, Array, Object, etc.). The function modifies fields in place and returns control to the OTTL pipeline for subsequent processing.
Syntax
edx_code("JavaScript expression")
JavaScript expression: A string containing valid JavaScript code that operates on theitemobject- The
item['attributes']path provides access to event attributes - The
item['body']path provides access to parsed JSON body content - Code can include multiple statements when wrapped in braces
Return Value
edx_code modifies the telemetry event in place and does not return a value that can be assigned. Any fields set within the JavaScript code are directly applied to the event attributes.
Quick Start
Simple Example
edx_code("item['attributes']['greeting'] = 'Hello from Edge Delta';")
edx_code("item['attributes']['timestamp'] = Date.now();")
String Concatenation
edx_code("item['attributes']['full_name'] = item['attributes']['first'] + ' ' + item['attributes']['last'];")
Conditional Logic
edx_code("item['attributes']['level_category'] = item['attributes']['score'] > 50 ? 'high' : 'low';")
Learn More
Explore the detailed guides for specific use cases:
- Basic Operations - String, numeric, and boolean operations
- Complex Transformations - Conditionals, nested objects, arrays, and multi-step logic
- End-to-End Examples - Complete pipeline configurations with real-world scenarios
- JavaScript Sandbox - Understanding capabilities, restrictions, and global state behavior
- Performance & Limitations - Performance considerations, type conversions, and known limitations
- Troubleshooting - Common issues and solutions
Comparison with Native OTTL
| Feature | Native OTTL | edx_code | Advantage |
|---|---|---|---|
| Simple field assignment | ✅ Easy | ✅ Easy | Equal |
| Conditional logic | ⚠️ where clauses only | ✅ Full if/else/ternary | edx_code |
| Array manipulation | ❌ Very limited | ✅ All array methods | edx_code |
| Nested object creation | ❌ Difficult | ✅ Easy with null-safe checks | edx_code |
| JSON operations | ❌ Not available | ✅ Full JSON support | edx_code |
| Performance | ✅ Native Go speed | ⚠️ JavaScript overhead | OTTL |
Use edx_code when you need capabilities beyond native OTTL. Use native OTTL for simple operations where performance is critical.