Most of my Graylog notifications just use the default template, which includes:
$${if backlog}Last messages accounting for this alert:
$${foreach backlog message}$${message}
$${end}$${else}
<No backlog>
${end}
I’d like to add a few other variables at the top of the email, for example:
Message received at: $timestamp
Source of alert: $source
Full text: $message
Why doesn’t this work? How come only $message is valid but $source and $timestamp don’t work? When I look at a log entry in Graylog these messages have all three, plus I use extractors and have tons of other variables I’d like to eventually use in these emails… so how do I reference them?
$${if backlog}Last messages accounting for this alert:
$${foreach backlog message}
Message received at: $${$message.timestamp}
Source of alert: $${$message.source}
Full text: $${$message}
$${end}$${else}
<No backlog>
${end}
Now I can reference a few of those fields, such as source, like this:
${message.source}
But when I try to reference the other fields that are listed there, such as:
${message.fw_proto}
I get an error from Graylog: “java.lang.NoSuchFieldException: fw_proto”… Note this field was created by an extractor…
I have tried all kinds of ways to reference these extracted fields such as using double $$ and $${$ like in your message but have not had any luck. Can you confirm the exact format I need?
The message.fields fields can be useful to get access to arbitrary fields that are defined in the message. For example message.fields.full_message would return the full_message of a GELF message.
message.fields works and confirms which fields I have: see above. It confirms one of my fields is called “fw_proto”, another is called “fw_scrip”, etc. These fields are created by one of my extractors.
However, I cannot reference these fields in my alerts, no matter how I format it, I have tried:
etc… None of these formats work, so I am looking for clarification. Note, these two do work:
{message.timestamp}
{message.source}
Therefore you would think that $${message.fw_proto} or $${message.fw_srcip} would work, but it doesn’t. Do you know why? Any suggestions what else I can try?
edit: note the forums are removing some of the $ signs