Event Timeout for Seq v1.5.6 - Optional Handlebars templates

I've previously said that I really like Handlebars implementations in other Seq apps, and I felt that there were opportunities to incorporate these into apps like Event Timeout.  One of the things to be cautious of here, though, is that we might already be passing a Handlebars template as part of the Message or Description, for use in a downstream app.

So in adding this as a feature, the first consideration was that Handlebars has to be optional, to allow templates to be passed through to other Seq apps such as Jira or Opsgenie. 

The second consideration - we don't have opportunity to pass properties from log events in Event Timeout, because we're creating logs based on timeouts - log events that didn't happen. Any properties that will be used for Event Timeout need to relate to the counters and properties that we have available. 

Note - Current builds of Seq have a bug with the Nuget v2 API affecting update of Event Timeout. The workaround is to either manually update Event Timeout to the current build via the Manage page for the app, or change your Nuget feed settings.

I've accordingly created a selection of Handlebars values that can be used. These are shown in the  below code extract:

            var payload = (IDictionary<string, object>)ToDynamic(new Dictionary<string, object>
            {
                { "AppName", config.AppName },
                { "TimeNow", DateTime.Now.ToLongTimeString() },
                { "DateNowLong", DateTime.Now.ToLongDateString() },
                { "DateNowShort", DateTime.Now.ToShortDateString() },
                { "DateTimeNow", DateTime.Now.ToString("F") },
                { "StartTime", counters.StartTime.ToString("F") },
                { "EndTime", counters.StartTime.ToString("F") },
                { "Timeout", config.TimeOut.TotalSeconds },
                { "TimeoutMins", config.TimeOut.TotalMinutes.ToString("N2") },
                { "TimeoutHours", config.TimeOut.TotalHours.ToString("N2") },
                { "RepeatTimeout", config.RepeatTimeout },
                { "SuppressTime", config.SuppressionTime.TotalSeconds },
                { "SuppressTimeMins", config.SuppressionTime.TotalMinutes.ToString("N2") },
                { "SuppressTimeHours", config.SuppressionTime.TotalHours.ToString("N2") },
                { "RepeatSuppressTime", config.SuppressionTime.TotalSeconds },
                { "RepeatSuppressTimeMins", config.RepeatTimeoutSuppress.TotalMinutes.ToString("N2") },
                { "RepeatSuppressTimeHours", config.RepeatTimeoutSuppress.TotalHours.ToString("N2") },
                { "Tags", string.Join(",", config.Tags) },
                { "Responders", config.Responders ?? "" },
                { "Priority", config.Priority ?? "" },
                { "ProjectKey", config.ProjectKey ?? "" },
                { "DueDate", config.DueDate ?? "" },
                { "InitialTimeEstimate", config.InitialTimeEstimate ?? "" },
                { "RemainingTimeEstimate", config.RemainingTimeEstimate ?? "" }
            });

Arguably there may be other counters that are useful, but these stood out as the most likely to be used.

To implement this, you would enable the new "Use Handlebars" setting, and configure the Log Message and/or Description using Handlebars expressions, eg.

{{AppName}} error after {{Timeout}} secs or {{TimeoutMins}} mins or {{TimeoutHours}} hours - Woe is me, this was meant to be sorted out by {dd-MM-yyyy-10M}

You can see that the Handlebars expressions are drawn from the above list. You can also make use of inbuilt helpers to make this funkier (such as excluding empty properties).  And the result is great!

Handlebars timeout log event

It's also worth noting that we still retain the date expressions and tokens that were recently added to Event Timeout via Lurgle.Dates. This allows you to use the .NET custom date strings, with optional add/subtract modifiers, along with the simple date tokens that return parts of a date.  The previous examples shown for these were:

  • {d M y+10d} - Add 10 days, with an example output 1 1 21.
  • {dd MM yy+10m} - Add 10 months, with an example output 01 11 21.
  • {dd MMM yyy+10y} - Add 10 years, with an example output 01 Jan 2021.
  • {MMMM yyyy-1m} - Subtract 1 month, with an example output December 2020.
  • {ddd dd MMM yyyy} - Sun 01 Aug 2021

And for simple date expressions:

  • {d} {MMM} {yyyy} - 3 Aug 2021
  • {d-1} {MMM} {yyyy} - 2 Aug 2021

With the note, as always, that simple date tokens aren't great for calculating whole dates with addition/subtraction - they're more useful for scenarios like {MMMM-1} to simply state last month's name.

I plan to roll this enhancement into Event Threshold and Event Schedule as well, which will enable them to similarly use properties related to threshold violations or schedule logs.

Seq.App.EventTimeout
Event Timeout for Seq Latest Version

Event Timeout for Seq Total Downloads

Event Timeout for Seq License

Comments

You may also like:

Event Timeout - A super powered event monitoring app for Seq

"Something hasn't happened!" My workplace has quite a number of disparate applications and scripts that drive critical SLAs. Historically, these were managed by exception and emailing errors to various mailboxes. This is a fairly poor approach to managing SLAs, since it is reliant on a human factor - someone has...

Event Timeout for Seq v1.4.2 released

A new release of Seq.App.EventTimeout is out. This was a little earlier than I planned to release v1.4.x, but there was a bug in the AbstractAPI deserialization as a result of some code refactoring which I'd missed. As usual, you can install Event Timeout for Seq using Seq.App.EventTimeout as the...

Calculating timeouts with Event Timeout for Seq

We use quite a number of Event Timeout instances in our Seq environment, to detect processes that have not completed in time. The nature of the Seq.App.EventTimeout implementation is one that relies on a timeout in seconds, and this can result in keeping track of quite a few different calculations....