node-exporter-textfile-collector-scripts
node-exporter-textfile-collector-scripts copied to clipboard
Added Security Updates as separate Value
Isn't this already achievable with simple label matching? For example, with these source metrics:
# HELP apt_upgrades_pending Apt package pending updates by origin.
# TYPE apt_upgrades_pending gauge
apt_upgrades_pending{origin="Debian:11.4/stable",arch="all"} 2
apt_upgrades_pending{origin="Debian:11.4/stable",arch="amd64"} 14
apt_upgrades_pending{origin="Debian:11.4/stable,Debian-Security:11/stable-security",arch="all"} 2
apt_upgrades_pending{origin="Debian:11.4/stable,Debian-Security:11/stable-security",arch="amd64"} 11
apt_upgrades_pending{origin="Debian-Security:11/stable-security",arch="amd64"} 1
... I can get the number of security upgrades with sum(apt_upgrades_pending{origin=~".*Debian-Security.*"})
PS: I think we'd prefer not to tempt fate by doing precisely the thing that apt warns against doing.
$ apt list --upgradable | grep -c "\-security"
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Hi @dswarbrick, yes this is possible. But if you're using Grafana and use a Query like sum by(job) (apt_upgrades_pending{origin=~".*Security.*"}) you get "No Data" if there are no Updates, which is not so informative.
@manuel-held How about simply changing your query to
sum by(job) (apt_upgrades_pending{origin=~".*Security.*"}) or vector(0)
This has been superseded by https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/pull/99
Closing, since apt.sh has been superseded by apt_info.py.
Hello @dswarbrick ,
with sum by(job) (apt_upgrades_pending{origin=~".*Security.*"}) or vector(0) you only get {} 0 as a global result when there are no match / no security upgrades on each instance.
Is it possible to still have a vector with 0 for each original value of apt_upgrades_pending instead ?