Welcome to the Athom Community Forum! This is a place to share ideas, ask for help and discuss about Homey in general.

Please read Welcome to the forum to get started.

[APP] Prometheus.io export

KyrcioKyrcio Member
edited March 13 in Apps
As a means of learning how to interact with the Homey API, I decided to put together a basic exporter for Prometheus.io (partly because I want to understand how to subscribe to device changes, and partly because I miss the Grafana dashboards I had with Openhab).

If anyone wants to try it out it is here
https://github.com/rickardp/homey-prometheus-exporter

If there is enough interest, I might find some time to finalize and publish it.
«1

Comments

  • Awesome, just what i was looking for 

    Just installed the app, but it keeps on crashing  

  • Thanks for reporting! Could I please ask you to provide a stacktrace (athom project —run), either here or on github.

    I created the app yesterday and I’ve only tested it with my own Homey, so it’s not yet exactly stable. But with your help it will improve <span>:smile:</span>
  • Looking good, will try it also later but first need to install Promotheus in a docker
  • So here’s a small Grafana dashboard I put together after having the app running for about a day.
    Any ideas on what to show?
  • Kyrcio said:
    Thanks for reporting! Could I please ask you to provide a stacktrace (athom project —run), either here or on github.
    Sure, please note i'm running the  1.5.6-rc.8  firmware


    module.js:538
        throw err;
        ^
    Error: Cannot find module 'athom-api'
        at Function.Module._resolveFilename (module.js:536:15)
        at Function.Module._load (module.js:466:25)
        at Module.require (module.js:579:17)
        at Module.require (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/index.js:1:253)
        at require (internal/module.js:11:18)
        at Object.<anonymous> (/app.js:4:22)
        at Module._compile (module.js:635:30)
        at Object.Module._extensions..js (module.js:646:10)
        at Module.load (module.js:554:32)
        at tryModuleLoad (module.js:497:12)
    --- INFO: io.prometheus has been killed ---




  • KyrcioKyrcio Member
    edited February 9
    @techniman You probably need to run “npm install” before installing on the Homey.
  • odd, that's a first 
    But indeed that fixed the issue Thanks!

  • KyrcioKyrcio Member
    edited February 9
    Maybe I made a mistake setting the project up. I also expected that to happen automatically.

    EDIT: Apparenly I am supposed to check in my node_modules directory. Although I strongly disagree with the practice, I have now done so.
  • qtechqtech Member
    Good. Any plans to support InfluxDB as well?
  • KyrcioKyrcio Member
    edited February 10
    InfluxDB would be a whole new ballpark as it does not have the polling architecture of Prometheus (for good or for bad, but in this case the polling greatly simplifies things). Usually, they are used for different things (InfluxDB is often used with event sources AFAIK).

    I am not ruling out Influx but it would likely take a little more time to implement.

    What would you do with influx that you lack with Prometheus?
  • I was totally loving InfluxDB when it was launched, and the pushing of data. I could push data on every change, instead of polling (and having to "oversample").

    But as I have recently read about Prometheus, I am starting to like it. I will try it out.
  • qtech said:
    I was totally loving InfluxDB.
    Agreed, I tend to use Influx for lots of stuff where I push data. It's just more convenient in some cases to have the monitoring service know about what to monitor than the other way around. For example, I could make the exporter entirely configuration free. In the Influx case, I would have to create some kind of UI to have the user enter the endpoint(s).
  • Interesting to see how the updates went in Grafana. Apparently the update to 1.5.6 took almost 90 minutes, and about 16 hours later the load averages went up. I did not mess with the Homey that day, so I suspect one of the apps must have self-updated around that time.

  • Kyrcio said:
    Interesting to see how the updates went in Grafana. Apparently the update to 1.5.6 took almost 90 minutes, and about 16 hours later the load averages went up. I did not mess with the Homey that day, so I suspect one of the apps must have self-updated around that time.

    How did you got the Homey version added, i can't find the Homey version in the available data from Prometheus?
  • Kyrcio said:
    Interesting to see how the updates went in Grafana. Apparently the update to 1.5.6 took almost 90 minutes, and about 16 hours later the load averages went up. I did not mess with the Homey that day, so I suspect one of the apps must have self-updated around that time.

    How did you got the Homey version added, i can't find the Homey version in the available data from Prometheus?
    The version info comes as a label on the uptime. Use something like “homey_boot_time * 0 + 1“ to get the blocks in Grafana. To get nice labels you could use “v{{version}}” as legend format.

    I will publish the dashboards I created once I get them cleaned up.
  • Here’s a graph showing outside temperature and air pressure, aggregated over multiple Xiaomi Zigbee sensors. The temperature uses the min() aggregation while the pressure uses the avg() aggregation.
  • RobertLijkendijkRobertLijkendijk Backer - Early Bird
    edited March 5
    Kyrcio Thanks for the great work so far! I've been looking for a solution like this!
    I started a container running Prometheus, and installed your app using the Athom CLI.
    The app is running on my Homey, but for some reason I cannot connect to http://<homey ip>:9414/metrics .
    I get the following error:

    This site can’t be reached

    192.168.0.202 refused to connect

    Do you've got any clue what's going wrong? I already tried to reboot my Homey but that didn't solve this.


    I am running version 0.1.1 of your app, and Homey version 1.5.7
  • Kyrcio Thanks for the great work so far! I've been looking for a solution like this!
    I started a container running Prometheus, and installed your app using the Athom CLI.
    The app is running on my Homey, but for some reason I cannot connect to http://<homey ip>:9414/metrics .
    I get the following error:

    This site can’t be reached

    192.168.0.202 refused to connect

    Do you've got any clue what's going wrong? I already tried to reboot my Homey but that didn't solve this.


    I am running version 0.1.1 of your app, and Homey version 1.5.7
    Then either your router is blocking the ports, your docker is not reachable from the outside or the app is not  correctly installed. What do you see when you visit <homey ip>:9414/metrics because then you need to see the raw metrics. I have it also running with Prometheus and Grafana running in a docker on my synology
  • RobertLijkendijkRobertLijkendijk Backer - Early Bird
    Thanks for your reply @lubbertkramer, the issue is on the side of Homey.
    The docker containers are running fine and the webinterfaces of Prometheus and Grafana can be reached.

    The IP of my Homey is 192.168.0.202. Visiting http://192.168.0.202:9414/metrics shows an error the site cannot be reached.

    To install the App to my Homey i downloaded and installed Node.js 8.9.4 on my mac.
    After installing Node.js i used the command "npm install -g athom-cli" to install the Athom CLI software.
    Then i used git to download the app, moved into the directory containing the app and issued the "Athom app install" command to install the app to my Homey.

    Should I've done something differently? I've removed the app and installed it again but unfortunately it didn't make a difference.
  • You should be able to see a page full of metrics when visiting the page, don't know maybe something is blocking your traffic? 


  • RobertLijkendijkRobertLijkendijk Backer - Early Bird
    I am not filtering / blocking any traffic within my LAN... The app doesn't seem to be logging anything so it's hard to figure out what's wrong... I understand I should see information when I visit that page but unfortunately it doesn't work:


  • RobertLijkendijkRobertLijkendijk Backer - Early Bird
    edited March 7
    I've been looking through the code of the app, and I've modified the port from 9414 to 8080 to make sure it hasn't got anything to do with something within my network blocking/filtering traffic to port 9414. Will test it later today when I get home and I'll get back to you guys <span>:smile:</span>
  • RobertLijkendijkRobertLijkendijk Backer - Early Bird
    edited March 7
    Changing the port the app listens on in the code doesn't make a difference, I am unable to access the metrics page. Something really seems off.... @Kyrcio  any idea what could be causing this issue? Perhaps you can add some kind of logging the app so we can figure out what's going on. :smile:
  • JBSJBS Member
    I am trying to install this app via CLI om my Homey (running on 1.5.3 stable) but gets an error about incompatible app version:


  • bvdbosbvdbos Moderator, Backer - Geek Edition
    Which Homey version are you on?
  • JBSJBS Member
    bvdbos said:
    Which Homey version are you on?
    1.5.3 but >= 1.5.6 is needed I saw :(
  • RobertLijkendijkRobertLijkendijk Backer - Early Bird
    After resetting my Homey to factory defaults and installing this app again it somehow started working.
    Is there a way to export the "presence" status as well? I can see it in insights but it doesn't show up in the Metrics page.
  • KyrcioKyrcio Member
    edited March 12
    Changing the port the app listens on in the code doesn't make a difference, I am unable to access the metrics page. Something really seems off.... @Kyrcio  any idea what could be causing this issue? Perhaps you can add some kind of logging the app so we can figure out what's going on. :smile:
    I have really no idea about your particular case, but I would “nmap” the Homey just to see what’a open. Running the app with “athom app run” should give you plenty of log output. If you didn’t get any I suspect there was a problem starting the app.
  • KyrcioKyrcio Member

    ...
    Is there a way to export the "presence" status as well? I can see it in insights but it doesn't show up in the Metrics page.
    Great suggestion. I will look into if there is an API for it.
Sign In or Register to comment.