laminair / jetson_stats_node_exporter

This project is a custom Prometheus Node Exporter Variation for Nvidia's Jetson Platform.
GNU Affero General Public License v3.0
20 stars 5 forks source link
gpu-monitoring iot jetson prometheus-exporter

Nvidia Jetson Prometheus Node Exporter (incl. GPU) - incl. JetPack 6.0

This project contains a node exporter variation building on jetson-stats (jtop) rather than tegrastats directly. We export the following metrics:

We do not export:

Installation

You can either clone this repo or use pip for installation. Wheels or binaries are provided here: Jetson Stats Node Exporter Releases

Easy Installation via PyPi

Make sure your local installation of jetson-stats is 4.2.9. Otherwise, you will run into dependency issues.

pip install jetson-stats-node-exporter==0.1.0

Install from git

Installation with pip (no venv or conda due to jetson-stats dependency!):

> export JSN_RELEASE="0.1.0"
> sudo -H pip3 install -U https://github.com/laminair/jetson_stats_node_exporter/releases/download/$JSN_RELEASE/jetson_stats_node_exporter-$JSN_RELEASE-py3-none-any.whl

Install from source

Manual installation (may require sudo privileges due to jetson-stats dependency):

> git clone https://github.com/laminair/jetson_stats_node_exporter.git
> cd jetson_stats_node_exporter
> python3 setup.py install

Running the exporter

After installation the project is available as python module. Run it as follows:

python3 -m jetson_stats_node_exporter

This will spawn a prometheus node exporter service on port 9100 and you'll be able to scrape all statistics. Note: The command above can also be run as a systemd service in the background.

Creating a background service

The node exporter can be wrapped in a systemd service. Place the following file in path /etc/systemd/system/jetson-stats-node-exporter.service

[Unit]
Description=Jetson Stats GPU Node Exporter
After=multi-user.target
Requires=jtop.service

[Service]
Type=simple
Restart=on-failure
RestartSec=10
User=root
Group=root
ExecStart=/usr/bin/python3 -m jetson_stats_node_exporter

[Install]
WantedBy=multi-user.target

Then run sudo systemctl start jetson-stats-node-exporter. To check if the service is alive sudo systemctl status jetson-stats-node-exporter

Creating a docker image

The node exporter can be wrapped in a docker image and can be run via docker. If you use docker compose you can build the image directly via docker compose. Place the Dockerfile in the same directory as your docker-compose.yaml, or use the context option in your docker-compose.yaml to specify the folder containing the Dockerfile.

  jetson_stats_node_exporter:
    build:
      context: ./custom_images
      dockerfile: Dockerfile_jetson_stats_exporter
    container_name: hsos_jetson_stats_node_exporter
    restart: always
    ports:
      - "9100:9100"  # Map internal port 9100 to a different external port 9100
    volumes:
      - /run/jtop.sock:/run/jtop.sock

Credits

This project is based on https://github.com/lipovsek/jetson_prometheus_exporter, which uses tegrastats.