Skip to content

Special chars keys with mustache templates #58

@jstoja

Description

@jstoja
  • Version: 6.2.2
  • Operating System: any
  • Config File (if you have sensitive info, please remove it):
    output_mail.conf
output {
  if "shouldmail" in [tags] {
    email {
      to => 'technical@example.com'
      from => 'monitor@example.com'
      subject => 'Alert - %{title}'
      template_file => "/tmp/email_template.mustache"
      domain => 'mail.example.com'
      port => 25
    }
  }
}

email_template.mustache

<p>{{ [@meta][_type] }}</p>
<p>{{ [log][level] }}</p>
  • Sample Data:

hash of the event:

{
  "@meta: { "_type": "beats" },
  "log": { "level": 3 },
  "message": "Hello world!",
}

If we take this example, it's not possible to use the keys having special characters in the mustache template. This is annoying because it means we have to move/duplicate the meta keys/hash (for example), and re-delete them after.

The solution I propose would be to have a basic conversion of these, for example removing the brackets and special symbols, transforming @meta to meta for example.

In addition, mustache allows for dot notation to traverse hashes (for example log.level, which is nice). So it could help to traverse meta._type (I'm not sure about _ though).
Do you have any idea on this?

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions