Alert template recovery: how to get actual value instead of alerted one


I’m working on alert templates using Telegram transport.

We notify admins when a BGP session goes down, a filesystem reach more than certain mark, etc. We make a list by iterating faults to give more information to sysadmin Screenshot%20from%202018-12-20%2011-05-18

A filesystem was at 92% of usage when alert was triggered. Then when the problem was resolved, the filesystem was at 65%, but the recovery message still say 92%. I would like to notify admin team, that the problem was resolved and the filesystem is now at 65%. I thing that this can’t be possible just iterating the faults list.

Is there a way to do this? Or may be a feature request?

Thanks in advance.

Probably not the best idea but you could.

{{ \App\Models\Storage::find($value['storage_id'])->storage_perc }}

No guarantees that won’t break your alerting :slight_smile:

I did a first test and it works.

Looks intresting that we can use Librenms classes on alert templating :slight_smile:

1 Like

Here is the final alert template:

{{ $alert->title }}
` Host     : {{ $alert->hostname }}`
` sysName  : {{ $alert->sysName }}`
` Time     : {{ $alert->timestamp }}`
` State    : @if ($alert->state == 0)Ok @endif @if ($alert->state == 1)✋ Warning @endif`
` Rule     : @if ($alert->name){{ $alert->name }} @else {{ $alert->rule }} @endif `
` Unique-ID: {{ $alert->uid }}`
@if ($alert->state == 0) ⏳ Time elapsed:  {{ $alert->elapsed }} @endif 
@if ($alert->faults) 
@foreach ($alert->faults as $key => $value)
`   ⭗ {{ $value['storage_descr'] }}: ({{ \App\Models\Storage::find($value['storage_id'])->storage_perc }}%)`
@if ($alert->alert_notes)
✍ *Notes:* 
https://mynet/device/device={{ $alert->hostname }}/tab=alerts/
1 Like

You could put the old value in there too :slight_smile:

Dude, your template looks awesome.

I use telegram too. Do you mind sharing them?

My url goes to /tab=health/metric=storage/

I would like to get the actual value of port utilization.
It seems to be able to get with the following code. It’s OK?

Input : {{ \App\Models\Port::find($value['port_id'])->ifInOctets_rate *8 / $value['ifSpeed'] *100 }} %
Output: {{ \App\Models\Port::find($value['port_id'])->ifOutOctets_rate *8 / $value['ifSpeed'] *100 }} %