Telegram alerts seems to be broken

When asking for help and support, please provide as much information as possible. This should include:

  • Steps to reproduce an issue.
  • The output of ./validate.php

If it’s an issue with the WebUI then please consider including a screenshot and the browser version you are using.

If you are having troubles with discovery/polling include the pastebin output of:

./discovery.php -h HOSTNAME -d | ./pbin.sh
./poller.php -h HOSTNAME -r -f -d | ./pbin.sh

If you need to post any text longer than a few lines, please use a pastebin service such as https://p.libren.ms using non-expiring pastes.

Since i think the last update the alerts send by telegram only contain variables and not the content anymore output see below. I did already an apt-get update and upgrade.
Validate php does not give any clue here. I do have an issue with te time in php, seems i need to find out where the php.ini is located for librenms since the setting is there in the php.ini of apache.
Willing to debug but need some guidance here.

message in telegram:
%title

Severity: %severity

{if %state == 0}Time elapsed: %elapsed

{/if}Timestamp: %timestamp

Unique-ID: %uid

Rule: {if %name}%name{else}%rule{/if}

{if %faults}Faults:

{foreach %faults} #%key: %value.string

{/foreach}{/if}Alert sent to: {foreach %contacts}%value <%key> {/foreach}

Further investigation.
When i want to make a test message from librenms it fails
Test to telegram failed general error.

Hi,

No, telegram transport is not broken.

Also, seems like you werent updating from long time ago.

Check Deprecation notice: Alerting - Legacy transports and templates and update your templates :wink:

strange the daily updates were processed. i wil look into the info thanks

Checked, removed all old transport and old rules, and create new ones under alerts to be sure.
Created a new bot based on this document : https://docs.librenms.org/Alerting/Transports/
From there there is a small corrrection needed in the document. After creaton of the bot, you need to start the url to activate the bot otherwise the bot will anwer the url in de example with : {“ok”:true,“result”:[]}
After talking to the bot then you get the jason result back.
But , after the whole procedure … no luck
the message pop ups and then no further actions possible.

image

Iirc, you configure your bot to use html or markdown.

You must select the same in your transport settings.

conversion done seems test does work.

Darn test alerts do work, but the system does not transport, logging shows this message.
I do not receive alerts in telegram. While test alerts do work.
Any Clue?? Where could i debug this issue?

2019-06-17 20:32:03 alert 192.168.1.14 Issued recovery for rule ‘Device rebooted’ to transport ‘mail’ System
2019-06-17 20:32:02 alert 192.168.1.14 Issued recovery for rule ‘Device rebooted’ to transport ‘mail’ System
2019-06-17 20:32:02 error 192.168.1.14 Could not issue recovery for rule ‘Device rebooted’ to transport ‘telegram’ Error: HTTP Status code 400 System
2019-06-17 20:27:04 alert 192.168.1.14 Issued recovery for rule ‘Devices up/down’ to transport ‘mail’ System
2019-06-17 20:27:03 alert 192.168.1.14 Issued warning alert for rule ‘Device rebooted’ to transport ‘mail’ System
2019-06-17 20:27:03 error 192.168.1.14 Could not issue warning alert for rule ‘Device rebooted’ to transport ‘telegram’ Error: HTTP Status code 400

Check here -> https://docs.librenms.org/Alerting/Testing/

Thanks:


But i see only one transport, so seems we have found the issue … but how to solve it since the transport is recreated and when i do a test with telegram the message is popping up…

Rule name: Devices up/down
Alert rule: macros.device_down = 1
Alert query: SELECT * FROM devices WHERE (devices.device_id = ?) AND (devices.status = 0 && (devices.disabled = 0 && devices.ignore = 0)) = 1
Rule match: no match

Found 1 transports to send alerts to.
Transport: mail

Debug :
:: Transport telegram => SQL[SELECT transport_config FROM alert_transports WHERE transport_id=? [4] 0.78ms]

string(21) “API ‘’ returned Error”
string(8) “Params: "
string(154) “Return: {“ok”:false,“error_code”:400,“description”:“Bad Request: ca n’t parse entities: Unsupported start tag “[email protected] at byte offse t 352”}”
ERROR: HTTP Status code 400
SQL[INSERT IGNORE INTO eventlog (device_id,reference,type,datetime,se verity,message,username) VALUES (:device_id,:reference,:type,:datetime,:se verity,:message,:username) {“device_id”:7,“reference”:null,“type”:“error”,“datet ime”:“2019-06-17 21:51:11”,“severity”:5,“message”:“Could not issue recovery for rule ‘Devices up/down’ to transport ‘telegram’ Error: HTTP Status code 400”,“us ername”:”"} 4.96ms]

Here i have a problem, syntax error?

[email protected]:/opt/librenms/scripts# ./test-template.php -t 0 -d -h 192.168.1.14 -r 4 -s 1
SQL[SELECT device_id FROM devices WHERE hostname = ? [“192.168.1.14”] 0.8ms]

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘alerts.state=1’ at line 1 (SQL: SELECT alerts.id, alerts.device_id, alerts.rule_id, alerts.state, alerts.note, alerts.info FROM alerts WHERE alerts.device_id=7 && alerts.rule_id=4 alerts.state=1) (SQL: SELECT alerts.id, alerts.device_id, alerts.rule_id, alerts.state, alerts.note, alerts.info FROM alerts WHERE alerts.device_id=7 && alerts.rule_id=4 alerts.state=1)#0 /opt/librenms/includes/alerts.inc.php(675): dbFetchRows(‘SELECT alerts.i…’)
#1 /opt/librenms/scripts/test-template.php(24): loadAlerts(‘alerts.device_i…’)
#2 {main}
No alert found, make sure to select an active alert.

Do you mind posting your template?

Seems you have something wrong in it

{{ $alert->title }}
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

Ok.
In the last line remove the < > surrounding the $key var.

From

To look like this:

Done, if i want to test the transport how could i create a forced alert? should i play with the -s or is there another script needed to force the transport, the telegram standard test does work from the transport interface but that is the standard test message.

[email protected]:/opt/librenms/scripts# ./test-template.php -t 0 -d -h 192.168.1.14 -r 4 -s 0
No alert found, make sure to select an active alert.

What I usually do to test templates is to create a “fake alert” that will trigger in normal conditions.

For example, port utilization, I just set it to a value that is already lower than the actual usage so it will trigger.

The correction works thanks