New Alerts Templates syntax (1.41)

Hi All,

Kindly help to convert my old Alert template to the new format.
Thanks

{if %transport == slack}
{if %state == 1}ALERT:{else}RECOVERED:{/if}
Rule: {if %name}%name{else}%rule{/if}
Hostname: %sysName
Hardware: %hardware
Duration: %elapsed
{if %faults}
Interfaces: {foreach %faults} #%key: %value.ifDescr - %value.ifAlias {/foreach}
Location: {foreach %faults} #%key: %value.location {/foreach}
{/if}
{else}
{if %state == 1}ALERT:{else}RECOVERED:{/if}
Rule: {if %name}%name{else}%rule{/if}

Hostname: %sysName

Hardware: %hardware

Duration: %elapsed

{if %faults}
Interfaces::
{foreach %faults} #%key: %value.ifDescr - %value.ifAlias
{/foreach}
Location::
{foreach %faults} #%key: %value.location
{/foreach}
{/if}
{/if}

Did you look over the new doc? https://docs.librenms.org/#Alerting/Templates/

  • there is a convert template button on the templates page to do this for you. It might not be 100% but it will get you close.

ops, sorry, missed the convert button.
Will play with it, thanks!

Thanks for pointing to the converter, it did the job, in my case even for 100%.

The only question remains is how to make “new line” in the new code, no luck with that so far.

I addition, it would be great to add picture to each example from https://docs.librenms.org/#Alerting/Templates/

If you send plain text emails then just pressing enter will create a new line. If it’s html emails then <br />

Thanks mate for the help.

Yet another small issue, since some daily update I see that in alerts it started to send Priority / Severity although it is not configured in the Alert template.

It comes the last one.
Would you be able to check that plz?

And of course, KUDOS for the transports update!!! Great thing!
Would love to have dependencies, like to not alert for all devices when one major goes down - is that planned?

Sounds like your template is broken. Try using the convertor to convert to the new format.

I used the converter as you suggested, the issue starter on Jul 22nd.
Before that all notifications were without that line.

Here is the template:

@if ($alert->transport == slack)
@if ($alert->state == 1) ALERT: @else RECOVERED: @endif

Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif

Hostname: {{ $alert->sysName }}
Hardware: {{ $alert->hardware }}
Duration: {{ $alert->elapsed }}


@if ($alert->faults)
Interfaces: @foreach ($alert->faults as $key => $value) #{{ $key }}: {{ $value[‘ifDescr’] }} - {{ $value[‘ifAlias’] }} @endforeach
Location: @foreach ($alert->faults as $key => $value) #{{ $key }}: {{ $value[‘location’] }} @endforeach
@endif
@else
@if ($alert->state == 1) ALERT: @else RECOVERED: @endif
Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif
Hostname: {{ $alert->sysName }}
Hardware: {{ $alert->hardware }}
Duration: {{ $alert->elapsed }}
@if ($alert->faults)
Interfaces:: @foreach ($alert->faults as $key => $value) #{{ $key }}: {{ $value[‘ifDescr’] }} - {{ $value[‘ifAlias’] }} @endforeach
Location:: @foreach ($alert->faults as $key => $value) #{{ $key }}: {{ $value[‘location’] }} @endforeach
@endif
@endif

Got some alerts today and priority is gone.
Whatever you did guys, thanks.