Graham Christensen

Prometheus and the NixOS System Version

posted on February 04 2018

Prometheus and the NixOS System Version

Use the Prometheus Node Exporter Textfile collector to help correlate changes in your application’s behavior with NixOS deployments.

First, configure Prometheus’s NodeExporter to enable Textfile collection:

services.prometheus.nodeExporter = {
  enable = true;
  enabledCollectors = [
  extraFlags = [

Second, populate the textfile directory with the current system version on every boot and deployment:

system.activationScripts.node-exporter-system-version = ''
  mkdir -pm 0775 /var/lib/prometheus-node-exporter-text-files
    cd /var/lib/prometheus-node-exporter-text-files
      echo -n "system_version ";
      readlink /nix/var/nix/profiles/system | cut -d- -f2
    ) >
    mv system-version.prom

Then, configure Grafana to use the system_version as an Annotation with the following query:



Graham works on NixOS.