Alerting from Traps - clean up the email message

Tags: #<Tag:0x00007fd894c3fae0> #<Tag:0x00007fd894c3fa18>


I am sending SNMP Traps on port 162 into my LibreNMS server, and I might not be grasping how to properly manage the trap information. My current rules grab the trap in the field

eventlog.type = “trap” AND eventlog.message LIKE ‘%12003%’

I have not found a better way to sort the trap based on the payload of said traip.

Here is a copy of my alert template:

{{ $alert->title }}
Severity: {{ $alert->severity }}
@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif
Timestamp: {{ $alert->timestamp }}
Unique-ID: {{ $alert->uid }}

@if ($alert->faults)
@foreach ($alert->faults as $key => $value)
@if ($loop->last) Current TRAP – {{ $value[‘message’] }} @endif

And here is a sample email response:

Alert for device - Something Happened
Severity: warning
Timestamp: 2021-09-09 14:31:09
Unique-ID: 1234

    Current TRAP -- MY-MIB::infrElementStatusTrap



  1. Is there a way in my Alert template that I can cleanup deeper, such as {{ $value[‘message.MIB::Location’] }} to isolate that field? Perhaps I could also perform a grep to sort for that field, or perhaps a sed / awk to pull out the piece of desired information?

  2. On my email, I have &quot but here in the HTML viewer, I am seeing “” marks. Is there a command inside the alert template that I can surpres those marks?

My goal is to make the email presentation nice and clean for a quick read.