[New Add-on] Prometheus Node Exporter

prometheus_node_exporter

The Prometheus Node Exporter for hardware and OS metrics exposed by *NIX kernels.

Installation

  1. Add my repository. The URL is https://github.com/loganmarchione/hassos-addons.
  2. Search for the “Prometheus Node Exporter” add-on in the Supervisor add-on store and install it.
  3. Disable “Protection mode” in the add-on panel.
  4. Start the add-on.
  5. Check the logs of the add-on to see if everything went well.
  6. To verify the metrics are available, visit http://your_home_assistant_ip_address:9100/metrics in your browser, or use curl curl -X GET http://your_home_assistant_ip_address:9100/metrics.

Configuration

N/A

Usage

Add the following to the /etc/prometheus/prometheus.yml config file on your Prometheus server:

scrape_configs:
  ...
  ...
  ...
  - job_name: 'homeassistant'
    static_configs:
    - targets: ['your_home_assistant_ip_address:9100']

The following Prometheus query should return data:

node_uname_info{job="homeassistant"}

Support

WIP

Authors & contributors

Logan Marchione

License

WIP

Known issues

  • [ ] The “Open Web UI” button doesn’t work when Home Assistant is behind a reverse proxy.
  • [ ] Only tested on amd64 builds.

FAQ

  • Doesn’t Home Assistant already have Prometheus integration?
  • Isn’t there already an Prometheus add-on?
    • Yes, but that add-on is for Prometheus server, not the node exporter.
  • Why does this add-on require so many permissions?
    • The add-on needs to access to host-level metrics (CPU, memory, disk, etc…). As such, I have requested all possible permissions. Please inspect the code of this add-on before you run it.

thanks for the addon. it´s a bummer that this doesn´t work on a rpi 4 :frowning: maybe someone could do that in the future :wink:

@BangerTech - I got my hands on a RPi 4B and created an aarch64 built. It seems to work for me, test it and let me know.

I was just looking to set up node_exporter myself via SSH to HassOS and manual installation, when I stumbled across this. Thank you! I installed and seems to work fine so far on my RPi 4.

@lmm7425 - great job! I just installed it and it is looking great. It’s nice to have another node in my grafana boards to better understand conntrack and networking metrics.

If I can offer some feedback: I admit that I don’t know exactly what Protection Mode does with Add-ons, but I don’t really like that I have to disable it. I see that SSL is on your to-do list. Is there any help you need with either SSL or being able to use the add-on with protection mode enabled?

@norman.rasmussen Thanks, always open to feedback and help!

Node exporter requires host-level access (since it’s running in a container) so that it can read CPU, memory, disk, etc… of the host. This is why protection mode needs to be disabled. I tried to enable it, but wasn’t getting all the metrics I needed. I’m running my Home Assistant instance in my homelab and it’s not exposed to the internet, so I’m comfortable disabling protection mode internally.

As far as SSL, I’m going back and forth on that. I do want to expose metrics via HTTPS, but it shouldn’t be my add-on’s job to do that. I’m leaning more towards letting the user expose their Home Assistant instance via HTTPS (reverse proxy, directly, whatever the user wants, etc…) and then having my add-on “play nice” with that. I guess my job is to figure out the best way to do that. I’m honestly not sure what APIs I can call to get the Home Assistant URL or how to make port 9100 work if Home Assistant is behind a reverse proxy. There are a lot of scenarios that could be out there, so that’s kind of where I’m stuck…

Thanks for your reply! Makes sense on all fronts. I’ll look into the SSL thing and what you are considering and let you know if I come up with anything useful.

Hi.
I have some troubles making this add-on work.
I can see the metrics page on port 9100 but I am unable to get the data in my prometheus database.
Can someone help me ?
what config should I do in Grafana/prometheus database ? Should I use port 9090 or 9100 ?

Thanks a lot…

@Paddi - this is a 2-step process

  1. You need to setup a prometheus scrape config. Below is a snippet from mine. Note that port 9100 is used here. Authentication is optional.
  - job_name: 'homeassistant'
    static_configs:
      - targets: ['hass02.internal.mydomain.com:9100']
    basic_auth:
      username: user
      password: asldfjaslkdfjasdflkasjdlfjasdlfknalsdfsdf

Once the scrape config is setup, you should be able to query the job from prometheus’ web interface. Note how the job name in the query below is the same as the scrape config from above.

node_uname_info{job="homeassistant"}
  1. In Grafana, you’ll need to setup a Prometheus data source with the URL of http://prometheus_server:9090. Then, you can setup Grafana queries using regular PromQL. You won’t be able to do anything in Grafana if you can’t get the stuff in step 1 working.

Thank you for the reply. However as I am a total newbie in that domain, I can’t make it work.
I installer HA on a Raspi 4 with influxdb and grafana plugins.
I then added a prometheus database using port 9090.
I installed your add-on and I can see the metrics page on port 9100.
For the prometheus scraping config, I created a prometheus folder (as it was not existing) and created the prometheus.yml file. The only thing I have in it is your snippet.
I am then missing the prometheus server ? Based on what I read, adding ‘prometheus:’ in HA configuration file is enough.

So, sorry… I am a bit lost.

I don’t use Prometheus server installed on HA (I run my own instance on a separate Docker container), so I can’t speak to how Prometheus on HA is setup 100%.

Setting prometheus: in the HA config file exports HA data to a format a separate Prometheus server can read. That integration is documented here. Doing this does not setup a Prometheus server.

If you want to setup an actual Prometheus server on your HA instance, you want to first add the Community Beta Repo, then follow these instructions to install Prometheus server on your HA instance.

Then, you can use my snippet in the config file.

Thank you, I followed the directions and everything is working perfectly first try.