edx_delete_empty_values

Learn about the edx_delete_empty_values Edge Delta OTTL extension function.

Minimum Agent Version: v1.28.0

edx_delete_empty_values fills a gap in standard OTTL which lacks a dedicated function for cleaning up empty or meaningless values. While OTTL can delete specific keys with delete_key, it doesn’t provide a way to automatically remove all keys with empty, null, or custom-defined “empty” values (like “unknown” or “N/A”). This Edge Delta extension enables comprehensive data cleanup by removing fields that contain no meaningful information based on customizable criteria.

Syntax

edx_delete_empty_values(input, excluded_keys, empty_patterns, strategies)
  • input: A map (e.g., attributes, resource) from which empty values should be deleted.
  • excluded_keys: An array of key names to exclude from deletion (optional, use [] to exclude none).
  • empty_patterns: An array of string patterns to consider as empty values (e.g., ["", "unknown", "N/A"]).
  • strategies (optional): An array of strategies for additional deletion behavior. Supported values:
    • "deleteNull": Delete keys with null/empty values
    • "deleteEmptyList": Delete keys with empty arrays/slices
    • "deleteEmptyMap": Delete keys with empty maps/objects
    • "deleteZero": Delete keys with zero integer or float values

Input

{
  "_type": "log",
  "timestamp": 1735788500000,
  "body": "user_id=12345 name=John email= status=unknown location= department=null notes=",
  "resource": {...},
  "attributes": {
    "decoded_body": "user_id=12345 name=John email= status=unknown location= department=null notes=",
    "kv_map": {
      "user_id": "12345",
      "name": "John",
      "email": "",
      "status": "unknown",
      "location": "",
      "department": null,
      "notes": ""
    }
  }
}

Example

edx_delete_empty_values(attributes["kv_map"], [], ["", "unknown"], ["deleteNull"])

Output

{
  "_type": "log",
  "timestamp": 1735788530000,
  "body": "user_id=12345 name=John email= status=unknown location= department=null notes=",
  "resource": {...},
  "attributes": {
    "decoded_body": "user_id=12345 name=John email= status=unknown location= department=null notes=",
    "kv_map": {
      "user_id": "12345",
      "name": "John"
    }
  }
}

The keys email, status, location, department, and notes have been removed because their values were either empty strings, matched the pattern “unknown”, or were null (with the deleteNull option enabled).