Skip to content

Prometheus exporter for Rockchip NPU load metrics, written in Rust.

License

Notifications You must be signed in to change notification settings

yinguobing/rknpu-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RKNPU Exporter

Rust

Prometheus exporter for Rockchip NPU load metrics, written in Rust.

Grafana Screenshot

How it works

The Rockchip NPU load is available by this command:

sudo cat /sys/kernel/debug/rknpu/load
# output
NPU load:  Core0:  0%, Core1:  0%, Core2:  0%,

With a little help of Rocket and client_rust, the load metrics could be parsed and exported for Prometheus.

Prerequisites

To run the exporter natively:

  • RK3588 SoC
  • Debian 11

To develop:

  • rustc 1.73.0 (cc66ad468 2023-10-03)

Install

  1. Download the executable binary file from the Release page and extract the content.

  2. Create a configuration file named Rocket.toml in the same directory, and fill it with your custom settings.

    # Example setup.
    [release]
    address = "0.0.0.0"
    port = 9102

That's all.

Notes

Run

In the directory where the binary file located

sudo ./rknpu-exporter

A message looks like 🚀 Rocket has launched from http://127.0.0.1:8000 will be printed, then the exporter is ready.

Quick test

Open a browser and visit 127.0.0.1:9102/metrics, you shall see the raw metrics.

# HELP rockchip_npu_load Rockchip NPU Load.
# TYPE rockchip_npu_load gauge
rockchip_npu_load{manufacturer="rockchip",device="npu",id="1"} 0
rockchip_npu_load{manufacturer="rockchip",device="npu",id="2"} 0
rockchip_npu_load{manufacturer="rockchip",device="npu",id="0"} 28
# EOF

If you are running the exporter in a remote machine, replace 127.0.0.1 with actual IP address.

Run as a systemd service

Consider using a systemd service file.

Modify the following sample so the executable file and the config file locations are correct. Name this service file as you wish (rkxporter.service as an example) and put it in directory /etc/systemd/system.

# File name: rkxporter.service
# This is a sample file. Please modify before using.
[Unit]
Description=Rockchip NPU Exporter
After=network.target
Before=shutdown.target

[Service]
WorkingDirectory=/usr/local/npuexporter
ExecStart=/usr/local/npuexporter/bin/rknpu-exporter
Type=simple
Restart=always
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target

Then start it with systemd command.

sudo systemctl start rkxporter

License

See LICENSE for more information.

Authors

Yin Guobing (尹国冰) - yinguobing

About

Prometheus exporter for Rockchip NPU load metrics, written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Languages