Skip to content

[Bug]: An error occurs when a field in victorialogs contains the character / #41

Description

@congto

What happened?

Hi @fxthiry

My system uses Victorialogs and vectors to receive log forwarding from OpenShift.

I used vectors to extract information fields from the raw OpenShift message. After extraction, Victorialogs now has fields containing the / character.

ocp.annotations.authentication.openshift.io/username: allow
ocp.annotations.authentication.openshift.io/decision: congtt2

My system uses Victorialogs, specifically Vector, to receive log forwarding from OpenShift.

I used Vector to extract information fields from the raw OpenShift message. After extraction, Victorialogs displays fields containing the / character.

When I created the rule /etc/valerter/templates.d/template_ocp_login.yaml for Valerter to handle, I declared it as follows.

#Template log ocp /etc/valerter/templates.d/template_ocp_login.yaml
template_login_ocp:
  title: "{{ rule_name | upper }} - trên {{ host }} từ nguồn {{vl_source}}"
  body: |
    <b>Alert Name</b>: <code>{{ rule_name }}</code>
    <b>OCP User</b>: <code>{{ ocp.annotations.authentication.openshift.io/username }}</code>
    <b>OCP Login Action</b>: <code>{{ ocp.annotations.authentication.openshift.io/decision }}</code>
    <b>OCP Host</b>: <code>{{ hostname }}</code>
    <b>OCP Cluster</b>: <code>{{ appname }}</code>
    <b>OCP UserAgent</b>: <code>{{ ocp.userAgent }}</code>
    <b>Description</b>: User <code>{{ ocp.annotations.authentication.openshift.io/username }}</code> đã login vào <code>{{ hostname }}</code> với trạng thái <code>{{ ocp.annotations.authentication.openshift.io/decision }}</code>.
  email_body_html: |
    <p style="font-weight: 600;">Log Overview</p>
    <pre>
    Alert Name            : {{ rule_name }}
    OCP User              : {{ ocp.annotations.authentication.openshift.io/username }}
    OCP Login Action      : {{ ocp.annotations.authentication.openshift.io/decision }}
    OCP Host              : {{ hostname}}
    OCP Cluster           : {{ appname }}
    OCP UserAgent         : {{  ocp.userAgent }}
    Description           : User <code> {{ ocp.annotations.authentication.openshift.io/username }}</code> đã login vào <code>{{ hostname }}</code> với trạng thái <code>{{ ocp.annotations.authentication.openshift.io/decision }}</code>
    </pre>
    <p style="font-weight: 600;">Log excerpt</p>
    <pre style="background: #1f2937; color: #f9fafb; padding: 12px; border-radius: 4px; overflow-x: auto;">{{ _msg }}</pre>
  accent_color: "#dc3545"

Then, when I used the command valerter --validate, I received a message with a forward slash (/).

root@vmalert-authentik-50-24:/etc/valerter/templates.d# valerter --validate
2026-05-04T04:25:57.593399Z  INFO valerter: Loading configuration config_path=/etc/valerter/config.yaml
2026-05-04T04:25:57.595306Z  INFO valerter: Validating configuration
2026-05-04T04:25:57.601893Z ERROR valerter: Configuration validation error error=invalid template in rule 'template:template_login_ocp': body render: invalid operation: tried to use / operator on unsupported types sequence and sequence (in _render_test:2)
2026-05-04T04:25:57.601943Z ERROR valerter: Configuration validation error error=invalid template in rule 'template:template_login_ocp': email_body_html render: invalid operation: tried to use / operator on unsupported types sequence and sequence (in _render_test:4)
2026-05-04T04:25:57.601954Z ERROR valerter: Configuration validation failed error_count=2

To avoid the "/" character, I used the vector's functionality to transform the fields containing the "/" character, and Valerter worked well.

However, if Valerter could handle the "/" character as well, it would save the extra step of transforming from the vector.

If possible, please consider improving the capabilities of the valet.

What did you expect?

We want Valuer to support fields containing the forward slash character (/)

Affected component

Configuration loading / validation

Valerter version

v2.0.0

VictoriaLogs version

v.149.0

Platform

Ubuntu 24.04

Relevant configuration (redact secrets!)

#Template log ocp /etc/valerter/templates.d/template_ocp_login.yaml
template_login_ocp:
  title: "{{ rule_name | upper }} - trên {{ host }} từ nguồn {{vl_source}}"
  body: |
    <b>Alert Name</b>: <code>{{ rule_name }}</code>
    <b>OCP User</b>: <code>{{ ocp.annotations.authentication.openshift.io/username }}</code>
    <b>OCP Login Action</b>: <code>{{ ocp.annotations.authentication.openshift.io/decision }}</code>
    <b>OCP Host</b>: <code>{{ hostname }}</code>
    <b>OCP Cluster</b>: <code>{{ appname }}</code>
    <b>OCP UserAgent</b>: <code>{{ ocp.userAgent }}</code>
    <b>Description</b>: User <code>{{ ocp.annotations.authentication.openshift.io/username }}</code> đã login vào <code>{{ hostname }}</code> với trạng thái <code>{{ ocp.annotations.authentication.openshift.io/decision }}</code>.
  email_body_html: |
    <p style="font-weight: 600;">Log Overview</p>
    <pre>
    Alert Name            : {{ rule_name }}
    OCP User              : {{ ocp.annotations.authentication.openshift.io/username }}
    OCP Login Action      : {{ ocp.annotations.authentication.openshift.io/decision }}
    OCP Host              : {{ hostname}}
    OCP Cluster           : {{ appname }}
    OCP UserAgent         : {{  ocp.userAgent }}
    Description           : User <code> {{ ocp.annotations.authentication.openshift.io/username }}</code> đã login vào <code>{{ hostname }}</code> với trạng thái <code>{{ ocp.annotations.authentication.openshift.io/decision }}</code>
    </pre>
    <p style="font-weight: 600;">Log excerpt</p>
    <pre style="background: #1f2937; color: #f9fafb; padding: 12px; border-radius: 4px; overflow-x: auto;">{{ _msg }}</pre>
  accent_color: "#dc3545"

Logs

root@vmalert-authentik-50-24:/etc/valerter/templates.d# valerter --validate
2026-05-04T04:25:57.593399Z  INFO valerter: Loading configuration config_path=/etc/valerter/config.yaml
2026-05-04T04:25:57.595306Z  INFO valerter: Validating configuration
2026-05-04T04:25:57.601893Z ERROR valerter: Configuration validation error error=invalid template in rule 'template:template_login_ocp': body render: invalid operation: tried to use / operator on unsupported types sequence and sequence (in _render_test:2)
2026-05-04T04:25:57.601943Z ERROR valerter: Configuration validation error error=invalid template in rule 'template:template_login_ocp': email_body_html render: invalid operation: tried to use / operator on unsupported types sequence and sequence (in _render_test:4)
2026-05-04T04:25:57.601954Z ERROR valerter: Configuration validation failed error_count=2

Steps to reproduce

  1. Create file rule
  2. Run valerter --validate

Pre-checks

  • I ran valerter --validate -c config.yaml and it passed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions