ECS Scripts Developer Documentation

March 19, 2026 · View on GitHub

This directory contains developer-focused documentation for the ECS generation scripts.

Purpose

The ECS repository includes a comprehensive toolchain for generating various artifacts from schema definitions. These developer guides explain:

  • How each component works internally
  • Architecture and design decisions
  • How to make changes and extend functionality
  • Troubleshooting common issues

Documentation Structure

Module-Specific Guides

Each major generator module has its own detailed guide:

  • otel-integration.md - OpenTelemetry Semantic Conventions integration

    • Validation of ECS ↔ OTel mappings
    • Loading OTel definitions from GitHub
    • Generating alignment summaries
  • markdown-generator.md - Markdown documentation generation

    • Rendering ECS schemas to human-readable docs
    • Jinja2 template system and customization
    • OTel alignment documentation
    • Adding new page types
  • intermediate-files.md - Intermediate file generation

    • Flat and nested format representations
    • Bridge between schema processing and artifact generation
    • Top-level vs. reusable fieldsets
    • Data structure reference
  • es-template.md - Elasticsearch template generation

    • Composable vs. legacy template formats
    • Field type mapping conversion
    • Template customization and settings
    • Installation and troubleshooting
  • csv-generator.md - CSV field reference generation

    • Spreadsheet-compatible field export
    • Column structure and multi-field handling
    • Analysis and integration examples
    • Usage in Excel, Google Sheets, databases
  • beats-generator.md - Beats field definition generation

    • YAML field definitions for Elastic Beats
    • Default field selection and allowlist
    • Contextual naming and field groups
    • Integration with Beat modules

Quick Reference

For high-level usage information, see:

Scripts Overview

The scripts/ directory contains several key components:

Core Modules

ModulePurposeDocumentation
generator.pyMain entry point - orchestrates complete pipelineComprehensive docstrings in file
generators/otel.pyOTel integration and validationotel-integration.md
generators/markdown_fields.pyMarkdown documentation generationmarkdown-generator.md
generators/intermediate_files.pyIntermediate format generationintermediate-files.md
generators/es_template.pyElasticsearch template generationes-template.md
generators/csv_generator.pyCSV field reference exportcsv-generator.md
generators/beats.pyBeats field definition generationbeats-generator.md
generators/ecs_helpers.pyShared utility functionsSee docstrings in file

Schema Processing

The schema processing pipeline transforms YAML schema definitions through multiple stages. See schema-pipeline.md for complete pipeline documentation.

ModulePurposeDocumentation
Pipeline OverviewComplete schema processing flowschema-pipeline.md
schema/loader.pyLoad and parse YAML schemas → nested structureschema-pipeline.md#1-loaderpy---schema-loading
schema/cleaner.pyValidate, normalize, apply defaultsschema-pipeline.md#2-cleanerpy---validation--normalization
schema/finalizer.pyPerform field reuse, calculate namesschema-pipeline.md#3-finalizerpy---field-reuse--name-calculation
schema/visitor.pyTraverse field hierarchies (visitor pattern)schema-pipeline.md#visitorpy---field-traversal
schema/subset_filter.pyFilter to include only specified fieldsschema-pipeline.md#4-subset_filterpy---subset-filtering-optional
schema/exclude_filter.pyExplicitly remove specified fieldsschema-pipeline.md#5-exclude_filterpy---exclude-filtering-optional

Types

ModulePurpose
ecs_types/schema_fields.pyCore ECS type definitions
ecs_types/otel_types.pyOTel-specific types

Getting Started

If you're new to the ECS generator codebase:

  1. Start with the main orchestrator: Read generator.py docstrings to understand the pipeline
  2. Understand schema processing: Read schema-pipeline.md
  3. Pick a generator: Choose a specific generator that interests you
  4. Read its documentation: Start with the module-specific guide
  5. Explore the code: Read the source with the guide as reference
  6. Run it: Try generating artifacts to see it in action

Quick Command Reference

# Standard generation (from local schemas)
python scripts/generator.py --semconv-version v1.24.0

# From specific git version
python scripts/generator.py --ref v8.10.0 --semconv-version v1.24.0

# With custom schemas
python scripts/generator.py --include custom/schemas/ --semconv-version v1.24.0

# Generate subset only
python scripts/generator.py --subset schemas/subsets/minimal.yml --semconv-version v1.24.0

# Strict validation mode
python scripts/generator.py --strict --semconv-version v1.24.0

# Intermediate files only (fast iteration)
python scripts/generator.py --intermediate-only --semconv-version v1.24.0

See generator.py docstrings for complete argument documentation.

Contributing Documentation

When adding or modifying generator code:

  1. Update docstrings: Add comprehensive Python docstrings to all functions and classes
  2. Update/create guide: Ensure a markdown guide exists explaining the component
  3. Update this README: Add links to new documentation
  4. Include examples: Show practical usage examples
  5. Document edge cases: Explain tricky parts and gotchas

Documentation Standards

  • Python docstrings: Use Google-style docstrings with Args, Returns, Raises, Examples
  • Markdown guides: Include Overview, Architecture, Usage Examples, Troubleshooting
  • Code examples: Should be runnable (or clearly marked as pseudocode)
  • Diagrams: Use ASCII/Unicode diagrams for flow visualization
  • Tables: Use markdown tables for structured comparisons

Questions?

For questions about: