Valerter

Email Body Templates

Valerter email notifications use Jinja2 templates (via minijinja) to customize the email body content.

Default Behavior

By default, emails use a built-in template (default-email.html.j2) that provides a clean, responsive design with color-coded headers and professional styling.

Custom Templates

You can provide your own template via:

Option Description
body_template Inline Jinja2 template string
body_template_file Path to template file (relative to config dir or absolute)

Priority: body_template_file > body_template > default template

Available Variables

Variable Type Description
title string Alert title (from message template)
body string Alert body (from message template)
rule_name string Name of the rule that triggered
accent_color string | null Accent color from template (e.g., #ff0000)
log_timestamp string Original log timestamp in ISO 8601 format (for VictoriaLogs search)
log_timestamp_formatted string Human-readable timestamp (respects timestamp_timezone setting)

Jinja2 Syntax

Common patterns:

{# Variable output #}


{# With default value #}


{# Filters #}



{# Conditionals #}


{# Comments (not rendered) #}
{# This is a comment #}

Examples

Minimal Config (uses default template)

notifiers:
  email-ops:
    type: email
    smtp:
      host: smtp.example.com
      port: 587
    from: "valerter@example.com"
    to:
      - "ops@example.com"
    subject_template: "[] "

Custom Template File

notifiers:
  email-custom:
    type: email
    smtp:
      host: smtp.example.com
      port: 587
    from: "valerter@example.com"
    to:
      - "ops@example.com"
    subject_template: "[] "
    body_template_file: "templates/my-alert.html.j2"

Inline Template

notifiers:
  email-inline:
    type: email
    smtp:
      host: smtp.example.com
      port: 587
    from: "valerter@example.com"
    to:
      - "ops@example.com"
    subject_template: "Alert: "
    body_template: |
      <html>
        <body>
          <h1 style="color: "></h1>
          <p></p>
          <hr>
          <small>Rule: </small>
        </body>
      </html>

Writing Templates

Basic Structure

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <div style="padding: 20px; border-left: 4px solid ;">
        <h1></h1>
        <p></p>
        <small>
            Rule: <code></code><br>
            Log time: 
        </small>
    </div>
</body>
</html>

Tips

  1. Use inline CSS - Many email clients don’t support <style> blocks well
  2. Use tables for layout - Flexbox/Grid support is limited in email clients
  3. Test across clients - Gmail, Outlook, Apple Mail render differently
  4. Keep it simple - Complex layouts often break

File Naming

We recommend .html.j2 extension (e.g., my-alert.html.j2), but any extension works.

Security

HTML auto-escaping is enabled - All variables are automatically escaped to prevent XSS attacks from malicious log data.

For example, <script>alert('xss')</script> in a log becomes:

&lt;script&gt;alert('xss')&lt;/script&gt;