---
title: "TenXTemplate Loader"
description: "import joint JSON schemas files to expand events into well-defined TenXObjects."
source: "https://github.com/log-10x/modules/tree/main/pipelines/run/units/template/unit.yaml"
icon: "material/forest-outline"

---
The 10x Engine employs an optimization model inspired by Chrome V8’s [_intelligent design_](https://v8.dev/docs/hidden-classes#why-have-hidden-classes%3F){target="\_blank"} principle. Rather than treating each log event as a "bag of properties," the 10x Engine assumes only a finite number of object shapes will emerge and that these shapes will follow stereotypical usage `templates`.

The 10x Engine utilizes [symbol library](https://doc.log10x.com/compile/link/#symbol-library) files to assign a shared [TenXTemplate](https://doc.log10x.com/api/js/#TenXTemplate "The TenXEngine class implements an optimization model inspired by Chrome V8's") (i.e., _hidden class_) to input log/trace events with the same [structure](https://doc.log10x.com/run/transform/structure "Structure input events into well-defined TenXObjects"), creating a cached optimized schema for each event type.

Operating on typed TenXObjects enables direct access to [symbol](https://doc.log10x.com/run/transform/structure/#symbols) and [variable](https://doc.log10x.com/run/transform/structure/#variables) values at runtime without repeatedly parsing JSON structures or evaluating complex, brittle regular expressions for each event.

## :material-code-json: Template Files

Template files describes the structure of [TenXTemplates](https://doc.log10x.com/engine/design/#optimization-model) generated during previous execution cycles, similar to a `.proto` file which describes the structure of serialized records.

Each template instance is read as a single line JSON object which contains a `templateHash` and `template` fields into an in-memory map to enable [expanding](https://doc.log10x.com/run/transform/#expand) of previously compact instances read from [inputs](https://doc.log10x.com/run/input/ "Read events into the pipeline from local and remote sources").

For example, a template .json file or data read from an input stream may contain the following template objects:

```json
{"templateHash":"7C9 /a$3Lv","template":"{\"log\":\".:$\\n\",\"stream\":\"stdout\",\"docker\":{\"container_id\":\"$\"},\"kubernetes\":{\"container_name\":\"coredns\",\"namespace_name\":\"kube-system\",\"pod_name\":\"coredns-$-$\",\"container_image\":\"registry.k8s.io//coredns//coredns:v1.$.$\",\"container_image_id\":\"docker-$:////registry.k8s.io//coredns//coredns@sha256:$\",\"pod_id\":\"$-$-$-$$\",\"pod_ip\":\"$.$.$.$\",\"host\":\"minikube\",\"labels\":{\"k8s-app\":\"kube-dns\",\"pod-template-hash\":\"$\"}},\"$_tag\":\"kubernetes.var.log.containers.coredns-$-$_kube-system_coredns-$.log\"}"}
{"templateHash":"-EqO[AdeT!#","template":"{\"log\":\"[INFO] plugin//reload: Running configuration SHA512 = $\\n\",\"stream\":\"stdout\",\"docker\":{\"container_id\":\"$\"},\"kubernetes\":{\"container_name\":\"coredns\",\"namespace_name\":\"kube-system\",\"pod_name\":\"coredns-$-$\",\"container_image\":\"registry.k8s.io//coredns//coredns:v1.$.$\",\"container_image_id\":\"docker-$:////registry.k8s.io//coredns//coredns@sha256:$\",\"pod_id\":\"$-$-$-$$\",\"pod_ip\":\"$.$.$.$\",\"host\":\"minikube\",\"labels\":{\"k8s-app\":\"kube-dns\",\"pod-template-hash\":\"$\"}},\"$_tag\":\"kubernetes.var.log.containers.coredns-$-$_kube-system_coredns-$.log\"}"}
{"templateHash":"-*pAW5IsbiJ","template":"{\"log\":\"[INFO] $.$.$.$:$ - $ \\\"AAAA IN github.com.default.svc.cluster.local. udp $ false $\\\" NXDOMAIN qr,aa,rd $ $7.$\\n\",\"stream\":\"stdout\",\"docker\":{\"container_id\":\"$\"},\"kubernetes\":{\"container_name\":\"coredns\",\"namespace_name\":\"kube-system\",\"pod_name\":\"coredns-$-$\",\"container_image\":\"registry.k8s.io//coredns//coredns:v1.$.$\",\"container_image_id\":\"docker-pullable:////registry.k8s.io//coredns//coredns@sha256:$\",\"pod_id\":\"$-$-$-$$\",\"pod_ip\":\"$.$.$.$\",\"host\":\"minikube\",\"labels\":{\"k8s-app\":\"kube-dns\",\"pod-template-hash\":\"$\"}},\"$_tag\":\"kubernetes.var.log.containers.coredns-$-$_kube-system_coredns-$.log\"}"}
```

The last template in this example whose hash is `-*pAW5IsbiJ` can be used to expand the contents of the following [compact event](https://doc.log10x.com/run/transform/#compact) from an input stream:

```
~-*pAW5IsbiJ,10,244,0,102,45981,64767,77,1232,147,000221854s,4c195cfdbf7e41f640631629970b9af2d8a1f40f63dcffd15edca84e2e2e497e,7db6d8ff4d,pddxj,11,1,1eeb4c7316bacb1d4c8ead65571cd92dd21e27359f0d4917f1a5822a73b75db1,38b91d65,ba47,4d0f,a689,-711056955842,10,244,0,99,7db6d8ff4d,10x,7db6d8ff4d,pddxj,4c195cfdbf7e41f640631629970b9af2d8a1f40f63dcffd15edca84e2e2e497e
```

Given both template and compact event information, the 10x Engine will automatically expand the event to its original full-text form:

```json
{"log":"[INFO] 10.244.0.102:45981 - 64767 \"AAAA IN github.com.default.svc.cluster.local. udp 77 false 1232\" NXDOMAIN qr,aa,rd 147 0.000221854s\n","stream":"stdout","docker":{"container_id":"4c195cfdbf7e41f640631629970b9af2d8a1f40f63dcffd15edca84e2e2e497e"},"kubernetes":{"container_name":"coredns","namespace_name":"kube-system","pod_name":"coredns-7db6d8ff4d-pddxj","container_image":"registry.k8s.io/coredns/coredns:v1.11.1","container_image_id":"docker-pullable://registry.k8s.io/coredns/coredns@sha256:1eeb4c7316bacb1d4c8ead65571cd92dd21e27359f0d4917f1a5822a73b75db1","pod_id":"38b91d65-ba47-4d0f-a689-711056955842","pod_ip":"10.244.0.99","host":"minikube","labels":{"k8s-app":"kube-dns","pod-template-hash":"7db6d8ff4d"}},"tenx_tag":"kubernetes.var.log.containers.coredns-7db6d8ff4d-pddxj_kube-system_coredns-4c195cfdbf7e41f640631629970b9af2d8a1f40f63dcffd15edca84e2e2e497e.log"}
```

At runtime, matching TenXTemplate JSON objects from pipeline [inputs](https://doc.log10x.com/run/input/ "Read events into the pipeline from local and remote sources") are automatically added to the available templates for expanding. This allows compact files and streams to include template definitions followed by their compact instances.

## :material-wrench-outline: Config Files

To configure the TenXTemplate Loader unit, [:material-cog: Edit](https://doc.log10x.com/config/app/#module-config "Learn how to edit app and module configurations") these files.  

Below is the default configuration from: [template/config.yaml](https://github.dev/log-10x/config/blob/main/pipelines/run/template/config.yaml "template/config.yaml"){target="\_blank"}.  
  
<div class="edit-options">
    <a class="md-button tenx-edit-online-button" data-tooltip="Edit online on github.dev" href="https://github.dev/log-10x/config/blob/main/pipelines/run/template/config.yaml" target="_blank" rel="noopener noreferrer">
        <span class="twemoji" style="margin-right: 0.3rem;">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                <path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path>
            </svg>
        </span> Edit Online
    </a>
    <button class="md-button tenx-config.yaml0-edit-button" data-tooltip="Edit configuration file" data-dialog-id="config-yaml0-dialog">
        <span style="margin-right: 0.3rem;">
            <span class="twemoji">
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                    <path d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z"></path>
                </svg>
            </span>
        </span>Edit Locally
    </button>
</div>

<dialog id="config-yaml0-dialog" class="md-dialog md-dialog--editor">
    <div class="editor-dialog-wrapper">
        <div class="editor-dialog-header">
            <span class="editor-dialog-title">Edit config.yaml Locally</span>
            <div class="editor-header-actions">
                <button class="editor-toolbar-btn yaml-editor-locations" data-tooltip="Save">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M5 20h14v-2H5v2m14-9h-4V3H9v8H5l7 7 7-7Z"></path></svg>
                </button>
                <button class="editor-toolbar-btn yaml-editor-reset" data-tooltip="Reset to default">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"></path></svg>
                </button>
                <button class="editor-toolbar-btn yaml-editor-copy" data-tooltip="Copy to clipboard">
                    <svg class="icon-copy" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M19 21H8V7h11m0-2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m-3-4H4a2 2 0 0 0-2 2v14h2V3h12V1Z"></path></svg>
                    <svg class="icon-check" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="display:none;"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg>
                </button>
                <span class="header-divider"></span>
                <button class="editor-toolbar-btn yaml-editor-fullscreen" data-tooltip="Fullscreen">
                    <svg class="icon-maximize" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M5,5H10V7H7V10H5V5M14,5H19V10H17V7H14V5M17,14H19V19H14V17H17V14M10,17V19H5V14H7V17H10Z"></path></svg>
                    <svg class="icon-minimize" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="display:none;"><path fill="currentColor" d="M5,16H8V19H10V14H5V16M14,14V19H16V16H19V14H14M16,5V8H19V10H14V5H16M10,5V10H5V8H8V5H10Z"></path></svg>
                </button>
                <span class="header-divider"></span>
                <button class="editor-toolbar-btn editor-dialog-close" onclick="closeDialog('config-yaml0-dialog')" data-tooltip="Close">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg>
                </button>
            </div>
        </div>
        <div class="editor-dialog-content">
            <div class="yaml-editor-container"></div>
        </div>
        <div class="yaml-editor-statusbar">
            <span class="yaml-editor-status"></span>
        </div>
    </div>
    <!-- Locations Popup -->
    <div class="locations-popup" style="display: none;">
        <div class="locations-popup-content">
            <div class="locations-popup-header">
                <span class="locations-header-label">Download and save to:</span>
                <button class="locations-popup-close" aria-label="Close">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
                        <path fill="currentColor" d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path>
                    </svg>
                </button>
            </div>
            <ul class="locations-list">
                <li>
                    <span class="location-label">Linux / Docker / macOS
                        <span class="help-icon" data-tooltip="Default system location. The engine automatically reads configs from here at startup. Best for production deployments.">
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12"><path fill="currentColor" d="M11 18h2v-2h-2v2m1-16A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14a4 4 0 0 0-4 4h2a2 2 0 0 1 2-2 2 2 0 0 1 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5a4 4 0 0 0-4-4Z"/></svg>
                        </span>
                    </span>
                    <div class="location-path-row">
                        <code class="default-path location-path" data-tooltip=""
                            data-copy-osx="/etc/log10x/config/run/template/config.yaml"
                            data-copy-nix="/etc/log10x/config/run/template/config.yaml"
                            data-copy-win="C:\log10x\configs/run/template/config.yaml"></code>
                        <button class="copy-btn" data-tooltip="Copy path">
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14">
                                <path fill="currentColor" d="M19 21H8V7h11m0-2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m-3-4H4a2 2 0 0 0-2 2v14h2V3h12V1Z"></path>
                            </svg>
                        </button>
                    </div>
                </li>
                <li>
                    <span class="location-label">Custom directory
                        <span class="help-icon" data-tooltip="Set TENX_CONFIG environment variable to point to a custom config directory. Useful when you want configs in a non-standard location.">
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12"><path fill="currentColor" d="M11 18h2v-2h-2v2m1-16A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14a4 4 0 0 0-4 4h2a2 2 0 0 1 2-2 2 2 0 0 1 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5a4 4 0 0 0-4-4Z"/></svg>
                        </span>
                    </span>
                    <div class="location-path-row">
                        <code class="location-path" data-tooltip="$TENX_CONFIG/run/template/config.yaml">$TENX_CONFIG/run/template/config.yaml</code>
                        <button class="copy-btn" data-tooltip="Copy path">
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14">
                                <path fill="currentColor" d="M19 21H8V7h11m0-2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m-3-4H4a2 2 0 0 0-2 2v14h2V3h12V1Z"></path>
                            </svg>
                        </button>
                    </div>
                </li>
                <li>
                    <span class="location-label">Within cloned repo
                        <span class="help-icon" data-tooltip="First run: git clone github.com/log-10x/config. Then save the file to this path within the cloned folder. Use for version control.">
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="12" height="12"><path fill="currentColor" d="M11 18h2v-2h-2v2m1-16A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m0-14a4 4 0 0 0-4 4h2a2 2 0 0 1 2-2 2 2 0 0 1 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5a4 4 0 0 0-4-4Z"/></svg>
                        </span>
                    </span>
                    <div class="location-path-row">
                        <code class="location-path" data-tooltip="./pipelines/run/template/config.yaml">./pipelines/run/template/config.yaml</code>
                        <button class="copy-btn" data-tooltip="Copy path">
                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14">
                                <path fill="currentColor" d="M19 21H8V7h11m0-2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m-3-4H4a2 2 0 0 0-2 2v14h2V3h12V1Z"></path>
                            </svg>
                        </button>
                    </div>
                </li>
            </ul>
            <div class="locations-popup-footer">
                <button class="locations-download-btn" title="Download config file">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14">
                        <path fill="currentColor" d="M5 20h14v-2H5v2m14-9h-4V3H9v8H5l7 7 7-7Z"></path>
                    </svg>
                    <span>Download</span>
                </button>
            </div>
        </div>
    </div>
</dialog>

<template class="tenx-config-schema" data-encoding="base64">ewogICJ0eXBlIiA6ICJvYmplY3QiLAogICJwcm9wZXJ0aWVzIiA6IHsKICAgICJ0ZW54IiA6IHsKICAgICAgInR5cGUiIDogInN0cmluZyIKICAgIH0sCiAgICAidGVtcGxhdGUiIDogewogICAgICAidHlwZSIgOiAib2JqZWN0IiwKICAgICAgImFkZGl0aW9uYWxQcm9wZXJ0aWVzIiA6IGZhbHNlLAogICAgICAicHJvcGVydGllcyIgOiB7CiAgICAgICAgImZpbGVzIiA6IHsKICAgICAgICAgICJ0eXBlIiA6IFsKICAgICAgICAgICAgImFycmF5IiwKICAgICAgICAgICAgInN0cmluZyIsCiAgICAgICAgICAgICJudWxsIgogICAgICAgICAgXSwKICAgICAgICAgICJtYXJrZG93bkRlc2NyaXB0aW9uIiA6ICJJbnB1dCBmaWxlcyBvciBnbG9iIHBhdHRlcm5zIGNvbnRhaW5pbmcgSlNPTi1lbmNvZGVkIFRlblhUZW1wbGF0ZXNcblxuSW5wdXQgZmlsZXMgb3IgZ2xvYiBwYXR0ZXJucyBmcm9tIHdoaWNoIHRvIGxvYWQgSlNPTi1lbmNvZGVkIFRlblhUZW1wbGF0ZXMuIChEZWZhdWx0OiBbXCJwYXRoKFxcXCJkYXRhL3NhbXBsZS90ZW1wbGF0ZXMvKi5qc29uXFxcIilcIl0pIiwKICAgICAgICAgICJpdGVtcyIgOiB7CiAgICAgICAgICAgICJ0eXBlIiA6ICJzdHJpbmciCiAgICAgICAgICB9LAogICAgICAgICAgImRlZmF1bHQiIDogWwogICAgICAgICAgICAicGF0aChcImRhdGEvc2FtcGxlL3RlbXBsYXRlcy8qLmpzb25cIikiCiAgICAgICAgICBdCiAgICAgICAgfSwKICAgICAgICAiY2FjaGVTaXplIiA6IHsKICAgICAgICAgICJ0eXBlIiA6IFsKICAgICAgICAgICAgIm51bWJlciIsCiAgICAgICAgICAgICJzdHJpbmciLAogICAgICAgICAgICAibnVsbCIKICAgICAgICAgIF0sCiAgICAgICAgICAibWFya2Rvd25EZXNjcmlwdGlvbiIgOiAiTWF4aW11bSB0b3RhbCBieXRlIHNpemUgb2YgaW4tbWVtb3J5IGNhY2hlZCB0ZW1wbGF0ZXNcblxuQ29udHJvbHMgdGhlIG1heGltdW0gdG90YWwgYnl0ZSBzaXplIG9mIHRlbXBsYXR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0YW1wIiA6IHsKICAgICAgInR5cGUiIDogIm9iamVjdCIsCiAgICAgICJhZGRpdGlvbmFsUHJvcGVydGllcyIgOiBmYWxzZSwKICAgICAgInByb3BlcnRpZXMiIDogewogICAgICAgICJwcmVmaXgiIDogewogICAgICAgICAgInR5cGUiIDogWwogICAgICAgICAgICAic3RyaW5nIiwKICAgICAgICAgICAgIm51bGwiCiAgICAgICAgICBdLAogICAgICAgICAgIm1hcmtkb3duRGVzY3JpcHRpb24iIDogIlRlbXBsYXRlIHRpbWVzdGFtcCBwcmVmaXhcblxuU3BlY2lmaWVzIGEgcHJlZml4IGZvciBhbiBUZW5YVGVtcGxhdGUncyBzZXQgb2YgdmFyaWFibGUgYW5kIHN5bWJvbCB0b2tlbnMgZGVzY3JpYmluZyBhIHRpbWVzdGFtcCAoZS5nLiwgJHtERC9NTS9ZWSBISC1tbS1zc30pLiAoRGVmYXVsdDogKCkiLAogICAgICAgICAgImRlZmF1bHQiIDogIigiCiAgICAgICAgfSwKICAgICAgICAicG9zdGZpeCIgOiB7CiAgICAgICAgICAidHlwZSIgOiBbCiAgICAgICAgICAgICJzdHJpbmciLAogICAgICAgICAgICAibnVsbCIKICAgICAgICAgIF0sCiAgICAgICAgICAibWFya2Rvd25EZXNjcmlwdGlvbiIgOiAiVGVtcGxhdGUgdGltZXN0YW1wIHBvc3RmaXhcblxuU3BlY2lmaWVzIGEgdmFsdWUgYXBwZW5kZWQgdG8gYW4gVGVuWFRlbXBsYXRlJ3MgYW5kIHNldCBvZiB2YXJpYWJsZSBhbmQgc3ltYm9sIHRva2VucyBkZXNjcmliaW5nIGEgdGltZXN0YW1wIChlLmcuLCAke0REL01NL1lZIEhILW1tLXNzfSkuIChEZWZhdWx0OiApKSIsCiAgICAgICAgICAiZGVmYXVsdCIgOiAiKSIKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9LAogICJhZGRpdGlvbmFsUHJvcGVydGllcyIgOiBmYWxzZQp9</template>

```yaml
# 🔟❎ 'run' template file configuration

# Load TenXTemplates .json files that define the structure/schema of TenXObjects.
# To learn more see https://doc.log10x.com/run/template/

# Set the 10x pipeline to 'run'
tenx: run

# =============================== Template ===================================

template:
  # 'files' specifies GLOB pattern for finding JSON-encoded TenXTemplates.
  files:
    - $=path("data/templates/*.json")
    - $=path("data/sample/output/*.json")

  # 'cacheSize' controls the maximum total byte size of templates held
  #  in the in-memory cache vs. on disk. Set to 0 to disable pruning.
  cacheSize: $=parseBytes("10MB")

# =============================== Variable ===================================

var:
  # 'placeholder' specifies a character to use when encoding a TenXTemplate
  #  to signify the location of a runtime variable value.
  placeholder: "$"

  # 'maxRecurIndexes' controls the maximum number of variable values to reuse.
  maxRecurIndexes: 10

# =============================== Timestamp ==================================

timestamp:
  # 'prefix' specifies a prefix for a TenXTemplate's timestamp tokens.
  prefix: (

  # 'postfix' specifies a postfix for a TenXTemplate's timestamp tokens.
  postfix: )
```

## :material-menu: Options

Specify the options below to [configure](/config "configure") the TenXTemplate Loader:

|Name|Description|Category|
|---|---|---|
|[templateFiles](#templatefiles "input files or glob patterns containing JSON-encoded TenXTemplates")|Input files or glob patterns containing JSON-encoded TenXTemplates|Load|
|[varPlaceholder](#varplaceholder "placeholder character for notating TenXObject instance variables")|Placeholder character for notating TenXObject instance variables|Parse|
|[timestampPrefix](#timestampprefix "template timestamp prefix")|Template timestamp prefix|Parse|
|[timestampPostfix](#timestamppostfix "template timestamp postfix")|Template timestamp postfix|Parse|
|[varMaxRecurIndexes](#varmaxrecurindexes "maximum number of template reusable variable value")|Maximum number of template reusable variable value|Parse|
|[templateCacheSize](#templatecachesize "maximum total byte size of in-memory cached templates")|Maximum total byte size of in-memory cached templates|Advanced|

### Load

#### :material-menu-right-outline:**`templateFiles`**

Input files or glob patterns containing JSON-encoded TenXTemplates.

|Type|Default|Category|
|---|---|---|
|List|\[path("data/sample/templates/\*.json")\]|Load|

Input files or glob patterns from which to load JSON-encoded TenXTemplates.


### Parse

#### :material-menu-right-outline:**`varPlaceholder`**

Placeholder character for notating TenXObject instance variables.

|Type|Default|Category|
|---|---|---|
|String|$|Parse|

Specifies a character to use when encoding an TenXTemplate to signify the location of a
runtime variable value.

For example, for an TenXTemplate containing the following segment:
'ERROR: could not connect to host IP: $.$.$.$'

The '$' entries designate that any TenXObject associated with this template
will substitute the '$' slots with matching values from its individual [vars](https://doc.log10x.com/api/js/#TenXBaseObject+vars "An array of  variable sequences extracted from the object's text.") array (e.g. 0,0,0,127).


#### :material-menu-right-outline:**`timestampPrefix`**

Template timestamp prefix.

|Type|Default|Category|
|---|---|---|
|String|(|Parse|

Specifies a prefix for an TenXTemplate's set of variable and symbol tokens describing
a timestamp (e.g., ${DD/MM/YY HH-mm-ss}).


#### :material-menu-right-outline:**`timestampPostfix`**

Template timestamp postfix.

|Type|Default|Category|
|---|---|---|
|String|)|Parse|

Specifies a value appended to an TenXTemplate's and set of variable and symbol tokens
describing a timestamp (e.g., ${DD/MM/YY HH-mm-ss}).


#### :material-menu-right-outline:**`varMaxRecurIndexes`**

Maximum number of template reusable variable value.

|Type|Default|Category|
|---|---|---|
|Number|10|Parse|

Controls the maximum number of variable values to reuse when
encoding an TenXObject's [vars](https://doc.log10x.com/api/js/#TenXBaseObject+vars "An array of  variable sequences extracted from the object's text.") array to stream. When generating a new
TenXTemplate for an TenXObject instance whose variables contain repetitive values,
the template may indicate that a value is a repetition of a previous variable value and
does not need to be encoded again.

For example, for an TenXObject whose [text](https://doc.log10x.com/api/js/#TenXBaseObject+text "The content of the event from which this instance was structured.") field contains the following segment:
`userID=45dfgdfs4,parentID=45dfgdfs4`, the resulting TenXTemplate can be encoded
as: `userID=$,parentID=$1` specifying that the value of the `parentID` variable
can be found one slot behind in the TenXObject's [vars array](https://doc.log10x.com/api/js/#TenXBaseObject+vars "An array of  variable sequences extracted from the object's text."), saving
the need to encode this value multiple times.


### Advanced

#### :material-menu-right-outline:**`templateCacheSize`**

Maximum total byte size of in-memory cached templates.

|Type|Default|Category|
|---|---|---|
|Number|20971520|Advanced|

Controls the maximum total byte size of templates held in the in-memory cache.
When the cache exceeds this limit, least recently used templates are pruned to a
temporary file on disk. Pruned templates are automatically reloaded from disk when
accessed again.

Set to 0 to disable pruning and keep all templates in memory.


<br/>:material-github: This unit is defined in [template/unit.yaml](https://github.com/log-10x/modules/tree/main/pipelines/run/units/template/unit.yaml "template/unit.yaml"){target="\_blank"}.

