shelly-script-examples icon indicating copy to clipboard operation
shelly-script-examples copied to clipboard

prometheus.js not working on Shelly PM Mini Gen3

Open gmoscalu opened this issue 7 months ago • 1 comments

Describe the bug Script gives an error not the desired output.

To Reproduce Steps to reproduce the behavior:

  1. added the script as it comes from the library to my device
  2. adjusted the const monitored_switches = ["pm1:0"]
  3. calling from POSTMAN: GET http://10.10.200.43/script/2/metrics
  4. result:

Body: "error" Status: 500 Internal Server Error Logs: { "ts": 1721422542.866, "level": 2, "data": "shelly_ejs_rpc.cpp:41 Shelly.call Shelly.GetStatus {}", "fd": 1 }, { "ts": 1721422542.9, "level": 2, "data": "shos_rpc_inst.c:230 Shelly.GetStatus via loopback ", "fd": 1 }, { "ts": 1721422545.687, "level": 2, "data": "in function \"generateMetricsForSwitch\" called from generateMetricsForSwitch(switch_string_id)", "fd": 102, "component": "script:2" }, { "ts": 1721422545.688, "level": 2, "data": " ^", "fd": 102, "component": "script:2" }, { "ts": 1721422545.688, "level": 2, "data": "in function called from }).join(\"\")", "fd": 102, "component": "script:2" }, { "ts": 1721422545.689, "level": 2, "data": " ^", "fd": 102, "component": "script:2" }, { "ts": 1721422545.689, "level": 2, "data": "in function called from system", "fd": 102, "component": "script:2" }, { "ts": 1721422545.69, "level": 1, "data": "shelly_user_script.:388 error: Error in EjsCall", "fd": 1 }, { "ts": 1721422545.691, "level": 2, "data": "shelly_ejs_httpserv:348 0x3fcba8bc send() -> -9 error", "fd": 1 }, { "ts": 1721422545.708, "level": 2, "data": "shelly_ejs_httpserv:117 2 unregistered /script/2/metrics", "fd": 1 }, { "ts": 1721422545.73, "level": 2, "data": "shelly_notification:163 Status change of script:2: {\"id\":2,\"errors\":[\"error\"],\"running\":false}", "fd": 1 },

Expected behavior As "promised" by the script, i hoped to be able to scrape these devices (10 of them) directly from Prometheus, not going through the json_exporter tool...

Screenshots Postman: image

Console: image

Device and script details (please complete the following information):

  • Firmware version: 20240625-122557/1.3.3-gbdfd9b3
  • Link to the script you were running: prometheus.js

Additional context Add any other context about the problem here.

gmoscalu avatar Jul 19 '24 21:07 gmoscalu