For the complete documentation index, see llms.txt. This page is also available as Markdown.

Templating

Templating Language

We use Jinja templating to construct dynamic queries, allowing flexible adjustments tailored to your data model.

Jinja allows:

  • Loops (for) → Automate query generation for multiple signals.

  • Conditions (if) → Add optional calculations dynamically.

For example, for retrieving cursor stats in ADX, we could use the following query:

{% for name, series in time_series -%}
{{series}}
| summarize
    min = min(toreal(value)),
    max = max(toreal(value)),
    mean = avg(toreal(value))
{% if extended %},
    median = percentile(toreal(value), 50),
    std = stdev(toreal(value))
{% endif %}
| extend name = '{{ name }}';

Template Constants

Marple allows you to substitute variables in query templates using Jinja syntax.

These variables fall into three categories: constants, dataset filters, and query-specific variables.

  • Constants are predefined values that can be referenced in queries as {{CONSTANT_NAME}}. You can define these constants within the configuration.

  • Dataset filters are determined by the filter signals in your dataset definition. For example, if session is part of the filter list, it can be used in queries as {{dataset.session}}.

  • Query-specific variables are defined per query and vary based on its purpose. For instance, a time series query might use {{timestamp_start}} and {{timestamp_stop}} to define the time range.

This approach ensures dynamic and flexible queries that adapt to different datasets while maintaining clarity and efficiency.

Last updated

Was this helpful?