How to enable remote (syslog) udp logging in Shelly IoT device

Written by - 0 comments

Published on - Listed in Monitoring Hardware Linux

Shelly IoT devices are mainly used in combination with a Smart Home or to simply measure (and control) the power consumption of a device or room.

The Shelly devices can be monitored and integrated into a classical monitoring system as well. But is there a way to get the system logs from the device itself? Yes, there is!

Prepare a Syslog server for "incoming" logs

All you need as a preparation is a Linux machine in the same network as your Shelly device. Of course you could also use a Linux machine in the cloud, but that's not recommended.

On that Linux machine, configure a Syslog server, such as Rsyslog or Syslog-NG. In this example I'm using Rsyslog, which is pretty much the standard on Ubuntu and Debian machines.

In /etc/rsyslog.conf there should be a prepared configuration snippet which enables the "imudp" module (short for Input Module UDP):

# provides UDP syslog reception
input(type="imudp" port="514")

Enable the module and input lines by removing the comment character (#). Note that the default port is 514.

Restart Rsyslog after this change:

root@syslog ~ # systemctl restart rsyslog

Configure Shelly to log to Syslog server

Now open up your browser of choice and enter the IP of your Shelly device in the address bar. This should show the user interface of Shelly's internal web server:

Click on the "Device" icon at the bottom, then open up the "Debug" drow down menu. Here you are able to enable a "Udp debug". The name is unfortunately not self-explaining, calling it "Syslog debug" would probably be more helpful. Toggle the Udp debug and enter the IP address and the port of the remote syslog server.

Syslog logging from Shelly device

Click on "Save address" and the Shelly device will immediately start sending logs to the defined Syslog server.

Checking the logs

Logged in on the Linux Syslog server, check the logs of the default log (usually /var/log/syslog):

root@syslog ~ # tail -f /var/log/syslog
Jul  8 13:41:40 shellypro4pm-083a083a083 49866 90810.856 2 2|shelly_notification:118 Status change of switch:0: {"id":0,"apower":311.7}
Jul  8 13:41:45 shellypro4pm-083a083a083 49867 90815.671 2 2|mgos_http_server.c:180  0x3ffe1c64 HTTP connection from
Jul  8 13:41:45 shellypro4pm-083a083a083 49868 90815.929 2 2|mgos_wifi_sta.c:737     Avg RSSI -88, will scan for a better AP
Jul  8 13:41:47 shellypro4pm-083a083a083 49869 90818.208 2 2|mgos_wifi_sta.c:560     Current AP is best AP
Jul  8 13:41:48 shellypro4pm-083a083a083 49870 90818.775 2 2|shelly_notification:118 Status change of switch:0: {"id":0,"apower":295.0}
Jul  8 13:41:55 shellypro4pm-083a083a083 49871 90825.703 2 2|shelly_notification:118 Status change of switch:0: {"id":0,"apower":310.3}
Jul  8 13:41:56 shellypro4pm-083a083a083 49872 90826.489 2 2|mgos_http_server.c:180  0x3ffe1ba0 HTTP connection from
Jul  8 13:41:56 shellypro4pm-083a083a083 49873 90826.693 2 2|shelly_notification:118 Status change of switch:0: {"id":0,"current":1.617}
Jul  8 13:41:57 shellypro4pm-083a083a083 49874 90827.529 2 2|mgos_http_server.c:180  0x3ffe18d0 HTTP connection from
Jul  8 13:41:57 shellypro4pm-083a083a083 49875 90827.752 2 2|mg_rpc.c:314            Sys.GetStatus via HTTP user admin

The Shelly device identifies itself with the product name (shellypro4pm) followed by the serial number. This is helpful if you have multiple Shelly devices logging to the same Syslog server.

Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.