Skip to content

Instantly share code, notes, and snippets.

@towo
Last active July 9, 2020 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save towo/d13ad92fc554c8aa6a7f53aea030520c to your computer and use it in GitHub Desktop.
Save towo/d13ad92fc554c8aa6a7f53aea030520c to your computer and use it in GitHub Desktop.
Apt metrics systemd units for prometheus-node-exporter

Simple service and timer for the apt.sh metrics script from the Prometheus community script collection. Used on a Debianite system with the Debian repository version of node-exporter, YMMV. puppet/prometheus uses node-exporter as the group by default, can be changed by setting prometheus::node_exporter::group via hiera/resource parameter. Alternative uses with ACLs are possible; one would have to investigate if the DynamicUser overlay would work for deleting files from a directory.

[Unit]
Description=Collect APT metrics
[Service]
ExecStartPre=rm -f /var/lib/prometheus/node-exporter/apt.prom
ExecStart=/usr/local/bin/apt.sh
User=nobody
Group=prometheus
StandardOutput=file:/var/lib/prometheus/node-exporter/apt.prom
[Unit]
Description=Collect APT metrics
[Timer]
OnCalendar=hourly
Unit=apt-metrics.service
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment