Monitor your Raspberry Pi using Rust, Prometheus and Grafana

Hey all,

I put up a sample project for creating a custom Prometheus exporter using the Rust programming language:

You can export metrics for your rust applications or even build binaries for other use cases.

Check out the file in exporter>src. The sample code is based on Francesco Cogno excellent prometheus_exporter_base library(crate) and example project to calculate the size of a folder. You can tweak it to suit your use case.

The project provisions Prometheus and Grafana too, so you can collect and visualise your data like this:

Let me know if you find this helpful or have any suggestions. I appreciate any feedback or reviews.


1 Like

Hey @rahul thanks for sharing your project! Maybe @zrzka would be interested to see this? :slight_smile:

Hey @chrisys thanks! Hope it was helpful. :grin:

Hey @rahul,

I missed the notification, hence my late reply. Thanks for sharing this! Looks good!

I’ve got couple of suggestions …

  • you can delete the repo.yml file, it’s used by our internal CI only
  • the ENV INITSYSTEM=on line can be removed too, it’s no longer supported, see the Major Changes
    • actually we should remove it from our rust hello world example as well
    • I even wonder why it’s there, because systemd wasn’t required for this example

And I believe that this line

RUN rm -rf target/release/hello* target/release/deps/rust_prometheus_exporter-*

… should look like this one …

RUN rm -rf target/release/rust_prometheus_exporter target/release/deps/rust_prometheus_exporter-*

… just a small mistake where you probably just forgot to rename hello to your binary name.

hey @zrzka, Thanks for the detailed review! I learnt some new things :slight_smile:

Do I need to RUN c_rehash though?


Hey @rahul,

yes, you have to. Your base image is Debian Buster based and there’s an issue with curl & certificates. It’s a workaround for this problem. You can learn more in this thread.