Email alerts not showing device hostname/sysname/ipaddress?

So I recently setup LibreNMS and it works great. However, I am having issues with mail alerts. I do not see any relevant data that can give me an idea about which device is having an issues. I am using the default template that comes with LibreNMS and just added 3 lines to it.

> {{ $alert->title }}
> Hostname: {{ $alert->hostname }}
> System Name: {{ $alert->sysName }}
> IP Address: {{ $alert->ip }}
> Severity: {{ $alert->severity }}
> @if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif
> Timestamp: {{ $alert->timestamp }}
> Unique-ID: {{ $alert->uid }}
> Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif
> @if ($alert->faults) Faults:
> @foreach ($alert->faults as $key => $value)
>   {{ $key }}: {{ $value['string'] }}
> @endforeach
> @endif
> Alert sent to:
> @foreach ($alert->contacts as $key => $value)
>   {{ $value }} <{{ $key }}>
> @endforeach

Using the above template, I get a mail alert with the below data which doesn’t mention any relevant data.

> Alert for device  - Port status up/down
> 
> 
> 
> 
> 17
> Severity: critical
> Timestamp: 2018-12-13 13:10:18
> Unique-ID: 518
> Rule:  Port status up/down  Faults:
>   1: sysObjectID = .1.3.6.1.4.1.311.1.1.3.1.2; sysDescr = Hardware: Intel64 Family 6 Model 45 Stepping 7 AT/AT COMPATIBLE - Software: Windows Version
> 6.1 (Build 7601 Multiprocessor Free); port_id = 244; ifDescr = Teredo Tunneling Pseudo-Interface.;
>   2: sysObjectID = .1.3.6.1.4.1.311.1.1.3.1.2; sysDescr = Hardware: Intel64 Family 6 Model 45 Stepping 7 AT/AT COMPATIBLE - Software: Windows Version
> 6.1 (Build 7601 Multiprocessor Free); port_id = 245; ifDescr = WAN Miniport (IKEv2).; Alert sent to:

As you can see, it throws the sysdescription but nothing relevent. I do not want anything fancy. A simple template saying there is an issue with xyz device and if possible, a little detail about the issue.

Few things to note: I have added all device IP’s in the host files so that librenms can resolve them to hostname and added each and every device using the hostname.

Could someone please help me as I am completely new to this.

what three lines did you add? it broke after you added the three lines. Syntax error.

> Hostname: {{ $alert->hostname }}
> System Name: {{ $alert->sysName }}
> IP Address: {{ $alert->ip }}

The above three lines were added. Rest its all default. As far as I believe, I am following the syntax rules. Please help me understand where I am going wrong and how I can fix it?

Using:

Hostname: {{ $alert->hostname }}
System Name: {{ $alert->sysName }}
IP Address: {{ $alert->ip }}

I get:

Hostname: www.google.co.uk
System Name: www.google.co.uk
IP Address: 172.217.23.3

So it definitely works ok.

Your output shows 17 is being printed out, unless your rule title is 17 then you’ve got an issue somewhere and that template above isn’t 100% the one being used.

Try: https://docs.librenms.org/Alerting/Testing/#templates

I’m sorry that I forgot to mention but 17 was actually device ID because I had also added the line

{{ $alert->device_id }}

I have not done any modifications in templates (except for the 4 lines for hostname, sysname, ip and ID) or rules. Nor have I created any custom template/rule.

How can I troubleshoot this? Can someone please help? This tool works flawlessly but the alerts are not using for us at all because we cannot figure out from the mail alerts.

Please Help.